28

Is there any way (short of getting an active directory browser) to view my OU while logged in to the domain?

  • Are you a domain admin, or have access to the domain admin tools? – Matt Simmons Jun 9 '09 at 19:44
14

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...

  • You beat me to it by about 15 seconds! Zow... – Evan Anderson Jun 9 '09 at 19:48
  • I beat him but for some reason gpresult /r doesn't work for everyone. "snaps fingers in lost pointage regret" ;-) – MathewC Jun 9 '09 at 19:57
  • Aye, 'tis true :) +1 though, great command! – squillman Jun 9 '09 at 20:05
  • 1
    Not sure why this is the accepted answer when "whoami /fqdn" is far simpler? – RCross Feb 23 '18 at 10:42
45

gpresult /r | find "OU"

will do it.

  • Is this a windows command? Doesn't seem to work. – Luke Jun 9 '09 at 19:48
  • /r doesn't work for me, although you do get almost everything otherwise with gpresult. – Matt Hanson Jun 9 '09 at 19:48
  • When I do it there is a user setting section that shows the OU. – MathewC Jun 9 '09 at 19:53
  • 1
    Awesome command that I didn't know about. Thanks! +1 – Matt Simmons Jun 9 '09 at 19:54
  • /R Displays RSoP summary data. – MathewC Jun 9 '09 at 19:56
22

In Command Prompt,

whoami /fqdn
  • Works in the event gpresult yields ERROR: Access Denied. Thanks. – timss Dec 1 '17 at 11:10
  • +1 for what is by far the simplest solution to the original problem (and which perhaps should become the accepted answer). – RCross Feb 23 '18 at 10:43
5

I've found that

gpresult -v|more 

also works for this.

1

User: adfind -sc u:%username% dn

Computer: adfind -sc c:%computername% dn

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

  • adfind is one of my favorite AD tools. I <3 joeware. – JamesBarnett Dec 28 '10 at 8:54
0

I am able to run the following in a cmd window

gpresult /r | find "OU"

Example output:

USER SETTINGS
--------------
CN=Lastname\, Firstname,OU=Users,OU=Toronto,DC=site,DC=com

    Last time Group Policy was applied: 1/24/2019 at 4:04:04 PM
    Group Policy was applied from:      dc.site.com
    Group Policy slow link threshold:   500 kbps
    Domain Name:                        SITE
    Domain Type:                        Windows 2008 or later

It also lists the user groups you are a member of:

The user is a part of the following security groups
---------------------------------------------------
    Domain Users
    Everyone
    BUILTIN\Administrators
    BUILTIN\Users
    Performance Log Users
    NT AUTHORITY\INTERACTIVE
    CONSOLE LOGON
    NT AUTHORITY\Authenticated Users
    This Organization
    LOCAL
    custom_security_linux_group
0

At a command / powershell prompt:

dsquery user -name <your-user-name>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.