To add new attributes and object classes to your Directory Server schema, create a custom schema file.
-
Create an LDIF file with the new attribute extensions using a text editor.
dn: cn=schema objectClass: top objectClass: ldapSubentry objectClass: subschema attributeTypes: ( contractorStatus-OID NAME 'contractorStatus' EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE USAGE userApplications X-ORIGIN 'Directory Server Example' ) attributeTypes: ( contractorAgency-OID NAME 'contractorAgency' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{256} SINGLE-VALUE USAGE userApplications X-ORIGIN 'PingDirectory Server Example' )
-
In the LDIF file you created in step 1, add a new object class definition after the
attribute types.
This example creates an auxiliary object class,
contractor
, that alone cannot be used as an entry.The object class is used to add supplemental information to the
inetOrgPerson
structural object class. The attributes are all optional for the new object class.objectClasses: ( contractor-OID NAME 'contractor' DESC 'Contractor status information' SUP top AUXILIARY MAY ( contractorStatus $ contractorAgency ) X-ORIGIN 'PingDirectory Server Example' )
-
Save the file and place it in the
<server-root>/config/schema
directory.
In this example, the file is saved as 99-auxobjclass.ldif.
-
Load the schema extensions into Directory Server. You have four
options:
- Create a task that loads the new extensions into the schema.
The following example creates a task with the ID
add-schema-99-auxobjclass
and adds it using ldapmodify.dn: ds-task-id=add-schema-99-auxobjclass,cn=Scheduled Tasks,cn=tasks objectClass: top objectClass: ds-task objectClass: ds-task-add-schema-file ds-task-id: add-schema-99-auxobjclass ds-task-class-name: com.unboundid.directory.server.tasks.AddSchemaFileTask ds-task-schema-file-name: 99-auxobjclass.ldif
Note:When using this method, you don't need to restart the server.
- Import the schema file using the Administrative Console Schema Editor.Note:
When using this method, you don't need to restart the server.
-
- Place the 99-auxobjclass.ldif file in the <server-root>/config/schema directory.
- Restart PingDirectory Server.
Note:The schema file is read at startup.
- Add the schema file using load-ldap-schema-file.
$ bin/load-ldap-schema-file --schemaFile config/schema 99-auxobjclass.ldif
Note:When using this method, you don't need to restart the server.
- Create a task that loads the new extensions into the schema.
-
Add the new object class and attribute to an existing user entry.
$ bin/ldapmodify dn: uid=user.9,ou=People,dc=example,dc=com changetype: modify add: objectClass objectClass: contractor - add: contractorStatus contractorStatus: TRUE
-
To verify the addition, run ldapsearch to display the
attribute.
$ bin/ldapsearch --baseDN dc=example,dc=com "(uid=user.9)" contractorStatus
dn: uid=user.9,ou=People,dc=example,dc=com contractorStatus: TRUE