Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

ldap inconsistent search results



I'm getting mixed results when I do a search to LDAP. I found that it has to do with how much time I wait between calling LDAPConnection.search() and LDAPSearchResults.next(). For my situation the sweet spot is to sleep 100 millis (Thread.sleep(100)) before calling next(). This gives me a 50% chance of a hit or a miss for the same search base on a good connection.

Is there a way tell the search to block until complete or to implement a reliable ready() function for LDAPSearchResults similar to the one in BufferedReader?

Oh, and here is the entry in my pom:

<dependency> 
    <groupId>com.novell.ldap</groupId> 
    <artifactId>jldap</artifactId> 
    <version>4.3</version> 
</dependency>