title: DirectoryEntry safe password handling
body: <p>The DirectoryEntry class requires username and password to be passed in as a string in cleartext. In c#, strings are generally not safe when used for storing sensitive data (there is no way to zero out the memory after use). How can I safely use DirectoryEntry to query the active directory without risking leaving the username in password in the memory? </p>
  
  <p>I do understand that the memory used to store this data will be released back to the heap after use, but it will not be cleared! </p>
  
  <p>If I'm wrong about any of my assertions, please let me know. </p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/wh2h7eed(v=vs.110).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/wh2h7eed(v=vs.110).aspx</a></p>