# Basic LDAP operations These scripts act as shortcuts for frequently used `openldap` commands or operations. ## Example commands It is necessary to understand these basic commands - `ldapsearch`: Search for entries in the directory - `ldapadd`: Add entries to the directory - `ldapmodify`: Modify entries in the directory - `ldapvi`: A program to edit enties using your text-editor ## Common options 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 the `ldif` data to add or modify an entry Usage examples: ```bash ldapsearch -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://ldap.example.com/ -b dc=example,dc=com uid=tomsawyer ``` ```bash ldapadd -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://192.12.34.123/ -f testuser.ldif ``` ## Script usage [ldapsearch.sh](ldapsearch.sh): Search entry by any attribute ```bash bash ldapsearch.sh uid=tomsawyer ``` [ldapadd.sh](ldapadd.sh): Add entries from ldif file ```bash bash ldapadd.sh filename.ldif ``` [ldapmodify.sh](ldapmodify.sh): Modify entries with info from ldif file ```bash bash ldapmodify.sh filename.ldif ```