Just putting this here for safekeeping since I couldn’t remember the exact syntax.
[evan@ehoffman 10:35:50 ~]$ ldapsearch -x -LLL -D "firstname.lastname@example.org" -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: Evan.Hoffman@example.com
Connect to activedirectory.example.com using ldaps (SSL) with simple authentication, binding as email@example.com 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.
4 Replies to “ldapsearch example on Active Directory”
Thanks for saving me from re-inventing the wheel.
There is no greater compliment.
Yes. This was precisely what I needed. Thank you very much.