title: Retrieving Global Address List from DirectoryServices is Extremely Slow
body: <p>The following code allows me to extract the entire Global Address List from DirectoryServices. The code is functional in that it gives me what I need. The problem is that it takes about 20 seconds to return 1000 objects. Is there anything that I can do to speed this up?</p>
  
  <pre><code>    public static List&lt;Address&gt; GetGlobalAddressList()
      {
          using (var searcher = new DirectorySearcher())
          {
              using (var entry = new DirectoryEntry(searcher.SearchRoot.Path, "*****", "*****"))
              {
                  searcher.Filter = "(&amp;(mailnickname=*)(objectClass=user))";
                  searcher.PropertiesToLoad.Add("cn");
                  searcher.PropertyNamesOnly = true;
                  searcher.SearchScope = SearchScope.Subtree;
                  searcher.Sort.Direction = SortDirection.Ascending;
                  searcher.Sort.PropertyName = "cn";
                  var results = searcher.FindAll();
                  var addressList = new List&lt;Address&gt;();
                  foreach (SearchResult i in results)
                  {
                      var address = new Address
                      {
                          DisplayName = (string)i.GetDirectoryEntry().Properties["displayName"].Value,
                          Mail = (string) i.GetDirectoryEntry().Properties["mail"].Value
                      };
                      addressList.Add(address);
  
                  }
                  return addressList;
              }
          }
      }
  
      public class Address
      {
          public string DisplayName { get; set; }
          public string Mail { get; set; }
  
      }
  </code></pre>