use of com.zimbra.cs.ldap.ZSearchResultEnumeration in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllCos.
@Override
public List<Cos> getAllCos() throws ServiceException {
List<Cos> result = new ArrayList<Cos>();
try {
ZSearchResultEnumeration ne = helper.searchDir(mDIT.cosBaseDN(), filterFactory.allCoses(), ZSearchControls.SEARCH_CTLS_SUBTREE());
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
result.add(new LdapCos(sr.getDN(), sr.getAttributes(), this));
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all COS", e);
}
Collections.sort(result);
return result;
}
use of com.zimbra.cs.ldap.ZSearchResultEnumeration in project zm-mailbox by Zimbra.
the class LdapProvisioning method listAllZimlets.
@Override
public List<Zimlet> listAllZimlets() throws ServiceException {
List<Zimlet> result = new ArrayList<Zimlet>();
try {
ZSearchResultEnumeration ne = helper.searchDir(mDIT.zimletBaseDN(), filterFactory.allZimlets(), ZSearchControls.SEARCH_CTLS_SUBTREE());
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
result.add(new LdapZimlet(sr.getDN(), sr.getAttributes(), this));
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all zimlets", e);
}
Collections.sort(result);
return result;
}
use of com.zimbra.cs.ldap.ZSearchResultEnumeration 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);
}
*/
}
use of com.zimbra.cs.ldap.ZSearchResultEnumeration in project zm-mailbox by Zimbra.
the class TestLdapHelper method hasSubordinates.
private boolean hasSubordinates(ZLdapContext zlc, String dn) throws Exception {
boolean hasSubordinates = false;
ZSearchResultEnumeration ne = null;
try {
ne = ldapHelper.searchDir(dn, filterFactory.hasSubordinates(), ZSearchControls.SEARCH_CTLS_SUBTREE(), zlc, LdapServerType.MASTER);
hasSubordinates = ne.hasMore();
if (hasSubordinates) {
int numEntries = 0;
String entryDn = null;
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
entryDn = sr.getDN();
numEntries++;
}
assertEquals(1, numEntries);
assertEquals(dn, entryDn);
}
} finally {
if (ne != null) {
ne.close();
}
}
return hasSubordinates;
}
use of com.zimbra.cs.ldap.ZSearchResultEnumeration 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);
}
Aggregations