我尝试向 ldap 添加新条目,但我不知道为什么它不起作用。

我有 addPeople.ldif 文件:

dn: ou=People,dc=example,dc=com,dc=au
ou: people
description: All people in organisation
objectClass: organizationalUnit

我输入以下命令:
ldapadd -x -D "cn=Manager,dc=example,dc=com,dc=au" -w secret -f ~/addPeople.ldif

结果:
adding new entry "ou=People,dc=example,dc=com,dc=au"
ldap_add: No such object (32)

按照quickstart openldap 文档命令:
ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts

返回:
# extended LDIF
#
# LDAPv3
# base <> with scope baseObject
# filter: (objectclass=*)
# requesting: namingContexts
#

#
dn:
namingContexts: dc=example,dc=com,dc=au

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

如何解决这个问题?

编辑

可能没有 dc=example,dc=com,dc=au 条目。
$ ldapsearch -b 'dc=example,dc=com,dc=au' -s base '(objectclass=*)'
# extended LDIF
#
# LDAPv3
# base <dc=example,dc=com,dc=au> with scope baseObject
# filter: (objectclass=*)
# requesting: ALL
#

# search result
search: 2
result: 32 No such object

# numResponses: 1

最佳答案

我在这个 faq 中找到了解决方案。
一开始我应该添加初始条目。我创建了 firstelement.ldif :

dn: dc=example,dc=com,dc=au
o: My Company
objectclass: organization
objectclass: dcObject

dn: cn=Manager,dc=example,dc=com,dc=au
cn: Manager
sn: Manager
objectclass: person

我执行了以下命令:
ldapadd -D "cn=Manager, dc=example,dc=com,dc=au" -W -f ~/firstelement.ldif

早些时候我还添加了一个初始条目,但事实证明我做错了。我的第一个错误的 ldif 文件带有初始条目:
version:1
# This DN is first to be loaded into database, then first level DN, then 2nd level, etc.
dn :dc=example,dc=com,dc=au     # DN
objectClass: dcObject           # required because 'dc' is packaged here; is AUXILLARY
objectClass: organization     # STRUCTURAL needed because 'dcObject' is AUXILLARY
dc: example                            # 'dc' is MUST as defined in 'dcObject'
o: example                              # 'o' is MUST as defined in 'organization'
description:Example Company  # 'description' is MA

关于openldap - 我无法添加新条目,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20531688/

10-15 04:32