Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

  • Print
  • + Share This
From the author of

Populating the LDAP Directory

To populate the LDAP directory, you must create a file that contains at least two entries: a top-level record and an administrative record. Listing 1 illustrates a simple example that conforms to our configuration.

dn: dc=localdomain,dc=mycompany,dc=org
objectclass: dcObject
objectclass: organization
o: Example company
dc: localdomain

dn: cn=admin,dc=localdomain,dc=mycompany,dc=org 
objectclass: organizationalRole 
cn: admin

Listing 1 An LDIF file

If you create this file on the Linux system, you can then load it into the directory by typing the following command:

ldapadd -x -D "cn=admin,dc=localdomain,dc=mycompany,dc=org" -W -f init.ldif

To verify that the directory now contains the above entries, try running a search:

ldapsearch –x –b 'dc=localdomain,dc=mycompany,dc=org' '(objectclass='*')'

The above command should return something like that illustrated in Figure 10.

Figure 10

Figure 10 A populated LDAP database

As you can see, Figure 10 indicates that our data now resides inside the directory. You've covered a lot of ground and your directory is now running and populated with a tiny amount of data. One next step would to create another .ldif file that contains more data to load into the directory.

  • + Share This
  • 🔖 Save To Your Account