Last post Feb 12, 2018 10:56 AM by PatriceSc
Feb 12, 2018 10:30 AM|hardeshis|LINK
I am using LDAP authentication in my web application.
I am using following code,
string domainAndUsername = domain + @"\" + username;
DirectoryEntry entry = new DirectoryEntry(_strLdapPath, domainAndUsername, pwd);
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(samaccountname=" + username + ")";
SearchResult result = search.FindOne();
I am getting reult as null.
How can I find exact reason why it's returning null.
Can I log something like result.tostring(); so will know the reason.
It's working fine for some users. Returning null for some users. I want to find out why it's returning null.
Feb 12, 2018 10:56 AM|PatriceSc|LINK
I would use a tool such as https://technet.microsoft.com/en-us/library/cc773354(v=ws.10).aspx to inspect a user I can't find and triple check username and _strLdapPath is correct
for this user (for now my guess is that the search criteria is just wrong).
Not directly related but if using 4.x you could use https://msdn.microsoft.com/en-us/library/bb344891(v=vs.110).aspx.