title: Accessing active directory from C#
body: <p>I am trying to access directory in XXX domain from my console application. </p>
  
  <pre><code>             DirectoryEntry oDE = new DirectoryEntry("LDAP://DC=XXXX,DC=myDomain,DC=com");
  
              using (DirectorySearcher ds = new DirectorySearcher(oDE))
              {
                  ds.PropertiesToLoad.Add("name");
                  ds.PropertiesToLoad.Add("userPrincipalName");
  
                  ds.Filter = "(&amp;(objectClass=user))";
  
                  SearchResultCollection results = ds.FindAll();
  
                  foreach (SearchResult result in results)
                  {
                      Console.WriteLine("{0} - {1}",
                          result.Properties["name"][0].ToString(),
                          result.Properties["userPrincipalName"][0].ToString());
                  }
              }
  </code></pre>
  
  <p>when the line SearchResultCollection results = ds.FindAll(); executes I receive the error "There is no such object on the server."</p>
  
  <p>what i am doing wrong?</p>