title: Get machine name from Active Directory
body: <p>I have performed an "LDAP://" query to get a list of computers within a specified OU, my issue is not being able to collect just the computer "name" or even "cn".</p>
  
  <pre><code>        DirectoryEntry toShutdown = new DirectoryEntry("LDAP://" + comboBox1.Text.ToString());
          DirectorySearcher machineSearch = new DirectorySearcher(toShutdown);
          //machineSearch.Filter = "(objectCatergory=computer)";
          machineSearch.Filter = "(objectClass=computer)";
          machineSearch.SearchScope = SearchScope.Subtree;
          machineSearch.PropertiesToLoad.Add("name");
          SearchResultCollection allMachinesCollected = machineSearch.FindAll();
          Methods myMethods = new Methods();
          string pcName;
          foreach (SearchResult oneMachine in allMachinesCollected)
          {
              //pcName = oneMachine.Properties.PropertyNames.ToString();
              pcName = oneMachine.Properties["name"].ToString();
              MessageBox.Show(pcName);
          }
  </code></pre>
  
  <p>Help much appreciated.</p>