1.4 KiB
1.4 KiB
Basic LDAP operations
These scripts act as shortcuts for frequently used openldap
commands or operations.
Common openldap commands and options
It is necessary to understand these basic commands
ldapsearch
: Search for entries in the directoryldapadd
: Add entries to the directoryldapmodify
: Modify entries in the directoryldapvi
: A program to edit enties using your text-editor
You will have to modify these fields in the scripts:
-H
: Host ip-address or url:ldap://192.12.34.123/
,ldaps://ldap.example.com/
-D
: Bind DN:cn=ldapadmin,dc=example,dc=com
-w
: Bind password:-wS3cretP4$$w0rd
or-w S3cretP4$$w0rd
-b
: Search base:dc=example,dc=com
-f
: File: The.ldif
file with theldif
data to add or modify an entry
Usage examples:
ldapsearch -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://ldap.example.com/ -b dc=example,dc=com uid=tomsawyer
ldapadd -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://192.12.34.123/ -f testuser.ldif
Script usage
ldapsearch.sh: Search entry by any attribute
bash ldapsearch.sh uid=tomsawyer
ldapadd.sh: Add entries from ldif file
bash ldapadd.sh filename.ldif
ldapmodify.sh: Modify entries with info from ldif file
bash ldapmodify.sh filename.ldif