title: Directory Services Com Exception Logon failure: unknown user name or bad password
body: <p>I am trying to  query LDAP server for a valid credential (username and password). 
  The problem is eventhough the credential itself is registered in the server it doesn't get authenticated. 
  If i put old ldapPath it works fine.
  The code is running on visual studio development server on my local machine (Not IIS).
  Whenever i run this i get "Directory Services Com Exception.
  Logon failure: unknown user name or bad password.".</p>
  
  <pre><code>const string ldapPath="LDAP:\\newDomain"; //please note this is just an example
  public override bool ValidateUser(string username, string password)
      {
  
              DirectoryEntry directoryEntry = new DirectoryEntry(ldapPath, username, password, AuthenticationTypes.ServerBind);
  
  
              DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry)
              {
                  SearchScope = SearchScope.Subtree,
                  Filter = "uid="+username
              };
  
              try
              {
                  using(HostingEnvironment.Impersonate())
                  {
                      SearchResult resultEmployee = directorySearcher.FindOne();
                      return resultEmployee.Properties["uid"].Count == 1;
                  }
  
              }
              catch (DirectoryServicesCOMException)
              {
                  return false;
              }       
  
      }
  </code></pre>