The DirLoad driver is a source-only driver that generates eDirectory (or other LDAP directory) data from information and commands contained in a template file. DirLoad can generate random numeric values and insert string values from lists, enabling you to load eDirectory with large amounts of generated data for testing or other purposes. The DirLoad driver can also modify existing attributes and attribute values.
To use the DirLoad driver, run the following from the command line:
ice -SLOAD -f<template file> -D<destination driver>
Other DirLoad command line options are described in LOAD Source Options, and additional control options are specified within the Template File.
The DirLoad driver can send output to an LDAP server, an LDIF file, or a comma-delimited file using the ICE destination drivers. For more information on ICE destination handlers, see Section 1.4, Destination Handler Options.
The main component of the DirLoad driver is the template file, which is described in the following section.
The template file contains the object, attributes, commands, and control settings for the DirLoad driver. The components of the template file are described in the following three sections:
HINT:As a reference while reading this section, you may wish to open the sample template file, named attrs, contained in the cldapsdk\tools\win32 folder. This file is also included in Sample Template.
The object class and attributes define the characteristics of the object you wish to add. Within the template file, the object class is specified in the following format:
objectclass: <classname>
The template file must have an objectclass statement, and only one object class can be defined in a template file. Following the objectclass statement, all mandatory attributes and any optional attributes must be specified in the following format:
<attributename>:<attributevalue>
For example, the following template would add an inetorgperson named Bob Smith to the ou=development,o=acme container, with the telephone number 1-888-555-1212:
objectclass: inetorgperson dn: cn=bsmith,ou=development,o=acme sn: Smith givenname: Bob telephone number: 1-888-555-1212
Multiple attribute values are added by listing each attribute type and value on separate lines in the template file. For example, the following template adds three values to the cn attribute:
cn: Robert cn: Bob cn: Bobbie
Using the LDAP attribute name, any LDAP attribute can be added using this format. If you are unsure of an LDAP name, consult the LDAP class and attribute mappings on the LDAP Group object for your tree in ConsoleOne.
Commands can be used in place of the attribute value to generate random numbers and insert random strings.
The power of the DirLoad driver lies within its commands. Commands are used within attribute values to insert:
Unique numeric values
Random numeric values
Random string values from a list
Previously defined attribute values
This command inserts a numeric value that is unique for a given object into an attribute value. The syntax is as follows:
$C[(<format>)]
The optional <format> specifies a printf formatting to apply to the value. To use the default format, "%d", no format is specified and the parenthesis are not used. For information on printf formatting consult a C programming guide.
The starting numeric value is specified with the counter control setting (see Control Settings) and is incremented from that point. For example, if you specified:
!COUNTER=100100 workforceID: $C
The first object added has an employee ID of 100100, the second 100101, and so on.
This value is incremented after each added object. Therefore, if you use $C multiple times in your template, the value is the same within a single object. For example, if you specify:
!COUNTER=100 workforceID= $C jobCode= $C
The first object added has a workforceID of 100 as well as a jobCode of 100, the second object added has a workforceID of 101 as well as a jobCode of 101, and so on.
This command inserts a random numeric value from a specified range into an attribute value. The syntax is as follows:
$N(<low>-<high>[,<format>])
<low> and <high> specify the lower and upper bounds, respectively, that are used as a random number is generated. They are required.
The optional <format> specifies a printf formatting to apply to the value. To use the default format, "%d", no format is specified. For information on printf formatting consult a C programming guide.
This command inserts a randomly selected string from a specified list into an attribute value. The behavior of this command can be further controlled using the cycle and unicycle control settings (see Control Settings). The syntax is as follows:
$R(<filename>[,<format>])
The filename specifies a relative or absolute path to a file that contains a list of values, and is required. The values are separated by a newline character.
The optional <format> specifies a printf formatting to apply to the value. To use the default format, "%d", no format is specified and the parenthesis are not used. For information on printf formatting consult a C programming guide.
The following list files are included with this package in the cldapsdk\tools\win32 folder:
cities
company
domain
first
initial
last
titles
Using the strings contained in these files with this command you can generate hundreds of thousands of unique objects.
This command inserts a previously defined attribute value into another attribute value. This command is useful to construct a dn or e-mail address from other attributes that are randomly generated. The syntax is as follows:
$A(<attributename>)
The attribute name specifies the name of the attribute whose value should be inserted, and is required.
In the following example, the dn is constructed using the first character of the givenname, the first character of the initial, and the entire surname. The e-mail address is constructed using the first character of the givenname, the entire surname, and a static string:
givenname: $R(first) initial: $R(initial) sn: $R(last) dn:cn=$A(givenname,%.1s)$A(initial,%.1s)$A(sn),ou=ds,ou=dev,o=novell mail: $A(givenname,%.1s)$A(sn)@acme.com
Running the previous code in a template file might generate the following LDIF data:
dn:cn=JTSmith,ou=ds,ou=dev,o=novell objectclass: inetorgperson mail: JSmith@acme.com givenname: Jon initials: T sn: Smith
It is important to understand that no forward references are allowed. Any attribute whose value you wish to use for the value of another attribute must precede the current attribute in the template file. In the example below, the cn (contained as part of the dn) is constructed from givenname, initial, and sn, so each of these attributes must precede the dn in the template file.
givenname: $R(first) initial: $R(initial) sn: $R(last) dn:o=novell,ou=dev,ou=ds,cn=$A(givenname,%.1s)$A(initial,%.1s)$A(sn)
If the dn preceeds the givenname, initial, or sn, an "invalid attribute reference" error occurs.
NOTE:The dn receives special handling in the LDIF file. Regardless of the location of the dn in the template file, it is written first (as per LDIF syntax) to the LDIF file. All other attributes are written in the order in which they appear.
Table 1-11 Command Quick Reference
Control settings provide additional control during object creation. All controls have an exclamation point ’!’ as the first character on the line. The controls can be placed anywhere in the file.
This setting determines how many objects are created from the template. The syntax is as follows:
!OBJECTCOUNT=<value>
This setting provides the starting value for the unique counter command (see Commands). The syntax is as follows:
!COUNTER=<value>
The CYCLE setting is used to modify the behavior of the random string value from a list command (see Commands). This setting is used to cycle in the following two ways:
Cycle in Order
Cycle a Block
!CYCLE=<listname>
When the list specified by <list name> is used, the next value from the list is used rather than randomly selecting a value. Once all values have been consumed in order, the list repeats from the beginning.
!CYCLE=<listname>,BLOCK=<number>
Each value from the list specified by <list name> is to be used <number> times before moving to the next value.
For example, the following control uses each value from the list "ou" 10 times before moving to the next value:
!CYCLE=ou,BLOCK=10
This control specifies a list of sources that are cycled through, from left to right, enabling you to create guaranteed unique values.
If this control is used, the object count control is used only to limit the number of objects to the maximum number of unique objects that can be created from the lists. In other words, if the lists that are defined by unicycle can produce 15,000 objects, then object count can be used to reduce that number, but not to increase it.
For example, you have a list file called "givenname" which contains the following two values:
Doug Carl
You also have a list file called "sn" which contains the following three values:
Hoffman Schultz Grieger
If you add the following control setting:
!UNICYCLE=givenname,sn
Then add the following attribute definition:
cn: $R(givenname) $R(sn)
the following six common names are created:
cn: Doug Hoffman cn: Karl Hoffman cn: Doug Schultz cn: Karl Schultz cn: Doug Grieger cn: Karl Grieger
The object count control can be used in conjunction with the previous control setting to limit the number of objects created to less than six, but not more than six objects are created regardless of the value of object count.
Table 1-12 Control Settings Quick Reference
In addition to adding objects, the DirLoad driver can modify objects by deleting, adding, and replacing attributes or their values. To specify a modify, include the -m option on the command line:
ice -SLOAD -m -f<template file> -D<destination driver>
When making a modification, the first line of your template file is the dn of the object to be modified.
This command deletes an attribute and its attribute value. The syntax is as follows:
delete: <attributename>
NOTE:Mandatory attributes cannot be deleted, however, you can use the replace command to edit the value of a mandatory attribute.
For example, the following template deletes the otherPhoneNumber attribute from the user Gillespie Zammitti:
dn: cn=gzammitti,ou=development,o=acme delete: otherPhoneNumber
This command adds an attribute and an attribute value. The syntax is as follows:
add: <attributename> <attributename>: <attributevalue>
For example, the following template adds a personalTitle to the user Gillespie Zammitti:
dn: cn=gzammitti,ou=development,o=acme add: personalTitle personalTitle: Best Programmer in the World
This command replaces an attribute value with a new value. The syntax is as follows:
replace: <attributename> <attributename>: <attributevalue>
For example, the following template changes the personalTitle of the user Gillespie Zammitti:
dn: cn=gzammitti,ou=development,o=acme replace: personalTitle personalTitle: Best Exaggerator in the World
Multi-valued attributes can be added with the replace command.
This command replaces all values of an attribute with the values specified in your template. If you wish to keep one or more of the current attribute values use the add command instead.
This section demonstrates the main functionality of the DirLoad driver, and demonstrates using the DirLoad driver with various destination drivers.
These samples use the sample template file, attrs, contained in the cldapsdk\tools\win32 folder). This template file is as follows:
#====================================================================== # DirLoad 1.00 #====================================================================== !COUNTER=300 !OBJECTCOUNT=2 #---------------------------------------------------------------------- # ATTRIBUTE TEMPLATE #---------------------------------------------------------------------- objectclass: inetorgperson givenname: $R(first) initials: $R(initial) sn: $R(last) dn: cn=$A(givenname,%.1s)$A(initial,%.1s)$A(sn),ou=$R(ou),ou=dev,o=novell, telephonenumber: 1-800-$N(1-999,%03d)-$C(%04d) title: $R(titles)
Given the previous template file, running the following command produces the LDIF file displayed below.
ice -SLOAD -fattrs -DLDIF -fnew.ldf
version: 1 dn:cn=JTSmith,ou=ds,ou=dev,o=novell changetype: add objectclass: inetorgperson givenname: Jon initials: T sn: Smith telephonenumber: 1-800-290-0300 title: engineer dn:cn=TTSmith,ou=ds,ou=dev,o=novell changetype: add objectclass: inetorgperson givenname: Timo initials: T sn: Smith telephonenumber: 1-800-486-0301 title: manager
Running the following command sends the data to an LDAP server:
ice -SLOAD -fattrs -DLDAP -swww.acme.com -dcn=admin,o=acme -wpassword
The following sample demonstrates a modify command. If the template file is as follows:
#====================================================================== # DirLoad 1.00 #====================================================================== !COUNTER=300 !OBJECTCOUNT=1 #---------------------------------------------------------------------- # ATTRIBUTE TEMPLATE #---------------------------------------------------------------------- dn: cn=gzammitti,ou=development,o=acme add: givenname givenname: test1 delete: mail replace: givenname givenname: test2 givenname: test3
Running the following command produces the LDIF file displayed below:
ice -SLOAD -fattrs -m -DLDIF -fnew.ldf
version: 1 dn: cn=gzammitti,ou=development,o=acme changetype: modify delete: mail - add: givenname givenname: test1 - replace: givenname givenname: test2 givenname: test3