use of com.zimbra.cs.ldap.ZLdapFilter 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.ZLdapFilter in project zm-mailbox by Zimbra.
the class TestLdapZLdapFilter method domainByKrb5Realm.
@Test
public void domainByKrb5Realm() throws Exception {
String REALM = getTestName();
String filter = LegacyLdapFilter.domainByKrb5Realm(REALM);
ZLdapFilter zLdapFilter = filterDactory.domainByKrb5Realm(REALM);
verify(FilterId.DOMAIN_BY_KRB5_REALM, filter, zLdapFilter);
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class TestLdapZLdapFilter method identityByName.
@Test
public void identityByName() throws Exception {
String NAME = getTestName();
String filter = LegacyLdapFilter.identityByName(NAME);
ZLdapFilter zLdapFilter = filterDactory.identityByName(NAME);
verify(FilterId.IDENTITY_BY_NAME, filter, zLdapFilter);
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class Cleanup method getDirectChildrenDNs.
private static List<String> getDirectChildrenDNs(ZLdapContext zlc, String dn) throws Exception {
final List<String> childrenDNs = new ArrayList<String>();
ZLdapFilter filter = ZLdapFilterFactory.getInstance().anyEntry();
ZSearchControls searchControls = ZSearchControls.createSearchControls(ZSearchScope.SEARCH_SCOPE_ONELEVEL, ZSearchControls.SIZE_UNLIMITED, new String[] { "objectClass" });
ZSearchResultEnumeration sr = zlc.searchDir(dn, filter, searchControls);
while (sr.hasMore()) {
ZSearchResultEntry entry = sr.next();
childrenDNs.add(entry.getDN());
}
sr.close();
return childrenDNs;
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class UBIDLdapContext method moveChildren.
@Override
public void moveChildren(String oldDn, String newDn) throws ServiceException {
try {
// use ZLdapFilter instead of just the native Filter so it's
// convenient for stating
ZLdapFilter filter = ZLdapFilterFactory.getInstance().anyEntry();
// Filter filter = Filter.createPresenceFilter(LdapConstants.ATTR_OBJECTCLASS);
SearchRequest searchRequest = new SearchRequest(oldDn, SearchScope.ONE, derefAliasPolicy, // size limit
0, // time limit
0, // getTypesOnly
false, ((UBIDLdapFilter) filter).getNative());
searchRequest.setAttributes("dn");
SearchResult result = UBIDLdapOperation.SEARCH.execute(this, searchRequest, filter);
List<SearchResultEntry> entries = result.getSearchEntries();
for (SearchResultEntry entry : entries) {
DN entryDN = entry.getParsedDN();
String childDn = entryDN.toNormalizedString();
String childRdn = entryDN.getRDNString();
UBIDLdapOperation.MODIFY_DN.execute(this, childDn, childRdn, true, newDn);
}
} catch (LDAPException e) {
throw mapToLdapException("unable to move children", e);
}
}
Aggregations