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.

Query User to Identify which OU it Belongs


Question:

Ok, I've seen where you can query an OU to list it's members, but is there a way to query a user name to identify which OU it belongs to?

Basically, I'm trying to identify the OU incase a user has an issue, I could easily id the OU in which I would know what policies are set.

Sorry, like a few others on the board, I don't have a clear understanding of the ADSI or LDAP stuff

Any help would be appreciated

Answer:

Here is one approach using the ADSI extender:
; Path to domain server or domain dn
sPath = "LDAP://shamrock"

; Search filter to find user account 'Slash'
sFilter = "(&(objectCategory=person)(samAccountName=Slash))"

; Do the search.
lResults = dsFindPath(sPath , sFilter) 

; Get the OU path (assumes only one user found.)
sOuPath = dsGetPrntPath(lResults)

; Display results.
Message("User's OU", sOuPath)

Article ID:   W16322
File Created: 2005:02:18:12:19:48
Last Updated: 2005:02:18:12:19:48