use of com.zimbra.cs.ldap.LdapException.LdapMultipleEntriesMatchedException in project zm-mailbox by Zimbra.
the class LdapProvisioning method getGroupByQuery.
private Group getGroupByQuery(ZLdapFilter filter, ZLdapContext initZlc, boolean basicAttrsOnly, boolean loadFromMaster) throws ServiceException {
try {
String[] returnAttrs = basicAttrsOnly ? BASIC_GROUP_ATTRS : null;
ZSearchResultEntry sr = helper.searchForEntry(mDIT.mailBranchBaseDN(), filter, initZlc, loadFromMaster, returnAttrs);
if (sr != null) {
ZAttributes attrs = sr.getAttributes();
List<String> objectclass = attrs.getMultiAttrStringAsList(Provisioning.A_objectClass, CheckBinary.NOCHECK);
if (objectclass.contains(AttributeClass.OC_zimbraDistributionList)) {
return makeDistributionList(sr.getDN(), attrs, basicAttrsOnly);
} else if (objectclass.contains(AttributeClass.OC_zimbraGroup)) {
return makeDynamicGroup(initZlc, sr.getDN(), attrs);
}
}
} catch (LdapMultipleEntriesMatchedException e) {
throw AccountServiceException.MULTIPLE_ENTRIES_MATCHED("getGroupByQuery", e);
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup group via query: " + filter.toFilterString() + " message:" + e.getMessage(), e);
}
return null;
}
use of com.zimbra.cs.ldap.LdapException.LdapMultipleEntriesMatchedException in project zm-mailbox by Zimbra.
the class LdapProvisioning method getDynamicGroupByQuery.
private DynamicGroup getDynamicGroupByQuery(ZLdapFilter filter, ZLdapContext initZlc, boolean basicAttrsOnly) throws ServiceException {
try {
String[] returnAttrs = basicAttrsOnly ? BASIC_DYNAMIC_GROUP_ATTRS : null;
ZSearchResultEntry sr = helper.searchForEntry(mDIT.mailBranchBaseDN(), filter, initZlc, false, returnAttrs);
if (sr != null) {
return makeDynamicGroup(initZlc, sr.getDN(), sr.getAttributes());
}
} catch (LdapMultipleEntriesMatchedException e) {
throw AccountServiceException.MULTIPLE_ENTRIES_MATCHED("getDynamicGroupByQuery", e);
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup group via query: " + filter.toFilterString() + " message:" + e.getMessage(), e);
}
return null;
}
use of com.zimbra.cs.ldap.LdapException.LdapMultipleEntriesMatchedException in project zm-mailbox by Zimbra.
the class TestLdapHelper method searchForEntryMultipleMatchedEntries.
@Test
public void searchForEntryMultipleMatchedEntries() throws Exception {
LdapDIT dit = prov.getDIT();
String base = dit.configBranchBaseDN();
ZLdapFilter filter = filterFactory.allAccounts();
boolean caughtException = false;
try {
ZSearchResultEntry entry = ldapHelper.searchForEntry(base, filter, null, false);
assertNotNull(entry);
} catch (LdapMultipleEntriesMatchedException e) {
caughtException = true;
}
assertTrue(caughtException);
}
Aggregations