OpenDJ: Adding your data, part III

OpenDJ logo In Adding your data, part I, I explained what needs to be done to add data to your directory, and how directory data is arranged. In Adding your data, part II, I demonstrated how to add data through the Control Panel. This entry shows how to do the same on the command line.

In this case, the data is for myOrg, which is just as small as myCompany.

dn: o=myOrg
objectClass: organization
objectClass: top
o: myOrg
aci: (target ="ldap:///o=myOrg")(targetattr !=
 "userPassword")(version 3.0;acl "Anonymous read-search access";
 allow (read, search, compare)(userdn = "ldap:///anyone");)

dn: ou=People,o=myOrg
objectClass: organizationalunit
objectClass: top
ou: People

dn: uid=mark,ou=People,o=myOrg
objectClass: person
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: top
uid: mark
userpassword: secret12
facsimiletelephonenumber: +1 408 555 1211
givenname: Mark
cn: Mark Craig
telephonenumber: +1 408 555 1212
sn: Craig
roomnumber: 0001
mail: mark@example.org
l: Barraux
ou: People
  1. Save the data in myOrg.ldif, being careful not to add spaces at the end of lines and to keep a blank line at the end of the file.
  2. Create a backend to contain the data using the dsconfigcommand.
    $ ./OpenDJ/bin/dsconfig create-backend --backend-name \
    > myOrgRoot --set base-dn:o=myOrg --set enabled:true --type local-db
    
    >>>> Specify OpenDS LDAP connection parameters
    
    Directory server hostname or IP address [myiMac.local]: 
    
    Directory server administration port number [4444]: 
    
    Administrator user bind DN [cn=Directory Manager]: 
    
    Password for user 'cn=Directory Manager': 
    
    >>>> Configure the properties of the Local DB Backend
    
            Property           Value(s)
            ----------------------------
        1)  backend-id         myOrgRoot
        2)  base-dn            o=myOrg
        3)  compact-encoding   true
        4)  db-cache-percent   10
        5)  db-cache-size      0 b
        6)  db-directory       db
        7)  enabled            true
        8)  index-entry-limit  4000
        9)  writability-mode   enabled
    
        ?)  help
        f)  finish - create the new Local DB Backend
        q)  quit
    
    Enter choice [f]: f
    
    The Local DB Backend was created successfully

    You could also specify host, port, and bind information with --no-prompt to avoid the interactive version.

  3. Add the data to populate the new suffix.
    $ ./OpenDJ/bin/import-ldif -l /path/to/myOrg.ldif \
    > -n myOrgRoot -h localhost -p 4444 -D "cn=Directory Manager" -w ******** -t 0
    Import task 20110512151557719 scheduled to start May 12, 2011 3:15:57 PM CEST

    The command above used the import-ldif command with host, port, and bind information to schedule the task at a time zero seconds from now. If you have lots of data to import, you can also stop the server, import the LDIF, and then restart OpenDJ.

You can now check that the data imported successfully.

$ ./OpenDJ/bin/ldapsearch -p 1389 -b o=myOrg mail=\*
dn: uid=mark,ou=People,o=myOrg
givenName: Mark
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: top
uid: mark
cn: Mark Craig
telephoneNumber: +1 408 555 1212
sn: Craig
roomNumber: 0001
mail: mark@example.org
l: Barraux
ou: People
facsimileTelephoneNumber: +1 408 555 1211

If your data use custom object classes and attribute types, there’s a procedure prior to the rest of this, in which you extend your directory schema. But that’s something for a later post.

Advertisements

Leave a comment

Filed under Directory Services and LDAP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s