Search code examples
javaldapapachedsldif

Adding Custom Attributes to ApacheDS Server


I am using ApacheDS Server as an LDAP Server. I have created a custom attribute to use in my LDAP structure that I have defined. I have created a schema and inside the Schema I have defined an ObjectClass and an attribute called dateOfBirth. I exported the Schema and imported it into the DIT of ApacheDS. The schema is imported and can view the dateOfBirth attribute.

However, when I try to add it I get a warning saying:

Warning according to the schema attribute dateOfBirth is not allowed.

Do you still want to add the new value?

The dateOfBirth is to store information about a Person. The Person object class in LDAP is called inetOrgPerson ObjectClass. What is the best way to add the dateOfBirth in order to use it?


Solution

  • There is no need to define a dateOfBirth attribute. The auxiliary objectClass naturalPerson - described in RFC2985 - already allows this attribute using generalizedTimeSyntax. Add the naturalPerson objectClass to your entry, then add a dateOfBirth attribute that conforms to generalizedTimeSyntax.

    dn: cn=myPerson,dc=example,dc=com
    objectClass: top
    objectClass: inetOrgPerson
    objectClass: naturalPerson
    dateOfBirth: 20121115121912.810Z
    

    and so forth.

    Update: example objectClass definition from RC2985.

    dn: cn=schema
    objectClass: top
    objectClass: ldapSubentry
    objectClass: subSchema
    objectClasses: ( 1.2.840.113549.1.9.24.2 NAME 'naturalPerson'
      SUP top
      AUXILIARY
      MAY ( emailAddress $
        unstructuredName $
        unstructuredAddress $
        dateOfBirth $
        placeOfBirth $
        gender $
        countryOfCitizenship $
        countryOfResidence $
        pseudonym $
        serialNumber )
      X-ORIGIN 'RFC 2985' )