title: Directory Services in Windows Server 2008
body: <p>We have some older code that we'll be upgrading in the future, but for now we'd like to figure out why this code is not valid for all of our domains in 2008.  </p>
  
  <p>Our older code:</p>
  
  <pre><code>entry = new DirectoryEntry("WinNT://" + domain + "/" + username);
  </code></pre>
  
  <p>The newer code:</p>
  
  <pre><code>UserPrincipal u= UserPrincipal.FindByIdentity(c, 
  IdentityType.SamAccountName, username)
  </code></pre>
  
  <p>We have 2 domains, one trusts the other, though we don't control the domains.  In Server 2003 the older code works without any problems for both domains.  In Server 2008 it returns data successfully for our main domain, but throws an exception for the other.  </p>
  
  <p>The error is:</p>
  
  <pre><code> System.Runtime.InteropServices.COMException (0x80070035): The network path was not found.
  at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
  at System.DirectoryServices.DirectoryEntry.Bind()
  at System.DirectoryServices.DirectoryEntry.get_AdsObject()
  at System.DirectoryServices.PropertyValueCollection.PopulateList()
  at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
  at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
  </code></pre>
  
  <p>Why does WinNT fail for one domain in 2008, when it worked in 2003?  Does Microsoft have any documentation on the WinNT type of DirectoryEntry?  Is there a way to resolve this in Server 2008, other than upgrading the code?</p>