misc_scripts/ldap_basic
2024-10-26 16:46:24 +05:30
..
ldapadd.sh commit 2024-10-26 16:42:22 +05:30
ldapmodify.sh commit 2024-10-26 16:42:22 +05:30
ldapsearch.sh commit 2024-10-26 16:42:22 +05:30
README.md commit 2024-10-26 16:46:24 +05:30

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 directory
  • ldapadd: Add entries to the directory
  • ldapmodify: Modify entries in the directory
  • ldapvi: 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 the ldif 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