DirectorySearcher.findOne returns null RRS feed

  • Question

  • User-510697852 posted

    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.

    Monday, February 12, 2018 10:30 AM

All replies