I am getting following exception while searching LDAP in Java. It fetches many records but in the last it throws following exception.
netscape.ldap.LDAPException: error result (4); Sizelimit exceeded
at netscape.ldap.LDAPConnection.checkMsg(LDAPConnection.java:4880)
at netscape.ldap.LDAPConnection.checkSearchMsg(LDAPConnection.java:2638)
at netscape.ldap.LDAPSearchResults.fetchResult(LDAPSearchResults.java:548)
at netscape.ldap.LDAPSearchResults.hasMoreElements(LDAPSearchResults.java:456)
I have tried following options.
1.getConnection().setOption(LDAPv2.SIZELIMIT,new Integer(0));
getConnection().setOption(LDAPv2.TIMELIMIT,new Integer(0));
2. LDAPSearchConstraints ldapSearchConst = getConnection().getSearchConstraints();
ldapSearchConst.setMaxResults(-1);
ldapSearchConst.setTimeLimit(-1);
3. Both 1 and 2 together
Only the number of records returned are different for above options but the exception doesn't go away.Can anybody help me on this. Lot of thanks
From RFC4511:
A size limit that restricts the maximum number of entries to be returned as a result of the Search. A value of zero in this field indicates that no client-requested size limit restrictions are in effect for the Search. Servers may also enforce a maximum number of entries to return.
The size limit in #1 is the client-requested size limit, which cannot override the server-side time limit, referenced in the above quote from RFC4511. No matter what value the client-requested time limit contains, that value cannot override the server enforcement.