How can i add an custom attribute and assign it to an existing custom object class in sun ds

user2818666 picture user2818666 · Oct 21, 2013 · Viewed 20.4k times · Source

I need to add an attribute to sun ds schema and assign it to an existing custom object class.

I know how to add an attribute but how can i add the attribute to an existing custom object class.

Please help.

Thanks

Answer

Terry Gardner picture Terry Gardner · Oct 21, 2013

Create the new attributeTypes definition, and add the new attribute name to the objectClasses MUST or MAY clause.

This example below shows the above using a file in the config/schema directory.

dn: cn=schema
objectClass: top
objectClass: ldapSubentry
objectClass: subschema
##
## The new attribute type
##
attributeTypes: ( stackOverflowQuestionID-oid
  NAME 'stackOverflowQuestionID'
  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
  SINGLE-VALUE
  DESC 'Describes the ID of a stack overflow question.'
  X-ORIGIN 'StackOverflow question.' )
##
## An existing object class
##
objectClasses: ( stackOverflow-oid NAME 'stackOverflow'
  SUP top
  STRUCTURAL
  MUST cn
  MAY (
    description $
    stackOverflowQuestionID
  ) X-ORIGIN 'StackExchange network' )

The example above can be used as a file in the config/schema directory, or the attributeTypes and objectClasses can be added/modified using LDAP in under cn=schema.

LDIF change records

dn: cn=schema
changetype: modify
add: attributeTypes
##
## The new attribute type
##
attributeTypes: ( stackOverflowQuestionID-oid
  NAME 'stackOverflowQuestionID'
  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
  SINGLE-VALUE
  DESC 'Describes the ID of a stack overflow question.'
  X-ORIGIN 'StackOverflow question.' )

For the existing objectClass, create an LDIF change record that deletes the original and then adds it back, this time including the new MUST or MAY clause. Or, as you say, use an LDAP browser to update the objectClasses attribute.