views:

565

answers:

3

Hi

I'm doing an application which needs to query active directory and I've been using ldap queries for that purpose.

My problem is that I really cant use "ou=People,dc=pisoftware,dc=com" because the People node name keeps changing because my department name have been changed a lot recently. So in order to avoid the problem of having to do code change each time the name changes then I was wondering if there is any way to query by some sort of a folder id ?

For example I could maybe do "ouid=123456,dc=pisoftware,dc=com"

+3  A: 

Why can't you do an ldap query which applies a filter to return back only the objectCategory=person. You then could target that query at a search base DN, so that it can still return what you want even if the ou/People nodes get renamed/changed. There is a really good guide to which shows you how to do all this and how the queries work here: http://www.rlmueller.net/ADOSearchTips.htm

mrTomahawk
A: 

Hi

I've figured this out. I'm using the GUID of the Organizational unit object to fetch the users. See more at my blog

A: 

Another thing you could do would be to move the search up the directory hierarchy far enough to encompass wherever the users may be and do:

myDirectorySearcher.SearchScope = SearchScope.SubTree;

which would then do a recursive sub-tree search throughout AD.

Doug Seelinger