389-DS Creating Custom Attributes and ObjectClasses

From Notes_Wiki

Home > Ubuntu > Ubuntu 22.04 > Ubuntu 22.04 389-DS server setup > 389-DS Creating Custom Attributes and ObjectClasses

Creating Example Custom Attributes and ObjectClasses in 389 Directory Server

Create LDIF to Add Custom Attributes

a) Create the LDIF file

vim add-example-attributes.ldif

Paste this content exactly:

dn: cn=schema
changetype: modify
add: attributeTypes
attributeTypes: ( 1.3.6.1.4.1.12345.1.1 NAME 'exampleAttribute1' DESC 'Example boolean attribute' EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )
-
add: attributeTypes
attributeTypes: ( 1.3.6.1.4.1.12345.1.2 NAME 'exampleAttribute2' DESC 'Example string attribute' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
-
add: attributeTypes
attributeTypes: ( 1.3.6.1.4.1.12345.1.3 NAME 'exampleAttribute3' DESC 'Example timestamp attribute' EQUALITY generalizedTimeMatch ORDERING generalizedTimeOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )

Explanation of example attributes:

  • exampleAttribute1: A boolean flag.
  • exampleAttribute2: A case-insensitive string.
  • exampleAttribute3: A timestamp.

b) Apply the LDIF

ldapmodify -v -x -D "cn=Directory Manager" -W -H ldaps://ldap.example.com -f add-example-attributes.ldif

Create LDIF to Add Custom ObjectClasses

a) Create the LDIF file

vim add-example-objectclasses.ldif

Paste this content exactly:

dn: cn=schema
changetype: modify
add: objectClasses
objectClasses: ( 1.3.6.1.4.1.12345.2.1 NAME 'exampleAuxObject' SUP top AUXILIARY MAY ( exampleAttribute1 $ exampleAttribute2 ) )
-
add: objectClasses
objectClasses: ( 1.3.6.1.4.1.12345.2.2 NAME 'exampleStructObject' SUP top STRUCTURAL MUST ( exampleAttribute2 ) MAY ( exampleAttribute3 ) )

Explanation of example object classes:

  • `exampleAuxObject`: An AUXILIARY objectClass allowing `exampleAttribute1` and `exampleAttribute2`.
  • `exampleStructObject`: A STRUCTURAL objectClass requiring `exampleAttribute2` and optionally `exampleAttribute3`.

b) Apply the LDIF

ldapmodify -v -x -D "cn=Directory Manager" -W -H ldaps://ldap.example.com -f add-example-objectclasses.ldif

Verifying Custom Attributes and ObjectClasses in 389 Directory Server

After applying your custom LDIFs, use the following steps to verify that the attributes and objectClasses have been successfully added to the schema.

Step 1: List All Attribute Types

Use the following command to list all defined `attributeTypes`:

ldapsearch -x -D "cn=Directory Manager" -W -H ldaps://ldap.example.com -b "cn=schema" "(objectClass=*)" attributeTypes

Step 2: List All Object Classes

To view all available `objectClasses`, run:

ldapsearch -x -D "cn=Directory Manager" -W -H ldaps://ldap.example.com -b "cn=schema" "(objectClass=*)" objectClasses

Step 3: Filter for Custom Schema by OID (Optional)

If you've used a specific OID prefix (e.g., `1.3.6.1.4.1.12345`) for your custom definitions, you can filter the output to confirm your entries:

ldapsearch -x -D "cn=Directory Manager" -W -H ldaps://ldap.example.com -b "cn=schema" "(objectClass=*)" attributeTypes objectClasses | grep "1.3.6.1.4.1.12345"

Expected Output Examples

You should see output like the following if your custom schema was loaded successfully:

attributeTypes: ( 1.3.6.1.4.1.12345.1.1 NAME 'exampleAttribute1' ...
objectClasses: ( 1.3.6.1.4.1.12345.2.1 NAME 'exampleAuxObject' ...

Replace `ldap.example.com` with your actual LDAP server hostname or IP address.

Home > Ubuntu > Ubuntu 22.04 > Ubuntu 22.04 389-DS server setup > 389-DS Creating Custom Attributes and ObjectClasses