26.7. OpenLDAP Creation and Maintenance Tools

To Create of the LDMB backend database, there are two methods to create a database for LDAP,

  1. The first is off-line with the ldif2ldbm command utility

  2. The other is on-line with the ldapadd command utility.

Usually you use the off-line method when you have many thousands of entries to insert into your database and the on-line method when you have only a small number of entries to put into your database. It is also important to note that

26.7.1. LDMB backend database off-line

The first thing to do is to create an LDIF input file containing a text representation of your entries. The text file named my-data-file below can be used as an example file. Of course, your real LDIF input file will handle much more information than this example. When you install OpenLDAP for the first time and have big entries to put in your backend database, it's always a good idea to put all this information into a text file and add them into your backend database with the ldif2ldbm command utility.

Example 26-1. my-data-file

Create the file, touch /tmp/my-data-file and add as an example in this file the following lines:

  1. 
                         dn: o=openna, c=com
                             o: openna
                             objectclass: organization
    
                             dn: cn=Gerhard Mourani, o=openna, c=com
                             cn: Gerhard Mourani
                             sn: Mourani
                             mail: gmourani@videotron.ca
                             title: Author
                             objectclass: person
    
                             dn: cn=Anthony Bay, o=openna, c=com
                             cn: Anthony Bay
                             sn: Bay
                             homephone: (444) 111-2233
                             mobile: (444) 555-6677
                             mail: abay@openna.com
                             objectclass: person
    
                             dn: cn=George Parker, o=openna, c=com
                             cn: George Parker
                             sn: Parker
                             telephonenumber: (555) 234-5678
                             fax: (543) 987-6543
                             mobile: (543) 321-4354
                             description: E-Commerce
                             objectclass: person
                           
    The above example shows you how to convert your information into LDIF files before adding them to your new backend directory. Consult your OpenLDAP documentation or book for more information.

  2. Once the LDIF input file containing our entries has been created, we must insert it in the LDAP directory server. To insert the LDIF input file and create the database off-line, use the following command:
    
                         [root@deep ]/tmp# ldif2ldbm -i <inputfile>  -f <slapdconfigfile>
                             [root@deep ]/tmp# ldif2ldbm -i my-data-file -f /etc/openldap/slapd.conf
                           
    The -i option with the <inputfile> option specifies the location of the LDIF input file containing the entries in text form to add. The <slapdconfigfile> option specifies the location of the slapd configuration file, which specifies where to create the indexes, what indexes to create, etc.

Important: It is important to note that the slapd daemon of LDAP is not started in this mode of creation.