Search in sources :

Example 1 with ExternalGroupInfo

use of com.zimbra.cs.account.accesscontrol.ZimbraACE.ExternalGroupInfo in project zm-mailbox by Zimbra.

the class ExternalGroup method searchGroup.

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);
    }
}
Also used : ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) GroupHandler(com.zimbra.cs.account.grouphandler.GroupHandler) Domain(com.zimbra.cs.account.Domain) ExternalGroupInfo(com.zimbra.cs.account.accesscontrol.ZimbraACE.ExternalGroupInfo) LdapProv(com.zimbra.cs.account.ldap.LdapProv) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Aggregations

Domain (com.zimbra.cs.account.Domain)1 ExternalGroupInfo (com.zimbra.cs.account.accesscontrol.ZimbraACE.ExternalGroupInfo)1 GroupHandler (com.zimbra.cs.account.grouphandler.GroupHandler)1 LdapProv (com.zimbra.cs.account.ldap.LdapProv)1 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)1 ZSearchResultEntry (com.zimbra.cs.ldap.ZSearchResultEntry)1