Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

Assuming:
All my users are connected to a server called "engineering.software.companyX.com".
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
1  
Is your AD domain "engineering.software.companyX.com"? –  jscott Feb 10 '12 at 19:38
    
That is correct –  Cocoa Dev Feb 10 '12 at 19:57

1 Answer 1

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"
  CN=myComputer,CN=Computers,DC=engineering,DC=software,DC=companyX,DC=com

You can also query users by their logon name:

dsquery user -samid "Administrator"
  "CN=Administrator,CN=Users,DC=engineering,DC=software,DC=companyX,DC=com

Edit:

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

ldap://DC=engineering,DC=software,DC=companyX,DC=com

share|improve this answer

Your Answer

 
discard

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.