Pergunta

Question 1:

I am using apacheds 2.0 embedded ldap server. I am seeing issues when service starts up. What could be wrong?

Error message:

09:40:43.657 [main] ERROR o.a.d.a.l.m.entry.DefaultAttribute - ERR_04487_ATTRIBUTE_IS_SINGLE_VALUED The attribute 'dc' is single valued, we cant add no more values into it
09:40:43.658 [main] WARN  o.a.d.s.c.n.NormalizationInterceptor - The Rdn 'dc=example' is not present in the entry
Exception in thread "main" org.apache.directory.api.ldap.model.exception.LdapException: ERR_04269 OBJECT_CLASS for OID ou does not exist!
    at org.apache.directory.api.ldap.model.schema.registries.DefaultSchemaObjectRegistry.lookup(DefaultSchemaObjectRegistry.java:176)
    at org.apache.directory.api.ldap.schemamanager.impl.DefaultSchemaManager.lookupObjectClassRegistry(DefaultSchemaManager.java:1656)

Java code:

Partition examplePartition = addPartition("example", "dc=example,dc=com");

// Index some attributes on the apache partition
addIndex(examplePartition, "objectClass", "ou", "uid");

    // And start the service
service.startup();

// Inject the context entry for dc=foo,dc=com partition if it does not already exist
try {
  service.getAdminSession().lookup(examplePartition.getSuffixDn());
}
catch (LdapException lnnfe) {
  Dn dn = new Dn("dc=example,dc=com");
  Entry entry = service.newEntry(dn);
  entry("objectClass", "top", "domain", "extensibleObject", "ou", "o", "mail");
  entry("dc", "example", "com");
  // entry("ou", "people");
  // entry("o", "exampleinc");
  service.getAdminSession().add(entry);
}

Question 2: Once the service is up I would like to import ldif file. Is my file correct? Do I need to set OU and O and in file or should it be set in service code? Any example?

ldif file:

dn: ou=people,dc=example,dc=com
ou: people
objectclass: top
objectclass: organizationalUnit

dn: o=exampleinc,dc=example,dc=com
o: exampleinc
objectclass: top
objectclass: organization

dn: cn=some guy,ou=people,o=exampleinc,dc=example,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
CN: some guy
sn: some_guy
givenName: someguy
name: some guy
uid: some_guy
mail: some_guy@example.com
Foi útil?

Solução

For the second question you can try:

dn: ou=people,dc=example,dc=com
ou: people
objectclass: top
objectclass: organizationalUnit

dn: ou=exampleinc,ou=people,dc=example,dc=com
ou: exampleinc
objectclass: top
objectclass: organization

dn: cn=some guy,ou=exampleinc,ou=people,dc=example,dc=com

Outras dicas

I think your issue is this line: entry("dc", "example", "com");

As the error notes, it is not multivalued.

No clue on the syntax, but I imagine it might be more like: entry("dc", "dc=example,dc=com");

or else

entry("dc", "example.com");

i think you need separate entry() call for each component:

entry("dc", "example");
entry("dc", "com");
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top