title: Active Directory cross-domain search
body: <p>I have an Ative Directory forest with two domains, AA.RR.COM, and BB.RR.COM, that contain users and groups.
  I need to search users in both domains, while querying against one of them, or example, AA.RT.COM
  How can I tell AD to run my LDAP query against all neighbour domains in the forest?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>using (var searcher = new DirectorySearcher(new DirectoryEntry(adServerName, adLogin, adPassword)))
  {
      var filter = string.Format("(&amp;(objectClass=person)(|(givenName=*{0}*)(displayName=*{0}*)(sn=*{0}*)(mail=*{0}*)))", valueToSearch);
  
      searcher.ReferralChasing = ReferralChasingOption.All;
  
      searcher.PropertiesToLoad.AddRange(new[] { 
          "samaccountName", 
          "memberOf", 
          "displayname", 
          "mail" });
  
      searcher.Sort = new SortOption("samaccountname", SortDirection.Ascending);
  }
  </code></pre>
  
  <p>This work fine when all users are in the same domain, but not when they are distributed within several domains in the same forest.</p>
  
  <p>Any help is appreciable.</p>