Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to create a script that can query users on Active Directory.

All my users are connected to a server called "".
All our PC's have domain accounts to the name above.

What LDAP URI do I use?

share|improve this question
By "LDAP name", do you mean the distinguishedName of the object? – jscott Feb 10 '12 at 19:27
when I get a new PC. We join it to the domain. When we get new employees, we add them to active directory. Active Directory knows when the users password will expire, etc. I want to connect to AD but I need to use some LDAP:// format and I don't know what it should be – Cocoa Dev Feb 10 '12 at 19:32
Is your AD domain ""? – jscott Feb 10 '12 at 19:38
That is correct – Cocoa Dev Feb 10 '12 at 19:57
up vote 7 down vote accepted

You may use dsquery to query the AD domain. To get the distinguishedName of the computer myComputer:

dsquery computer -name "myComputer"

You can also query users by their logon name:

dsquery user -samid "Administrator"


I see from the edits you just want the LDAP connection string/URI. Try this:


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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