OpenDJ: Adding your data, part II

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. I did not yet demonstrate how to add data.

Let’s make this example very simple. myCompany.com is starting very small. In fact there’s only one person today. Here is the LDIF.

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

dn: ou=People,dc=myCompany,dc=com
objectClass: organizationalunit
objectClass: top
ou: People

dn: uid=mark,ou=People,dc=myCompany,dc=com
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@myCompany.com
l: Barraux
ou: People

Here is the procedure for adding the data for myCompany.com through the Control Panel.

  1. Save the LDIF in myCompany.ldif, being careful not to add any spaces at the end of lines, and preserving a blank line at the end of the file.
  2. Open OpenDJ Control Panel. (On UNIX, ./OpenDJ/bin/control-panel. On Windows, double-click OpenDJ\bat\control-panel.bat.)
  3. Connect to your server, and notice New Base DN… and Import LDIF… in the Directory Data List.
  4. Click New Base DN…
    1. For the Backend, select New Backend: and provide the name myCompanyRoot.
    2. For the Base DN: dc=myCompany,dc=com.
    3. Leave Directory Data: Only Create Base Entry, and click OK to create the new base DN.
      At this point, you have created a new backend with a base DN entry, so you must still import data from LDIF.
  5. Click Import LDIF… in the Control Panel.
    1. For Backend: myCompanyRoot.
    2. For File to Import: myCompany.ldif, and then click OK to import the data.
      When prompted to overwrite existing data, in this case the base entry, choose Yes.

You can click Manage Entries in the Control Panel now to browse the new suffix you added.

Advertisements

7 Comments

Filed under Directory Services and LDAP

7 responses to “OpenDJ: Adding your data, part II

  1. gulam mustafa

    Can you Help me little bit more.
    i want added only my Custom object class with my custom attribute.
    i want base DN and dc contain only my custom object class .no Top or Domain Object class.
    please can you help
    how i able manage custom schema for above problem (eg:structural schema.)

  2. Hello,

    Adding custom object classes and attributes, as documented in the Admin Guide under http://opendj.forgerock.org/doc/admin-guide/index.html#update-schema, will let you create a custom object class that derives only from the Top object class. (All object classes ultimately derive from the abstract object class, Top, so you cannot get rid of Top.)

    When you create new object classes and attribute types, by default OpenDJ directory server stores them in /path/to/OpenDJ/config/schema/99-user.ldif. Here’s what that file contained for me after I created a custom object class and custom attribute type definition using OpenDJ control-panel.

    dn: cn=schema
    objectClass: subschema
    objectClass: ldapSubentry
    objectClass: top
    cn: schema
    objectClasses: ( temp-custom-oc-oid NAME 'customOC' DESC 'Custom object class that derives only from top' SUP top STRUCTURAL MUST customAttr )
    attributeTypes: ( temp-custom-attr-oid NAME 'customAttr' DESC 'Custom attribute type for custom object class' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE userApplications )
    modifyTimestamp: 20120809100548Z
    modifiersName: cn=Directory Manager,cn=Root DNs,cn=config
    

    If you have multiple OpenDJ servers configured for replication, replication copies the schema to the other servers, so you only need to change the schema on one server.

    Next, I created a new base DN with only the base entry, and edited that entry to use the customOC object class. The resulting entry looks like this in LDIF:

    dn: customAttr=My New Base DN
    customAttr: My New Base DN
    objectClass: customOC
    objectClass: top
    

    The customOC is structural, so I don’t need another structural object class.

    Hope this helps,
    Mark

    • Gulam mustafa

      i am really grateful to you.
      Thanks for nice reply
      i need little bit more help .
      ……………………………………….
      when i created new base DN eg: dc=example,dc=com.
      when i entered user information .
      default it take inetOrgPerson Object class with lots of attribute field.
      ……………………………………………………………………………………………
      i created custom attribute eg:
      marginnotes2_1
      marginnotes2_2
      marginnotes2_3
      marginnotes2_4
      and three object class
      abstract object class name: Objabstract with 2 attribute.1)marginnotes2_1
      2)marginnotes2_2

      Structural object class name: ObjMN2 with 2 attribute.1)marginnotes2_3
      2)marginnotes2_4

      Auxiliary object class name: MN1 with 2 attribute.1)marginnotes2_1
      2)marginnotes2_2
      ……………………………………………………………………………………………….
      in above Among of 3 object class i only successfully add Auxiliary object class with domain or other object classes
      ………………………………………………………………………………………………..
      now i want i will create new base DN and use only my custom object class and attribute .
      eg dc=room,dc=com.
      now i want any new user entry should be take only my custom attribute.
      not any other built in or default attribute.
      …………………………………………………………………………………………………….
      N.B: i am using Windows operating system.
      …………………………………………………………………………………..
      if you able help me regrading that
      please help me out.

      • When creating object classes, keep in mind what’s described in RFC 4512, section 2.4.

        • Abstract object classes are there for other object classes to inherit from.
        • Each object object class derives from one hierarchy of structural object class.
        • Once your entry has a structural object class inheritance, auxiliary classes give you a way to decorate the entry with additional attributes.

        So if for example marginnotes2_3 is a naming attribute on your structural object class, and that object class inherits from top, you could for example have an entry like this that gets all 4 attributes:

        dn: marginnotes2_3=myAttrValue from ObjMN2
        objectClass: top
        objectClass: ObjMN2
        objectClass: MN1
        marginnotes2_1: Attribute from MN1
        marginnotes2_2: Additional attribute from MN1
        marginnotes2_3: myAttrValue from ObjMN2
        marginnotes2_4: Additional attribute from ObjMN2
        

        You will need to create those entries in LDIF, either through the control-panel LDIF view, or as describe in the Admin Guide.

        Hope it helps. Regards,
        Mark

      • Durga Revanth

        99-user.ldif fie is not created for me after the attribute and class craetion

  3. Md Gulam Mustafa from Bangladesh

    Thanks a lot Dear.
    now i am successfully customize my data.

  4. Tomas Bundil

    I have created my own backend at start, the first question is:
    1. Best-practice is create own backend or use userRoot ?
    After some exploration and testing I have realized that in own backend there are only few indexed attributes compared to userRoot, for example member is not indexed…
    So there should be an info that when creating own backend you should also take a look on index settings.

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