title: How can I lookup an IdentityReference in Active Directory?
body: <p>I'm trying to read out users, which are having permisson to read a document. I could already connect to the directory and read out the Identity Reference, but now I want to look the ID up in the Active Directory and read out the name from this ID.</p>
  
  <pre><code>DirectorySecurity ds = Directory.GetAccessControl(path);
                       AuthorizationRuleCollection arc = ds.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
                       foreach (FileSystemAccessRule fsar in arc)
                       {
                               StringBuilder sb = new StringBuilder();
                               sb.AppendLine("Identity : " + fsar.IdentityReference.Value);
  
  
                               sb.AppendLine("FileSystemRights : " + fsar.FileSystemRights);
                               + fsar.PropagationFlags);
  
  
                               Console.WriteLine(sb.ToString());
  </code></pre>
  
  <p>And I could already connect with the AD-Server, now I want to search with the DirectorySearcher for the IdentityReference.</p>
  
  <pre><code> System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry(@"LDAP://mydomain.local/");
                                entry.Username = username;
                                entry.Password = password;
  
                               System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry);
  
  mySearcher.Filter = "(......)"; //searching for IdentityReference
  </code></pre>
  
  <p>How can I do that? </p>
  
  <p>btw: I'm a C# beginner an thankfull for every answer.</p>