huckfinn19
Programmer
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 users from both subdomains.
I am using the following code:
This works fine when I explicitely query SUBDOMAIN1 with the users that are in that domain (user1, user2, ...) or SUBDOMAIN2 with the users form 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.
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 users from both subdomains.
I am using the following code:
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);
SearchResultCollection aoUsers = oDirSearcher.FindAll();
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.