Extending the schema using a custom schema file
To add new attributes and object classes to your PingDirectory server schema, create a custom schema file.
Steps
-
Create an LDIF file with the new attribute extensions using a text editor.
Example:
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.
Example:
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
inetOrgPersonstructural 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/schemadirectory.In this example, the file is saved as
99-auxobjclass.ldif. -
Load the schema extensions into the PingDirectory server using one of the following methods.
The only method that requires a server restart is allowing the server to read the schema file at startup. You should choose this option when adding custom schema files other than the base
99-user.ldiffile to reduce the chance for dependency errors.Choose from:
-
Create a task that loads the new extensions into the schema.
The following example creates a task with the ID
add-schema-99-auxobjclassand adds it usingldapmodify: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
-
Import the schema file using the Administrative Console Schema Editor. Learn more in Modifying the schema.
-
Add the schema file using
load-ldap-schema-file.$ bin/load-ldap-schema-file --schemaFile config/schema/99-auxobjclass.ldif -
Restart the PingDirectory server. The schema file is read at startup.
-
-
Add the new object class and attribute to an existing user entry.
Example:
$ 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
ldapsearchto display the attribute.Example:
$ bin/ldapsearch --baseDN dc=example,dc=com "(uid=user.9)" contractorStatusResult:
dn: uid=user.9,ou=People,dc=example,dc=com contractorStatus: TRUE