ldapsearch example on Active Directory
Just putting this here for safekeeping since I couldn’t remember the exact syntax.
[evan@ehoffman 10:35:50 ~]$ ldapsearch -x -LLL -D "[email protected]" -w password -b "OU=Users,DC=example,DC=com" -s sub -H ldaps://activedirectory.example.com "(sn=hoffman)" cn mail displayName samaccountname
dn: CN=Evan Hoffman,OU=Tech,OU=Users,DC=example,DC=com
cn: Evan Hoffman
displayName: Evan D. Hoffman
sAMAccountName: ehoffman
mail: [email protected]
Explanation: Connect to activedirectory.example.com using ldaps (SSL) with simple authentication, binding as [email protected] with password password; search for (sn=hoffman) within the OU=Users,DC=example,DC=com search base (branch), and search the subtree. Return the cn, displayName, and samaccountname fields.
Refer to the ldapsearch man page for more options.