ldap Commands

Modify Operations

ldapadd

Add entries to an LDAP directory.

ldapadd

Examples:
Add entry from LDIF file
ldapadd -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -w password -f entry.ldif
Add entry from stdin
echo "dn: uid=john,ou=people,dc=example,dc=com\nobjectClass: person\nuid: john\ncn: John Doe" | ldapadd -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -w password
ldapmodify

Modify entries in an LDAP directory.

ldapmodify

Examples:
Modify entry from LDIF file
ldapmodify -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -w password -f changes.ldif
ldapdelete

Delete entries from an LDAP directory.

ldapdelete

Examples:
Delete entry
ldapdelete -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -w password "uid=john,ou=people,dc=example,dc=com"
Recursive delete
ldapdelete -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -w password -r "ou=people,dc=example,dc=com"
ldapmodrdn

Modify the RDN of an LDAP entry.

ldapmodrdn

Examples:
Modify RDN
ldapmodrdn -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -w password "uid=john,ou=people,dc=example,dc=com" -n "uid=jane" -r

Authentication

ldapwhoami

Perform a whoami operation against an LDAP server.

ldapwhoami

Examples:
Check current identity
ldapwhoami -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -w password

Password Management

ldappasswd

Change the password of an LDAP user.

ldappasswd

Examples:
Change password
ldappasswd -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -w password "uid=john,ou=people,dc=example,dc=com" -s newpassword

Backup/restore

slapcat

Export LDAP database to LDIF format.

slapcat

Examples:
Export database
slapcat -l backup.ldif
Export specific database
slapcat -n 2 -l backup.ldif
slapadd

Add entries from LDIF file to LDAP database.

slapadd

Examples:
Import from LDIF
slapadd -l backup.ldif
Import to specific database
slapadd -n 2 -l backup.ldif

Utilities

ldapurl

Parse and format LDAP URLs.

ldapurl

Examples:
Parse LDAP URL
ldapurl "ldap://localhost:389/dc=example,dc=com?cn,sn?sub?(objectClass=person)"