use of com.zimbra.cs.ldap.LdapException.LdapSizeLimitExceededException in project zm-mailbox by Zimbra.
the class TestLdapZLdapContext method searchPaged.
@Test
public void searchPaged() throws Exception {
int SIZE_LIMIT = 5;
String base = LdapConstants.DN_ROOT_DSE;
ZLdapFilter filter = ZLdapFilterFactory.getInstance().anyEntry();
String[] returnAttrs = new String[] { "objectClass" };
final List<String> result = new ArrayList<String>();
SearchLdapOptions.SearchLdapVisitor visitor = new SearchLdapOptions.SearchLdapVisitor() {
@Override
public void visit(String dn, Map<String, Object> attrs, IAttributes ldapAttrs) {
result.add(dn);
}
};
SearchLdapOptions searchOptions = new SearchLdapOptions(base, filter, returnAttrs, SIZE_LIMIT, null, ZSearchScope.SEARCH_SCOPE_SUBTREE, visitor);
boolean caughtException = false;
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapUsage.UNITTEST);
zlc.searchPaged(searchOptions);
} catch (LdapSizeLimitExceededException e) {
caughtException = true;
} finally {
LdapClient.closeContext(zlc);
}
assertTrue(caughtException);
assertEquals(SIZE_LIMIT, result.size());
}
use of com.zimbra.cs.ldap.LdapException.LdapSizeLimitExceededException in project zm-mailbox by Zimbra.
the class TestLdapZLdapContext method searchDir.
@Test
public void searchDir() throws Exception {
int SIZE_LIMIT = 5;
String base = LdapConstants.DN_ROOT_DSE;
ZLdapFilter filter = ZLdapFilterFactory.getInstance().anyEntry();
String[] returnAttrs = new String[] { "objectClass" };
ZSearchControls searchControls = ZSearchControls.createSearchControls(ZSearchScope.SEARCH_SCOPE_SUBTREE, SIZE_LIMIT, returnAttrs);
int numFound = 0;
boolean caughtException = false;
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapUsage.UNITTEST);
ZSearchResultEnumeration ne = zlc.searchDir(base, filter, searchControls);
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
numFound++;
}
ne.close();
} catch (LdapSizeLimitExceededException e) {
caughtException = true;
} finally {
LdapClient.closeContext(zlc);
}
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);
}
*/
}
use of com.zimbra.cs.ldap.LdapException.LdapSizeLimitExceededException in project zm-mailbox by Zimbra.
the class LdapProvisioning method addressExistsUnderDN.
/*
* returns if any one of addrs is an email address under the specified baseDN
*/
private boolean addressExistsUnderDN(ZLdapContext zlc, String baseDN, String[] addrs) throws ServiceException {
ZLdapFilter filter = filterFactory.addrsExist(addrs);
ZSearchControls searchControls = ZSearchControls.createSearchControls(ZSearchScope.SEARCH_SCOPE_SUBTREE, 1, null);
try {
long count = helper.countEntries(baseDN, filter, searchControls, zlc, LdapServerType.MASTER);
return count > 0;
} catch (LdapSizeLimitExceededException e) {
return true;
}
}
use of com.zimbra.cs.ldap.LdapException.LdapSizeLimitExceededException 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);
}
*/
}
Aggregations