Find what OU a user is a member of

G

Guest

Can someone tell me the easiest way to find out what OU a user is a member of.

Thanks
 
D

Deji Akomolafe

The OU is part of the distinghuishedname of the user object. So, if you know
how to get the DN, you will get the OU. Alternatively, if you enable
"advanced" view in ADUC, you can also see the OU of an object by looking at
the properties.

--

Sincerely,
Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I
Microsoft MVP - Directory Services
www.readymaids.com - we know IT
www.akomolafe.com
Do you now realize that Today is the Tomorrow you were worried about
Yesterday? -anon
 
J

Jerold Schulman

Can someone tell me the easiest way to find out what OU a user is a member of.

Thanks


You can use dsquery to query the user name for the distinguished name.

dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=Jerry))" -attr distinguishedName -limit 0

See tip 7714 » What attribute names can I use with the user filtered dsquery command?
in the 'Tips & Tricks' at http://www.jsifaq.com


You can use ADFind freeware to do the same:
adfind -default -dsq -f "&(objectcategory=person)(samaccountname=Jerry)"

See tip 5898 » Freeware ADFind

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
G

Guest

Any idea of how to do this with vbscript? I've search quite a few places and
can find a lot of LDAP examples to get user info, but none on how to get the
users OU.

Kind regards,
jtvbs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top