To perform a dynamic schema change, use the ldap_modify API with a DN of "cn=schema". It is permissible to add, delete, or replace only one schema entity (for example, an attribute type or an object class) at a time.
To delete a schema entry, specify the schema attribute that defines the schema entry (objectclasses or attributetypes), and for its value, the OID in parentheses. For example, to delete the attribute with OID <attr-oid>:
dn: cn=schema changetype: modify delete: attributetypes attributetypes: ( <attr-oid> )
You can also provide a full description. In either case, the matching rule used to find the schema entity to delete is objectIdentifierFirstComponentMatch.
To add or replace a schema entity, you MUST provide a LDAP Version 3 definition and you MAY provide the IBM definition. In all cases, you must provide only the definition or definitions of the schema entity that you want to affect.
For example, to delete the attribute type 'cn' (its OID is 2.5.4.3), use ldap_modify() with:
LDAPMod attr; LDAPMod *attrs[] = { &attr, NULL }; char *vals [] = { "( 2.5.4.3 )", NULL }; attr.mod_op = LDAP_MOD_DELETE; attr.mod_type = "attributeTypes"; attr.mod_values = vals; ldap_modify_s(ldap_session_handle, "cn=schema", attrs);
To add a new attribute type bar with OID 20.20.20 that inherits from the attribute "name" and has a length of 20 chars:
char *vals1[] = { "( 20.20.20 NAME 'bar' SUP name )" NULL }; char *vals2[] = { "( 20.20.20 LENGTH 20 )", NULL }; LDAPMod attr1; LDAPMod attr2; LDAPMod *attrs[] = { &attr1, &attr2, NULL }; attr1.mod_op = LDAP_MOD_ADD; attr1.mod_type = "attributeTypes"; attr1.mod_values = vals1; attr2.mod_op = LDAP_MOD_ADD; attr2.mod_type = "IBMattributeTypes"; attr2.mod_values = vals2; ldap_modify_s(ldap_session_handle, "cn=schema", attrs);
The LDIF version of the above would be:
dn: cn=schema changetype: modify add: attributetypes attributetypes: ( 20.20.20 NAME 'bar' SUP name ) - add:ibmattributetypes ibmattributetypes: (20.20.20 LENGTH 20)
Access controls
Dynamic schema changes can be performed only by a replication supplier or the administrator DN.
Replication
When a dynamic schema change is performed, it is replicated.