Last post Oct 06, 2011 04:26 PM by alm1
Oct 06, 2011 01:09 PM|alm1|LINK
Hope someone can help along the way here. I have a LDAP authenticator that goes out checks the username and p/w (the same one as all the examples seem to use). It works fine when i put in a known UserID and a correct/incorrect password (returns true or false
correctly). However when i punch in a random string of characters or make a spelling mistake on the username, it seems to run forever on the dsGet.FindOne() fnction.
I have tried all three timeouts in some form or the other, all set to 15 seconds, but nothing seems to stop the request running forever.
When i use a correct username the response is almost instanteneous.
(I tried using the search function here but damn it sucks)
Oct 06, 2011 02:50 PM|smirnov|LINK
Two things: you can try to set the
TimeOut property of LdapConnection (see example
here), or try to find a user with sAMAccountName=username and if found - test its password. Hope this helps.
Oct 06, 2011 04:26 PM|alm1|LINK
So i have a work around figured out, i think its kind of what you were implying smirnov.
Basically the first check is to see whether the user exists, if it does then it searches again with the password.
Otherwise it returns false.
DirectoryEntry deGetCN = new DirectoryEntry("LDAP://Hidden");
DirectorySearcher dsGet = new DirectorySearcher(deGetCN);
dsGet.Filter = "(SAMAccountName=" + strUser + ")";
dsGet.ServerTimeLimit = new TimeSpan(0, 0, 15);
dsGet.ClientTimeout = new TimeSpan(0, 0, 15);
SearchResult sr = dsGet.FindOne();
if (null == sr)
deGetCN.Username = strUser;
deGetCN.Password = strPassword;
SearchResult sra = dsGet.FindOne();