Jeremy
Jeremy

Reputation: 46420

Return OU in active directory search

I have performed an active directory search and now have a SearchResultCollection of all the users in active directory. I've specified all the properties that the DirectorySearch should load, but I also want to know what OU (distinguished name) each user is in. I know I could figure it out be getting a DirectoryEntry for each user, and look at the distinguished name of the directory entries parent directory entry, but this seems like it would be terribly slow. Is it possible to return the ou distinguished name some other way?

Upvotes: 1

Views: 1038

Answers (1)

geoffc
geoffc

Reputation: 4100

Subtring-after the first comma?

cn=bob, ou=someOU,dc=this,dc=that

would seem to be your goal.

Upvotes: 1

Related Questions