title: Is it possible to find the local computer in AD without hardcoding its domain?
body: <p>I'm using C# to find my local computer's <code>objectGuid</code> by querying Active Directory.  To do this, I'm currently using a <code>DirectorySearcher</code>, passing it a (hardcoded) path as the search root, and then filtering by computer name:</p>
  
  <pre><code>string adRootPath = @"LDAP://OU=foo,DC=bar,DC=baz,DC=com";    
  DirectoryEntry adRoot = new DirectoryEntry(adRootPath);
  
  DirectorySearcher searcher = new DirectorySearcher(adRoot);
  searcher.Filter = @"(&amp;(objectCategory=Computer)(CN=" + Environment.MachineName + "))";
  </code></pre>
  
  <p>I don't want to hardcode the search root, and was wondering if there is a better way.  I thought about just using an empty search root, but I was worried that computer names may not always be unique across different domains.</p>
  
  <p>Is there a better way?</p>