Multi Domain Active Directory Forest query in C#

Status
Not open for further replies.

hygor

Daemon Poster
Messages
833
Hiya,

I am trying to query an active directory setup (to retrieve user's details for an intranet system).

The active directory is set up as a multi domain forest in the following sort of structure:

.here
|
_____________________________________________________________
| | |
this.here (first domain in the AD forest) place.here .test.here
|
my.place.here

and so on...

I have been told by the client to connect to the GC server and run a query on .here which should allow the entire forest to be searched however I have tried querying the following

my c# code behind the user control contains the following:

lConnex = "LDAP://[SERVER]:[PORT]/DC=here";
lfilter = "(&(objectclass=user)(!(objectclass=computer)))";

DirectoryEntry UsersTree = new DirectoryEntry(lConnex, "[UNAME]", "[PASS], AuthenticationTypes.None);

DirectorySearcher Searcher = new DirectorySearcher();
Searcher.SearchRoot = UsersTree;
Searcher.Filter = lfilter;
Searcher.SearchScope = SearchScope.Subtree;

SearchResultCollection Results = Searcher.FindAll();

I then run through the results and map details like first name and family name to a data table.

This gives me the following error:

Error Code 8007202B - "A referral was returned from the server"

I think this is to do with the multi-domain structure of the AD Forest as if I change the LDAP connection to: lConnex = "LDAP://[SERVER]:[PORT]/DC=this,DC=here"; I can retrieve a few users (but not those from the other domains).

I have also tried changing LDAP:// to GC:// but it makes no difference.

I am starting to go crazy now as I have been staring at this problem and going in circles for ages, any help would be greatly appreciated.

Thanks

Hygor
 
I think this is to do with the multi-domain structure of the AD Forest as if I change the LDAP connection to: lConnex = "LDAP://[SERVER]:[PORT]/DC=this,DC=here"; I can retrieve a few users (but not those from the other domains).

i would try to find all the distinguished names in the forest. Then run separate queries.



edit:

this post from another forum describes searching gcs /multi domains. doesn't give an answer but describes some possibilites. that board could prolly answer more quickly.

Directory Programming .NET - Best Way to Handle Multiple Domains?
 
Status
Not open for further replies.
Back
Top Bottom