繁体   English   中英

如何在LDAP目录服务器架构中定义对象类o和ou?

[英]How to define objectclass o and ou in LDAP directory server schema?

问题1:

我正在使用apacheds 2.0嵌入式ldap服务器。 服务启动时出现问题。 有什么事吗

错误信息:

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代码:

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);
}

问题2:服务启动后,我想导入ldif文件。 我的文件正确吗? 我是否需要在文件中设置OU和O,还是应该在服务代码中设置它? 有什么例子吗?

ldif文件:

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

我认为您的问题是这一行: entry("dc", "example", "com");

如错误所示,它不是多值的。

没有语法上的线索,但我想它可能更像是: entry("dc", "dc=example,dc=com");

要不然

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

对于第二个问题,您可以尝试:

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

我认为您需要为每个组件单独的entry()调用:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM