The information contained in a data file is a list of values. To give meanings to these values, you must specify what the values in each field represent. To do this, define an LDIF template (LDT) file.
The LDT files describe the objects contained in the directory. The LDT file follows the LDIF file format, which is used to add directory information to the data values. An LDIF file consists of a series of records separated by blank lines. A record consists of a sequence of lines describing a directory entry. Special substitution tokens are used to place fields from the CSV file into the LDT.
Each line in the LDT file defines a rule that links a field in a CSV data file to a directory attribute or name with an object description. These rules let the tools translate CSV file information into LDIF file formats.
Each record in an LDT file specifies the format of entries at that level. Each record contains a DN and one or more attribute-value template lines.
use the $ character to denote a column in the source csv file. For example $2 gets replaced with the contents of the entry in second column in the csv file. If the escape character (\) precedes the $ character the the $ symbol is interpreted literally. Use \\ to represent the \ character.
Using substitution tokens in the DN line lets you specify leaf nodes and their parents. You can therefore infer hierarchy from the original CSV data. You must explicitly code parent objects in the template file, and they must appear in increasing-depth order in the file before any definition of leaf objects.
To specify a literal number following immediately after a substitution token, use the three-digit form of the token as in the following example:
...
Description: $00199 \$ $2 \$ $3 ...
When this LDT file is interpreted, the csv2ldif program looks at the first three digits after the $ for the column number. In this example, it interprets $00199 to mean find the $001 column of the CSV to substitute, that is column one, and append the characters "99" to it. If you use $199 it substitutes the value from the 199th column of the CSV.
# Acme template file - LDIF format # telephonenumber is a multivalued attribute dn:ou=$4, o="Acme", c=US oc:organizationalUnit dn:cn=$1 $2, ou=$4, o="Acme", c=US oc:organizationalPerson surname:$2 title:$3 telephonenumber:+61 3 $5 telephonenumber:+61 3 $6
Copyright © 2011 CA. All rights reserved. | Email CA Technologies about this topic |