LDAP Cheat Sheet

Basic Commands

CommandDescription
ldapsearch -xSearch the LDAP directory using simple authentication
ldapadd -x -D "cn=admin,dc=example,dc=com" -w <password> -f <ldif_file>Add an entry to the LDAP directory
ldapmodify -x -D "cn=admin,dc=example,dc=com" -w <password> -f <ldif_file>Modify an entry in the LDAP directory
ldapdelete -x -D "cn=admin,dc=example,dc=com" -w <password> <dn>Delete an entry from the LDAP directory
ldapwhoami -x -D "cn=admin,dc=example,dc=com" -w <password>Check the credentials of the current user

LDAP Operations

OperationDescription
BindAuthenticate the user and establish a session
SearchSearch the directory for entries matching specific criteria
AddAdd a new entry to the directory
ModifyModify an existing entry in the directory
DeleteDelete an entry from the directory

LDAP Filters

FilterDescription
objectClass=<class>Search for entries with a specific object class
cn=<name>Search for entries with a specific common name
uid=<name>Search for entries with a specific user ID
`((cn=John*)(cn=Mike*))`
(&(objectClass=person)(sn=Smith))Search for entries with the object class “person” and a surname of “Smith”

LDIF File Format

FormatDescription
dn: <dn>The distinguished name of the entry
changetype: <type>The type of change to be made (add, modify, or delete)
<attribute>: <value>The attribute and value to be added or modified

Leave a Reply

Proudly powered by WordPress | Theme: Code Blog by Crimson Themes.