WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

List Users that Belong to an OU

 Keywords:  List Users Organisational Unit OU AD Active directory

Question:

This there function that will list the users that belong to a Organizational Unit (i.e. OU). I have a OU named, "KeyAccts" and would like to list the user associated with that OU.

Any help would be appreciated.

Answer:

try this:
ou_path="LDAP://server.com/OU=yourOU,DC=server,DC=com" ;the path to the OU you want to search

users_in_OU=dsfindpath(ou_to_search,"(&(objectcategory=Person)(objectclass=user))")
users_in_OU will contain a tab delimited list of the paths to all users within the ou so you may want to loop through the list and get whatever properties you want about the user (i.e. name, email, etc)

You can also use the "dsGetChldPath" function. It would look something like this:

lUserPaths = dsGetChldPath(OuPath, "user")
where the second parameter is the class of object you wish to get paths for.
Article ID:   W15817
File Created: 2008:07:17:08:09:10
Last Updated: 2008:07:17:08:09:10