Searching Active Directory with ldapsearch
Okay, so I decided to carry on through journey of integrating AD with Linux. When I got AD working after my last post, I added a user for the testing purposes. And I needed to start browsing AD from Linux, so I installed ldapscripts package which provides ldapsearch utility for searching into LDAP (in the end Active Directory is an LDAP-like directory service).
# apt-get install ldapscripts
And here’s the magic syntax,
# ldapsearch -x -LLL -E pr=200/noprompt -D "cn=Administrator,cn=Users,dc=win2k3,dc=example,dc=com" -W -H ldap://win2k3.example.com:389 -b "cn=users,dc=win2k3,dc=example,dc=com" -s sub "(cn=*)" cn mail sn
And the result was
dn: CN=Users,DC=win2k3,DC=example,DC=com
cn: Usersdn: CN=Administrator,CN=Users,DC=win2k3,DC=example,DC=com
cn: Administratordn: CN=Guest,CN=Users,DC=win2k3,DC=example,DC=com
cn: Guestoutput omitted
dn: CN=Ahmed O. Anwar,CN=Users,DC=win2k3,DC=example,DC=com
cn: Ahmed O. Anwar
sn: Anwar
mail: ahmed@example.com# pagedresultscookie=