inserting the first object in your ldap directory


The first thing we have to add to our directory is the top level node. We create a "ldif" file that contains all information of the top level node. ldif stands for Lightweight Directory Interchange Format. The top level node will be of the type "organizationalUnit" and "dcObject". dc stands for "domain component". The ldif file looks like this:

topnode.ldif:
# top node
dn: dc=redflo,dc=de
dc: redflo
objectClass: dcObject
objectClass: organizationalUnit
ou: redflo.de domain


There are 2 different utilities to add data to your ldap directory: ldapadd and slapadd. ldapadd uses the ldap protocol to modifiy the directory, while slapadd directly modifies the ldap database. Therefore ldapadd can be used remote and all ldap access control is honoured while slapadd only works locally. Since we did not define authentication in ldap we use slapadd to add the first data:

slapadd -v -l topnode.ldif

restart your ldap server (needed if you use slapadd) with /etc/init.d/ldap restart (or similar on other distros) and check if all is there:

ldapsearch -x -b "dc=redflo,dc=de" "(objectClass=*)"
# extended LDIF
#
# LDAPv3
# base <dc=redflo,dc=de> with scope sub
# filter: (objectClass=*)
# requesting: ALL
#

# redflo.de
dn: dc=redflo,dc=de
dc: redflo
objectClass: dcObject
objectClass: organizationalUnit
ou: redflo.de domain

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1