Skip to content

add a custom schema  #2

Description

@marcdexet

Hi,

It's not possible to add a custom schema to the directory.

I wrote a unit test

    void testSchemaLoadLdif() {
        d2LdapServer.loadLdif("""
dn: cn=schema
changetype: modify
add: attributetypes
attributetypes: ( 1.3.6.1.4.1.99999.2.1.0.0 NAME 'myRegionalOffice' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' ) 
""")
        assertTrue(d2LdapServer.exists("cn=cn3,dc=d2"))
    }

It results into

The global schema subentry cannot be added since it exists by default.

org.apache.directory.shared.ldap.exception.LdapNameAlreadyBoundException: The global schema subentry cannot be added since it exists by default.
at org.apache.directory.server.core.exception.ExceptionInterceptor.add(ExceptionInterceptor.java:149)
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1189)
at org.apache.directory.server.core.interceptor.BaseInterceptor.add(BaseInterceptor.java:129)
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1189)
at org.apache.directory.server.core.authz.AciAuthorizationInterceptor.add(AciAuthorizationInterceptor.java:448)
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1189)

It's because the parsed ldif is used to do an add operation.

    private consumeLdifReader(ldifReader) {
        while (ldifReader.hasNext()) {
            def entry = ldifReader.next()
            def ldif = LdifUtils.convertToLdif(entry, Integer.MAX_VALUE)
            directoryService.adminSession.add(directoryService.newEntry(ldif, entry.dn.toString()))
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions