Pergunta

I am trying to create complex partitition with Apache DS

        Dn dnApache = new Dn("ou=test,dc=Apache,dc=org");
        Entry entryApache = service.newEntry(dnApache);
        entryApache.add("objectClass", "top", "domain", "extensibleObject");
        entryApache.add("dc", "Apache");
        service.getAdminSession().add(entryApache);

It works good and I have no problems. But when I tried to create more complex partition, like this:

        Dn dnApache = new Dn("ou=test,dc=Apache,dc=org");
        Entry entryApache = service.newEntry(dnApache);
        entryApache.add("objectClass", "top", "domain", "extensibleObject");
        entryApache.add("dc", "Apache");
        service.getAdminSession().add(entryApache);

        Dn serviceDN = new Dn("ou=service,ou=test,dc=Apache,dc=org");
        Entry serviceEntry = service.newEntry(serviceDN);
        entryApache.add("objectClass", "top",  "organizationalUnit");
        entryApache.add("dc", "Service");
        service.getAdminSession().add(serviceEntry);

I have an exception like this:

org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException: ERR_60 Entry ou=service,ou=test,dc=Apache,dc=org does not contain a STRUCTURAL ObjectClass
    at org.apache.directory.server.core.schema.SchemaInterceptor.assertObjectClasses(SchemaInterceptor.java:1493)
    at org.apache.directory.server.core.schema.SchemaInterceptor.check(SchemaInterceptor.java:951)
    at org.apache.directory.server.core.schema.SchemaInterceptor.add(SchemaInterceptor.java:1045)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.exception.ExceptionInterceptor.add(ExceptionInterceptor.java:188)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.admin.AdministrativePointInterceptor.add(AdministrativePointInterceptor.java:1201)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.authz.AciAuthorizationInterceptor.add(AciAuthorizationInterceptor.java:516)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.referral.ReferralInterceptor.add(ReferralInterceptor.java:249)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.authn.AuthenticationInterceptor.add(AuthenticationInterceptor.java:335)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.normalization.NormalizationInterceptor.add(NormalizationInterceptor.java:127)
    at org.apache.directory.server.core.DefaultOperationManager.add(DefaultOperationManager.java:394)
    at org.apache.directory.server.core.shared.DefaultCoreSession.add(DefaultCoreSession.java:193)
    at org.apache.directory.server.core.shared.DefaultCoreSession.add(DefaultCoreSession.java:170)
    at EmbeddedADSVerTrunk.initDirectoryService(EmbeddedADSVerTrunk.java:218)
    at EmbeddedADSVerTrunk.<init>(EmbeddedADSVerTrunk.java:234)
    at EmbeddedADSVerTrunk.main(EmbeddedADSVerTrunk.java:264)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Can you please help me?

Exception in this line:  service.getAdminSession().add(serviceEntry);
Foi útil?

Solução

Fixed in such way:

    Partition testPartition = addPartition("test", "ou=test,dc=apache,dc=org");
    Partition servicePartition = addPartition("service", "ou=service,ou=test,dc=apache,dc=org");


    addIndex(infopulsePartition, "objectClass", "ou", "uid");
    addIndex(servicePartition, "objectClass", "ou", "uid");

    service.startup();

    if (!service.getAdminSession().exists(infopulsePartition.getSuffixDn())) {
        Dn dnApache = new Dn("ou=test,dc=apache,dc=org");
        Entry entryApache = service.newEntry(dnApache);
        entryApache.add("objectClass", "top", "domain", "extensibleObject");
        entryApache.add("dc", "Apache");
        service.getAdminSession().add(entryApache);
    }

    if (!service.getAdminSession().exists(servicePartition.getSuffixDn())) {
        Dn dnApache = new Dn("ou=service,ou=test,dc=apache,dc=org");
        Entry entryApache = service.newEntry(dnApache);
        entryApache.add("objectClass", "top", "domain", "extensibleObject");
        entryApache.add("dc", "Apache");
        service.getAdminSession().add(entryApache);
    }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top