How can I determine my user account's OU in a Windows domain?

Solution 1:

gpresult /r | find "OU"

will do it.

Solution 2:

In Command Prompt,

whoami /fqdn

Solution 3:

Here's a quick VBS script you can use to display your account's DistinguishedName attribute which contains the OU that your account is in:

set objSysInfo = CreateObject("ADSystemInfo")
set objUser = GetObject("LDAP://" & objSysInfo.UserName)
wscript.echo "DN: " & objUser.distinguishedName

EDIT: I should say that it will display the DN of the account in which context the script is run...


Solution 4:

I've found that

gpresult -v|more 

also works for this.


Solution 5:

User: adfind -sc u:%username% dn

Computer: adfind -sc c:%computername% dn

Adfind available at http://www.joeware.net/freetools/tools/adfind/index.htm