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?

link|improve this question

20% accept rate
By "LDAP name", do you mean the distinguishedName of the object? – jscott Feb 10 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 at 19:32
1  
Is your AD domain "engineering.software.companyX.com"? – jscott Feb 10 at 19:38
That is correct – Cocoa Dev Feb 10 at 19:57
feedback

1 Answer

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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