[problem]
You want to perform an LDAP search
[/problem]
[solution]
Starting this topic slowly, by giving practical tips on LDAP commands.
Predominately LDAP has a couple of main commands: ldapsearch and ldapmodify. With openLDAP there is additionally ldapadd, with netscape this is just ldapmodify -a.
[/solution]
[example]
ldapsearch [ -v ] -x -D'user' -w'password'
[ -h host -p port ] -b base
-s depth 'criteria' [ attribs ]
User – ldap user, quite often directory manager, so usually you can get away with cn=Manager,your_tree.
Password – is LDAP password for user. If using the manager, password configured in the LDAP configs. If not user password it is set within LDAP itself.
Host and port – self-explanatory (default localhost on port 389).
Base – starting point within LDAP tree. Remember LDAP is hierarchal, so search will traverse down from this point.
Depth – can just be base (only show the the base level, do not transcend the tree) – specify sub to transcend.
Criteria – requirements for fields equaling a specific value, more on this shortly.
Attribs – fields to return, the dn is normally returned by default.
Demo:
ldapsearch -x -v -D'cn=Manager,dc=users,dc=net' -w secret -b'dc=users,dc=net' -s sub 'objectclass=*'
[/example]
[reference]
[tags]ldapsearch syntax, ldapsearch demo, LDAP Training School[/tags]
[/reference]
If you have found my website useful, please consider buying me a coffee below 😉