I am trying to search on an LDAP server (Active Directory). When I analyze the search results, the method hasMoreElements NamingEnumerationtakes about 15-20 seconds to execute when it returns false. This is not the case when it returns true. Is there any way to solve this problem?
code:
SearchControls ctrl = new SearchControls();
ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);
String searchFilter = "(&(objectClass=user("uid"="abc"))";
NamingEnumeration ne = dirContext.search("ldap://abc:389/dc=abc,dc=xy", searchFilter,ctrl);
if (ne != null) {
while (ne.hasMoreElements()) {
}
source
share