Search in sources :

Example 1 with LdapMultipleEntriesMatchedException

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;
}
Also used : AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) LdapMultipleEntriesMatchedException(com.zimbra.cs.ldap.LdapException.LdapMultipleEntriesMatchedException) ZAttributes(com.zimbra.cs.ldap.ZAttributes) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 2 with LdapMultipleEntriesMatchedException

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;
}
Also used : AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) LdapMultipleEntriesMatchedException(com.zimbra.cs.ldap.LdapException.LdapMultipleEntriesMatchedException) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 3 with LdapMultipleEntriesMatchedException

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);
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) LdapDIT(com.zimbra.cs.account.ldap.LdapDIT) LdapMultipleEntriesMatchedException(com.zimbra.cs.ldap.LdapException.LdapMultipleEntriesMatchedException) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Aggregations

LdapMultipleEntriesMatchedException (com.zimbra.cs.ldap.LdapException.LdapMultipleEntriesMatchedException)3 ZSearchResultEntry (com.zimbra.cs.ldap.ZSearchResultEntry)3 ServiceException (com.zimbra.common.service.ServiceException)2 AccountServiceException (com.zimbra.cs.account.AccountServiceException)2 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)2 LdapDIT (com.zimbra.cs.account.ldap.LdapDIT)1 ZAttributes (com.zimbra.cs.ldap.ZAttributes)1 ZLdapFilter (com.zimbra.cs.ldap.ZLdapFilter)1