35

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

Luke
  • 2,103
  • 7
  • 27
  • 30

7 Answers7

57

gpresult /r | find "OU"

will do it.

MathewC
  • 6,957
  • 9
  • 39
  • 53
35

In Command Prompt,

whoami /fqdn
cychoi
  • 580
  • 1
  • 5
  • 12
16

UPDATE
You should now use this answer on any kind of modern version of Windows


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

squillman
  • 37,883
  • 12
  • 92
  • 146
8

I've found that

gpresult -v|more 

also works for this.

Flup
  • 7,978
  • 2
  • 32
  • 43
JJJJNR
  • 870
  • 6
  • 20
  • 32
3

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
Kevin
  • 213
  • 2
  • 8
2

User: adfind -sc u:%username% dn

Computer: adfind -sc c:%computername% dn

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

benPearce
  • 321
  • 5
  • 11
1

At a command / powershell prompt:

dsquery user -name <your-user-name>
thetoolman
  • 121
  • 2