[Date Prev][Date Next] [Chronological] [Thread] [Top]

JLDAP LdapSearchResults getCount strange behaviour



** JLDAP Specific query **

Dear JLDAPers

Here's a snippet of code, from a superficially modified Search.java from the distribution samples.

-------------8<-------------------------------
lc.connect( ldapHost, ldapPort );
            // bind to the server
            lc.bind( ldapVersion, loginDN, password.getBytes("UTF8") );

LDAPSearchResults searchResults =
lc.search( searchBase,
searchScope,
searchFilter,
new String[]{"uid"}, // return all attributes
false); // return attrs and values
//try{Thread.sleep(200);}
//catch(InterruptedException ie){}
System.out.println(System.nanoTime() + " Num results: "+searchResults.getCount());
System.out.println(System.nanoTime() + " Num results: "+searchResults.getCount());
System.out.println(System.nanoTime() + " Num results: "+searchResults.getCount());
System.out.println(System.nanoTime() + " Num results: "+searchResults.getCount());
System.out.println(System.nanoTime() + " Num results: "+searchResults.getCount());
System.out.println(System.nanoTime() + " Num results: "+searchResults.getCount());


----------------->8------------------------------

and here is the output.....

rob@host:~/java >java -cp classes/:lib/jars/ldap.jar LDAPsearch rob
11733728995322827  Num results: 0
11733728997727660  Num results: 20
11733728997820487  Num results: 20
11733728997905835  Num results: 20
11733728998038362  Num results: 20
11733728998123031  Num results: 20
rob@host:~/java >java -cp classes/:lib/jars/ldap.jar LDAPsearch rob
11733731565049880  Num results: 0
11733731565416717  Num results: 0
11733731565467264  Num results: 0
11733731565515698  Num results: 0
11733731565623727  Num results: 0
11733731565672714  Num results: 0
rob@host:~/java >java -cp classes/:lib/jars/ldap.jar  LDAPsearch rob
11733734056219191  Num results: 20
11733734056553648  Num results: 20
11733734056600103  Num results: 20
11733734056644689  Num results: 20
11733734056743146  Num results: 20
11733734056788108  Num results: 20


You can see by the time stamps that all three results where taken in succession.


If I uncomment the Thread.sleep(200) I never see such bizarre results.

Qs. Is getCount() not for this purpose? I thought search(...) was a synchronous method... should it not block until everything is returned? Is there something else I should be doing?

Openldap 2.3.24 gcc Solaris 10 u1 x64
Java 1.5.0_04
jldap downloaded a couple of days ago

Cheers for any assistance...

Rob