我无法添加新条目

时间:2013-12-11 22:56:56

标签: openldap

我尝试向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

1 个答案:

答案 0 :(得分:5)

我在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