title: Active directory authentication
body: <p>I'm using the code below to authenticate a user in Active Directory, but the password is sending in clear text. How can I hash my password and then send it to Active Directory?</p>
  
  <pre><code>DirectoryEntry entry = new DirectoryEntry(path, username, pwd);
  try
  {
     //Bind to the native AdsObject to force authentication.
     object obj = entry.NativeObject;
  
     DirectorySearcher search = new DirectorySearcher(entry);
  
     search.Filter = "(SAMAccountName=" + username + ")";
     search.PropertiesToLoad.Add("cn");
     SearchResult result = search.FindOne();
  
     if (null == result)
     {
        return false;
     }
  
     //Update the new path to the user in the directory.
     _path = result.Path;
     _filterAttribute = (string)result.Properties["cn"][0];
  }
  catch (Exception ex)
  {
     throw new Exception("Error authenticating user. " + ex.Message);
  }
  
  return true;
  </code></pre>