The NamingEnumeration hasMoreElements method takes a long time to return false for LDAP

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()) {
        //parse results
    }
+5
source share
2 answers

NamingEnumeration hasMoreElements() . , , Context.REFERRAL "follow". , : hasMoreElements() ( hasMore() next() , ), 40 , LDAP, , Context.REFERRAL "".

+6

AD LDAP. , 1000.

1001, 1000 , , , .

, , betcha 1000, .

0

All Articles