This example describes how to create a mapping file, and use dsimport to perform a bulk load of information stored in a text file.
The file containing the information to import into the LDAP directory could be an extract from a corporate online directory service that provides basic information about employees.
This file is shown in Example 5-1.
Rob Green, rgreen@london.XYZ.com, phone x 44 1234, marketing communications manager Jean White, jwhite@london.XYZ.com, phone x44 1123, documentation manager Susan Brown, sbrown@london, phone (44) 123 45 67 00, technical writer Karen Gray, kgray@london, tel (44) 123 45 67 01, engineering project manager Steve Black, sblack@eng, x44 1122, software development engineer Felipe Diaz Gonzalez, fdgonzalez@eng, x41 2233, software development engineer Anne Marie de la Victoire, amvictoire@paris.xyz.com, x33 3344, software support engineer DURAND Pierre, pdurand@paris, tel 33 1133, software support engineer |
In this file, there is one employee definition per line. On each line the information is ordered as follows:
Name
E-mail address
Telephone number
Job description
The level of information is not always consistent for the various employees: the e-mail address is not always fully qualified, the telephone number is not always a complete telephone number but an extension, and in one case the last name is given before the first name.
If you want a consistent level of information for the entries that will be created in the LDAP directory, you must either make the necessary corrections in the source file, or make them after the import operation using the Deja tool.
The intention of the directory administrator is to create all employee entries under the naming context ou=People, o=XYZ, c=US. The token that specifies this in the mapping file is the BASE_DN token in the Common section.
The information will be imported just once. Therefore, it is not necessary to define an Export section in the mapping file. The Dynamic section is mandatory. The object class definition in the Condense section is also mandatory.
The mapping file created by the directory administrator is shown in Table 5-2.
Table 5-2 Example of Mapping File
The Condense section contains the inheritance tree for the inetOrgPerson object class.
The Build section contains all the mandatory attributes pertaining to or inherited by the inetOrgPerson object class. It also contains the optional attributes pertaining to this object class that the directory administrator required.
To import the file described in "Input File" sing the mapping file described in "Mapping File", you can use dsimport with the following arguments:
# dsimport -h hostname -D cn=admin,o=xyz,c=us -w secret -m mapping.file -f EXAMPLE -t People input.file |
where:
hostname is the name of the host that holds the directory data store
cn=admin,o=xyz,c=us is by default the distinguished name of the directory administrator
secret represents the password of the directory administarator
mapping.file contains the mapping for the input information
EXAMPLE is the front-end specified in the mapping file
People is the table specified in the mapping file
input.file contains the input information
It is not strictly necessary to specify the DN and password of the administrator on the command line. If you omit these parameters, dsimport will read them from the dsserv.conf file. The advantage is that the DN and password of the administrator will not be displayed by the ps command.
After running this command, the following message is displayed:
Lines read: 9, processed: 8 Entries: added 10, modified 0, deleted 0, errors 0 |
The line count includes blank lines. The number of entries created is greater than the number of lines in the file because the dsimport command automatically creates the root entry, in this example o=xyz, c=US.