title: Convert list of samaccount names to distinguished names
body: <p>I have a list of account names (thousands) that I need to add as members of a group, so I need to look up the distinguished names of those accounts so I can add them as members of a group.</p>
  
  <p>There are 21000 user accounts.  It takes hours to look up the distinguished names, is there a faster way?</p>
  
  <pre><code>DirectoryEntry deDomain = new DirectoryEntry();
  deDomain.Path = "LDAP://DC=my,DC=ca;
  deDomain.Username = "me";
  deDomain.Password =  "mypassword";
  
  DirectorySearcher dsSearch = new DirectorySearcher(deDomain);
  dsSearch.CacheResults = false;
  dsSearch.PropertiesToLoad.Add("distinguishedname");
  
  foreach (string sam in lstSamAccountNames)
  {
      dsSearch.Filter = $"(&amp;(objectCategory=person)(objectClass=user)(SAMAccountName={ReplaceSpecialCharacters(sSamAccountName)}))";
      SearchResult srPerson = dsSearch.FindOne();
  
      yield return  srPerson.Properties["distinguishedname"][0].ToString();
  }
  </code></pre>