Search in sources :

Example 81 with ZLdapFilter

use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.

the class TestLdapHelper method searchDirSizeLimitExceeded.

@Test
public void searchDirSizeLimitExceeded() throws Exception {
    int SIZE_LIMIT = 5;
    String base = LdapConstants.DN_ROOT_DSE;
    ZLdapFilter filter = filterFactory.anyEntry();
    String[] returnAttrs = new String[] { "objectClass" };
    ZSearchControls searchControls = ZSearchControls.createSearchControls(ZSearchScope.SEARCH_SCOPE_SUBTREE, SIZE_LIMIT, returnAttrs);
    int numFound = 0;
    boolean caughtException = false;
    try {
        ZSearchResultEnumeration ne = ldapHelper.searchDir(base, filter, searchControls);
        while (ne.hasMore()) {
            ZSearchResultEntry sr = ne.next();
            numFound++;
        }
        ne.close();
    } catch (LdapSizeLimitExceededException e) {
        caughtException = true;
    }
    assertTrue(caughtException);
/*
        // unboundid does not return entries if LdapSizeLimitExceededException
        // is thrown,  See commons on ZLdapContext.searchDir().
        if (testConfig != TestLdap.TestConfig.UBID) {
            assertEquals(SIZE_LIMIT, numFound);
        }
        */
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) ZSearchControls(com.zimbra.cs.ldap.ZSearchControls) ZSearchResultEnumeration(com.zimbra.cs.ldap.ZSearchResultEnumeration) LdapSizeLimitExceededException(com.zimbra.cs.ldap.LdapException.LdapSizeLimitExceededException) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 82 with ZLdapFilter

use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.

the class TestLdapHelper method searchDirNotFound.

@Test
public void searchDirNotFound() throws Exception {
    LdapDIT dit = prov.getDIT();
    String base = dit.configBranchBaseDN();
    ZLdapFilter filter = filterFactory.allSignatures();
    String[] returnAttrs = new String[] { "objectClass" };
    ZSearchControls searchControls = ZSearchControls.createSearchControls(ZSearchScope.SEARCH_SCOPE_SUBTREE, ZSearchControls.SIZE_UNLIMITED, returnAttrs);
    ZSearchResultEnumeration ne = ldapHelper.searchDir(base, filter, searchControls);
    int numFound = 0;
    while (ne.hasMore()) {
        ZSearchResultEntry sr = ne.next();
        numFound++;
    }
    ne.close();
    assertEquals(0, numFound);
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) ZSearchControls(com.zimbra.cs.ldap.ZSearchControls) LdapDIT(com.zimbra.cs.account.ldap.LdapDIT) ZSearchResultEnumeration(com.zimbra.cs.ldap.ZSearchResultEnumeration) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 83 with ZLdapFilter

use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.

the class TestLdapHelper method testAndModifyAttributes.

@Test
public void testAndModifyAttributes() throws Exception {
    ZLdapFilter filter = filterFactory.domainLockedForEagerAutoProvision();
    Map<String, Object> attrs = new HashMap<String, Object>();
    attrs.put(Provisioning.A_zimbraAutoProvLock, "blah");
    ZLdapContext zlc = null;
    try {
        zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UNITTEST);
        ldapHelper.testAndModifyEntry(zlc, ((LdapEntry) domain).getDN(), filter, attrs, domain);
    } finally {
        LdapClient.closeContext(zlc);
    }
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) HashMap(java.util.HashMap)

Example 84 with ZLdapFilter

use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.

the class TestLdapZLdapFilter method dynamicGroupByName.

@Test
public void dynamicGroupByName() throws Exception {
    String NAME = getTestName();
    String filter = LegacyLdapFilter.dynamicGroupByName(NAME);
    ZLdapFilter zLdapFilter = filterDactory.dynamicGroupByName(NAME);
    verify(FilterId.DYNAMIC_GROUP_BY_NAME, filter, zLdapFilter);
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter)

Example 85 with ZLdapFilter

use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.

the class TestLdapZLdapFilter method allDistributionLists.

@Test
public void allDistributionLists() throws Exception {
    String filter = LegacyLdapFilter.allDistributionLists();
    ZLdapFilter zLdapFilter = filterDactory.allDistributionLists();
    verify(FilterId.ALL_DISTRIBUTION_LISTS, filter, zLdapFilter);
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter)

Aggregations

ZLdapFilter (com.zimbra.cs.ldap.ZLdapFilter)123 ZSearchResultEntry (com.zimbra.cs.ldap.ZSearchResultEntry)15 ZSearchResultEnumeration (com.zimbra.cs.ldap.ZSearchResultEnumeration)13 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)10 ZSearchControls (com.zimbra.cs.ldap.ZSearchControls)10 ServiceException (com.zimbra.common.service.ServiceException)9 AccountServiceException (com.zimbra.cs.account.AccountServiceException)8 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)8 ArrayList (java.util.ArrayList)8 Server (com.zimbra.cs.account.Server)7 LdapDIT (com.zimbra.cs.account.ldap.LdapDIT)7 Account (com.zimbra.cs.account.Account)6 LdapSizeLimitExceededException (com.zimbra.cs.ldap.LdapException.LdapSizeLimitExceededException)6 NamedEntry (com.zimbra.cs.account.NamedEntry)5 SearchAccountsOptions (com.zimbra.cs.account.SearchAccountsOptions)5 BySearchResultEntrySearcher (com.zimbra.cs.account.ldap.BySearchResultEntrySearcher)5 SearchLdapOptions (com.zimbra.cs.ldap.SearchLdapOptions)5 ProvTest (com.zimbra.qa.unittest.prov.ProvTest)5 LDAPException (com.unboundid.ldap.sdk.LDAPException)3 SearchRequest (com.unboundid.ldap.sdk.SearchRequest)3