Sun ONE Directory Server Resource Kit 5.2 Tools Reference |
Chapter 18
The Standard Schema LDIF Generator ToolThe dbgen.pl tool generates a sample database containing entries with random values. The entries can then be loaded into a directory server and used to run performance tests. This chapter provides instructions on how to use the script. It contains the following sections:
OverviewThe dbgen.pl (database generator) tool is a Perl script that generates a database containing entries with random attribute values. The output is an LDAP Data Interchange Format (LDIF) text file which can be loaded into a directory server and used to run performance tests. Generated entries follow the standard schema to provide more realistic output.
Note
The ldifgen tool, detailed in Chapter 19, "The Custom Schema LDIF Generator Tool," generates entries using a custom schema. For this reasons, dbgen.pl is the recommended tool for random database creation.
The DSRK includes the tool in the DSRK_base/perl directory.
Note
This script requires Perl version 5.005_03 or later. See Third-Party Sources of Information for links to Perl resources.
Accompanying Data Files
The script relies on the following files in the DSRK_base/data directory:
- dbgen-OrgUnits contains the names for five organizational units (Accounting, Product Development, Product Testing, Human Resources, and Payroll). One entry for each organizational unit (ou) will be created under the suffix root of the generated directory. Then, each person entry will be randomly placed in one of the organizational units. Figure 18-1 shows the directory tree representing the LDIF entries of these organizational units.
Figure 18-1 LDAP Directory Tree Generated by dbgen.pl
- dbgen-GivenNames and dbgen-FamilyNames contain over 8600 plausible first names and 13400 plausible last names, respectively. Each entry representing a person is based on a given name and surname, each randomly chosen from these files. A sequential integer is also appended to all names to ensure that no two entries and no two DNs are identical.
Some attribute values such as email addresses are derived from the name and the suffix to create a plausible entry. Other data such as telephone numbers or titles are generated randomly or selected randomly from internal lists. These types of attribute values are not configurable.
Note
You may edit the contents of these data files to modify the output of the dbgen.pl tool. (You will need root privileges to edit these files on UNIX®-based systems.)
Customizing the Script
If you customize the dbgen.pl script for added functionality, we encourage you to share your work with other LDAP users. Please post a message to the iplanet.server.idsrk public newsgroup with your ideas or your code.
Command UsageThe dbgen.pl tool generates a directory hierarchy that mimics a simple corporate structure. The script has an option for specifying a suffix, which will be the root of the generated hierarchy. (By default it is dc=siroe,dc=com..) All of the leaf entries are inetOrgPerson objects by default, or you may specify the -O (the capital letter O) option to create all OrganizationalPerson objects. The tool generates random values for either object class’s allowed attributes. (See the Sample Output for examples of both object classes and the generated attribute values.)
The tool also generates the root and ou entries so that its output is a complete and valid LDAP directory hierarchy expressed in LDIF text. The ou entries do not contain any attributes and are always the same. The root entry contains only simple aci (Access Control Instructions) attributes that are also invariant.
Syntax
The syntax of the dbgen.pl tool on the command-line takes the following form:
dbgen.pl -o filename.ldif -n number [options]
Where:
- filename.ldif is a writable file that will contain the LDIF output.
- number is the number of leaf entries that will be generated, in addition to the parent entries that are always present.
Options
The dbgen.pl options and parameters are described in Table 18-1. Running the dbgen.pl script from the command-line without any options or parameters will display the usage help text that briefly describes all options.
Sample OutputThe examples in this section show the output of the dbgen.pl tool. These examples use the default data files found in the DSRK_base/data directory. To save space, only the first full leaf entry is shown in each case.
InetOrgPerson Entries
This example demonstrates how the dbgen.pl script generates random attribute values for entries of the inetOrgPerson object class. It uses the date command of the UNIX® shell to generate a seed for the random number generator. It also demonstrates the verbose output that includes progress messages.
OrganizationalPerson Entries
In this example we use the -O (capital letter O) option to generate entries of the organizationalPerson object class. We also use the -c and -s options to customize the DN of the generated entries.
Code Example 18-2 OrganizationalPerson Generated Entry
$ perl dbgen.pl -o out2.ldif -n 3 -O -r ‘date +%S‘ -q \
-c -s "o=Varrius Corp.,c=US"
$ cat out2.ldif
dn: o=Varrius Corp.,c=US
objectClass: top
objectClass: organization
o: Varrius Corp.
aci: (target=ldap:///o=Varrius Corp.,c=US)(targetattr=*)
(version 3.0; acl "acl1"; allow(write) userdn = "ldap:///self";)
aci: (target=ldap:///o=Varrius Corp.,c=US)(targetattr=*)
(version 3.0; acl "acl2"; allow(write) groupdn =
"ldap:///cn=Directory Administrators, o=Varrius Corp.,c=US";)
aci: (target=ldap:///o=Varrius Corp.,c=US)(targetattr=*)
(version 3.0; acl "acl3"; allow(read, search, compare) userdn =
"ldap:///anyone";)
dn: ou=Accounting, o=Varrius Corp.,c=US
objectClass: top
objectClass: organizationalUnit
ou: Accounting
dn: ou=Product Development, o=Varrius Corp.,c=US
objectClass: top
objectClass: organizationalUnit
ou: Product Development
dn: ou=Product Testing, o=Varrius Corp.,c=US
objectClass: top
objectClass: organizationalUnit
ou: Product Testing
dn: ou=Human Resources, o=Varrius Corp.,c=US
objectClass: top
objectClass: organizationalUnit
ou: Human Resources
dn: ou=Payroll, o=Varrius Corp.,c=US
objectClass: top
objectClass: organizationalUnit
ou: Payroll
dn: cn=Mihaela Inman, ou=Accounting, o=Varrius Corp.,c=US
objectClass: top
objectClass: person
objectClass: organizationalPerson
cn: Mihaela Inman
sn: Inman
uid: MInman0
givenName: Mihaela
description: This is Mihaela Inman’s description
userPassword: MInman0
telephoneNumber: +1 714 803-8455
facsimileTelephoneNumber: +1 714 371-9310
l: Santa Clara
ou: Accounting
mail: Mihaela_Inman@siroe.com
postalAddress: Accounting Dept #339, Room#98
title: Chief Accounting Director
dn: cn=Randall Braddy,ou=Human Resources,o=Varrius Corp.,c=US
[...]
dn: cn=Morley Cantwell,ou=Product Development,o=Varrius Corp.,c=US
[...]