Active Directory queries on all subdomains under root?

Hi all,

I am using C# 2.0.

Here is my active directory setup:

MAIN_DIRECTORY (root)
\ SUBDOMAIN1 -> [user1, user2]
\ SUBDOMAIN2 -> [user3, user4]

From a machine in the SUBDOMAIN1, I want to query user information from all subdomains under the root.

I am using the following code:

DirectoryEntry oDirEntry = new DirectoryEntry(string.Format("LDAP://{0}", SUBDOMAIN_1_OR_2));
string sSearchFilter = string.Format("(&(objectClass=user)(SAMAccountName={0}))", SOME_USERNAME);
DirectorySearcher oDirSearcher = new DirectorySearcher(oDirEntry, sSearchFilter);
oDirSearcher.SearchScope = SearchScope.Subtree;
SearchResultCollection aoUsers = oDirSearcher.FindAll();

This works fine when I explicitely query SUBDOMAIN1 with the users that are in that domain (user1, user2, ...) or SUBDOMAIN2 with the users from that domain (user3, user4, ...).

My problem is that at runtime, I don't know what subdomain the users are from and I don't want to query all subdomains one after the other to find user information.

Is these a way to query the entire directory (root) for users without knowing what subdomains they are in? If not, is there another better way to do this?

Thanks.
[1297 byte] By [huckfinn] at [2007-11-20 7:36:30]