Symas OpenLDAP Knowledge Base

Using ldapdelete

ldapdelete

ldapdelete Man Page

Syntax: ldapdelete <opts> [-f <file.ldif>] [DN]

  • The ldapdelete command removes an entry from a directory. If the entry being deleted has child entries, the ldap server will refuse to delete the entry unless the recursive delete option (-r)

  • Use caution with the -r option, as it does not prompt for confirmation!

ldapdelete Options Description
-c Continue delete operations even if there’s an error
-f <filename> Use the given file to delete multiple entries
-r Recursive delete. Deletes all child entries

ldapdelete Examples

# Delete a single entry
ldapdelete <opts> "cn=Par Chong,ou=Accounting,dc=example,dc=com"

# Recursively delete an entry and its children
ldapdelete <opts> -r ou=Planning,dc=example,dc=com

# Delete multiple entries by reading from a file named dn-list.txt
#   containing the following DNs (without the "dn:"" prefix seen 
#   in normal LDIF files):
#     cn=Muriel Oka,ou=Accounting,dc=example,dc=com
#     cn=Zyg Chawla,ou=Accounting,dc=example,dc=com
#     cn=Biddie Auld,ou=Accounting,dc=example,dc=com
#     cn=Byron Evers,ou=Accounting,dc=example,dc=com
ldapdelete <opts> -f dn-list.txt

The command is used to addd entries to a directory.

Syntax: ldapadd <opts> -f <file.ldif>

  • The ldapadd command is used to add new entries to a directory using plain LDIF data (not a change-type LDIF)
  • One or more entries may be added in the LDIF file being used. To add multiple entries, simply place an empty line between entries.
  • Example: An LDIF file that will add two new OU entries to the example database.
dn: ou=assets,dc=example,dc=com
objectClass: top
objectClass: organizationalUnit
ou: assets
description: Organizational Unit for storing asset data

dn: ou=policies,dc=example,dc=com
objectClass: top
objectClass: organizationalUnit
ou: policies
description: Organizational Unit for storing password policies

ldapadd Examples

Example, use a simple bind to authenticate to the server and verbose output when running the ldapadd command:

ldapadd -x -D dc=example,dc=com -w secret -H "ldap:///" -f add-OUs.ldif -v

If the add is successful, you’ll see the following verbose output:

add objectClass:
    top
    organizationalUnit
add ou:
    assets
add description:
    Organizational Unit for storing asset data
adding new entry "ou=assets,dc=example,dc=com"
modify complete
...