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);
}
}
Aggregations