title: Directory Services, Search all available providers
body: <p>I have the following method used for searching for a User Group either on the local computer (done first) or in the Current Forest.</p>
  
  <pre><code>public string FindUserGroup(string group)
      {
          //Search local computer
          using (DirectorySearcher searcher = new DirectorySearcher(new DirectoryEntry()))
          {
              searcher.Filter = "(&amp;(objectClass=group)(|(cn=" + group + ")(dn=" + group + ")))";
              SearchResult result = searcher.FindOne();
              if (result != null)
                  return TranslateDirectoryEntryPath(result.GetDirectoryEntry().Path);
          }
  
          //Search current forest
          Forest forest = Forest.GetCurrentForest();
          foreach (Domain domain1 in forest.Domains)
          {
              using (DirectorySearcher searcher = new DirectorySearcher(domain1.GetDirectoryEntry()))
              {
                  searcher.Filter = "(&amp;(objectClass=group)(|(cn=" + group + ")(dn=" + group + ")))";
                  SearchResult result = searcher.FindOne();
                  if (result != null)
                      return TranslateDirectoryEntryPath(result.GetDirectoryEntry().Path);
              }
          }
  
          return string.Empty;
      }
  </code></pre>
  
  <p>My problem is that we as an example have say "domain.local" and "mydomain.local", and my current login is bound to "domain.local", then using below won't be able to find anything in "mydomain.local", even if I through the Windows User Interface is able to.</p>
  
  <p>How can I search all viewable providers from my computers perspective when I don't nessesarily know them all? Do I REALLY have to do the Registry Work my self?</p>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>One difference in the 2 domains is the "level" they are on when I in an object browser dialog chooses "Locations", it layouts as:</p>
  
  <ul>
  <li>Computer</li>
  <li>Entire Direction
  
  <ul>
  <li>domain.local</li>
  </ul></li>
  <li>mydomain.local</li>
  </ul>
  
  <p>So "mydomain.local" excists outside what is referred to as "Entire Directory", yet my computer can locate it, if that makes any difference?</p>