Hello,

I'm trying to search for a user in my eDirectory using the Java LDAP libs
(not JNDI). I search for the user at a possible location first
(SCOPE_BASE) and, if not found there, the whole tree (SCOPE_SUB). I get
very strange results when doing this, with errors ranging from "entry not
found" to "could not disconnect, still pending operations" (roughly).

Through debugging, I realized that when I had a breakpoint between the
search and the processing of the result, everything works fine. So I
inserted some for loops for testing, and it works with those delays. What
am I doing wrong? The seach is syncronous, so it shouldn't return without
the results, right?

Here's my code:

----8<----
searchResults = lc.search(possibleDn,
LDAPConnection.SCOPE_BASE,
"(objectClass=*)",
new String[] { "dn" },
false);

for (int i=0;i<2000000000;i++){}
if (searchResults.getCount() == 1)
return searchResults.next().getDN();

searchResults = lc.search(baseDn,
LDAPConnection.SCOPE_SUB,
"(cn="+username+")",
new String[] { "dn" },
false);

for (int i=0;i<2000000000;i++){}
if (searchResults.getCount() == 1)
return searchResults.next().getDN();
else if (searchResults.getCount() > 1)
throw new DatabaseException("Found more than one user with the
specified username!");
else
throw new DatabaseException("The user couldn't be found in the
database!");
----8<----

Can anyone help me with this one?