LDIF examples

Archived

This page has been archived and will receive no further updates.

Add these using slapadd (if slapd is stopped) or ldapadd (if slapd is running)

See OpenLDAP notes

Add an attribute

dn: uid=myaccount,ou=accounts,dc=example,dc=com
changetype: modify
add: cn
cn: My Account

Modify an attribute

dn: uid=myaccount,ou=accounts,dc=example,dc=com
changetype: modify
replace: cn
cn: Your Account

Delete an attribute

dn: uid=myaccount,ou=accounts,dc=example,dc=com
changetype: modify
delete: cn
cn: Your Account

Make multiple modifications to attributes

Use a dash:

dn: uid=myaccount,ou=accounts,dc=example,dc=com
changetype: modify
add: description:
description: this is your account
-
replace: cn
cn: Your Account

Modify multiple entries

Use a dash and a blank line:

dn: uid=myaccount,ou=accounts,dc=example,dc=com
changetype: modify
add: description:
description: this is my account
-
replace: homeDirectory
homeDirectory: /bin/bash
-

dn: uid=youraccount,ou=accounts,dc=example,dc=com
changetype: modify
add: description:
description: this is your account

Delete an entry

dn: uid=myoldaccount,ou=accounts,dc=example,dc=com
changetype: delete

Create the base for a directory

# Organization for Example Corporation
dn: dc=example,dc=com
objectClass: dcObject
objectClass: organization
dc: example
o: Example Corporation
description: The Example Corporation

# Organizational Role for Directory Manager
dn: cn=Manager,dc=example,dc=com
objectClass: organizationalRole
cn: Manager
description: Directory Manager

Create a simple account for testing

  1. First, generate an encrypted password using slappasswd (see OpenLDAP notes)

  2. Add the LDIF
     dn: cn=ldaptest,dc=example,dc=com
     objectClass: organizationalRole
     cn: ldaptest
     objectClass: simpleSecurityObject
     userPassword: (generated by slappasswd)
    
  3. Add it to the ACL