title: How to convert SID to String in .net
body: <p>I would like to convert the SID's System.Byte[] type to a String.</p>
  
  <p>My code:</p>
  
  <pre><code>string path = "LDAP://DC=abc,DC=contoso,DC=com";
  DirectoryEntry entry = new DirectoryEntry(path);
  DirectorySearcher mySearcher = new DirectorySearcher(entry);
  
  mySearcher.Filter = "(&amp;(objectClass=user)(samaccountname=user1))";
  results = mySearcher.FindAll();
  foreach (SearchResult searchResult in results)
  {
      Console.WriteLine(searchResult.Properties["ObjectSID"][0].ToString());
  }
  </code></pre>
  
  <p>I tried with this but it gets the values from the domain I'm currently logged in, and i need from a given domain.</p>
  
  <pre><code>System.Security.Principal.NTAccount(user1)
      .Translate([System.Security.Principal.SecurityIdentifier]).value
  </code></pre>