Example #1
0
  private static ExternalGroup searchGroup(
      DomainBy domainBy, String extGroupGrantee, boolean asAdmin) throws ServiceException {
    LdapProv prov = LdapProv.getInst();

    ExternalGroupInfo extGrpInfo = ExternalGroupInfo.parse(extGroupGrantee);
    String zimbraDomain = extGrpInfo.getZimbraDmain();
    String extGroupName = extGrpInfo.getExternalGroupName();

    Domain domain = prov.get(domainBy, zimbraDomain);
    if (domain == null) {
      throw AccountServiceException.NO_SUCH_DOMAIN(zimbraDomain);
    }

    String searchBase = domain.getExternalGroupLdapSearchBase();
    String filterTemplate = domain.getExternalGroupLdapSearchFilter();

    if (searchBase == null) {
      searchBase = LdapConstants.DN_ROOT_DSE;
    }
    String searchFilter = LdapUtil.computeDn(extGroupName, filterTemplate);

    GroupHandler groupHandler = getGroupHandler(domain);

    ZLdapContext zlc = null;
    try {
      zlc = groupHandler.getExternalDelegatedAdminGroupsLdapContext(domain, asAdmin);

      ZSearchResultEntry entry =
          prov.getHelper()
              .searchForEntry(
                  searchBase, FilterId.EXTERNAL_GROUP, searchFilter, zlc, new String[] {"mail"});

      if (entry != null) {
        return makeExternalGroup(
            domain, groupHandler, extGroupName, entry.getDN(), entry.getAttributes());
      } else {
        return null;
      }
    } finally {
      LdapClient.closeContext(zlc);
    }
  }
Example #2
0
 private static GroupHandler getGroupHandler(Domain domain) {
   String className = domain.getExternalGroupHandlerClass();
   return GroupHandler.getHandler(className);
 }
Example #3
0
 boolean inGroup(Account acct, boolean asAdmin) throws ServiceException {
   return groupHandler.inDelegatedAdminGroup(this, acct, asAdmin);
 }