Pages

Sunday, January 31, 2010

Get Active Directory names via command line

Working on domain member server without any AD tools available, I needed to confirm the display name of an AD user. I was only supplied the logon user name. A common example might be Joe Smith being the display name and the logon / SAM user name being jsmith.

The commands involved are dsquery and dsget, both quite powerful.

Given the AD logon username is webmaxtor in the MAXTOR.LOCAL domain, the associated request and result returning the display name might be:

H:\>dsquery user dc=MAXTOR,dc=LOCAL -name web* | dsget user -display
display
Web Administrator
Web Maxtor
dsget succeeded


Since two names appear on the list, we know two users are returned and can see the logon / SAM names via:

H:\>dsquery user dc=MAXTOR,dc=LOCAL -name web* | dsget user -samid
samid
IISadmin
webmaxtor
dsget succeeded


Running the dsquery command without the piped dsget can also return all sorts of useful information all by itself.

No comments:

Post a Comment