Symas OpenLDAP Knowledge Base

Using ldapadd

ldapadd

ldapadd Man Page

The ldapadd 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
...