gpt4 book ai didi

java - 如何在 LDAP 目录服务器模式中定义对象类 o 和 ou?

转载 作者:行者123 更新时间:2023-12-01 04:13:46 26 4
gpt4 key购买 nike

问题 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

最佳答案

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

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

关于java - 如何在 LDAP 目录服务器模式中定义对象类 o 和 ou?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19638145/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com