我在 Centos 7 上安装了 OpenLDAP,并尝试创建管理员用户。但我遇到了一些错误ldap_modify
。以下是我的步骤:
安装 OpenLDAP 并启动它:
sudo yum install openldap openldap-servers openldap-clients -y
systemctl start slapd.service
创造admin.ldif
dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}CRiUMh5UM8/chPHbfc2Se2JA8Quc5F1P
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"
read by dn.base="cn=ldapadmin,dc=demo,dc=local" read by * none
dn: olcDatabase={2}bdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=demo,dc=local
dn: olcDatabase={2}bdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=ldapadmin,dc=demo,dc=local
dn: olcDatabase={2}bdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}CRiUMh5UM8/chPHbfc2Se2JA8Quc5F1P
dn: olcDatabase={2}bdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange by
dn="cn=ldapadmin,dc=demo,dc=local" write by anonymous auth by self write by * none
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=ldapadmin,dc=demo,dc=local" write by * read
运行下面的命令行:
ldapmodify -Y EXTERNAL -H ldapi:/// -f /root/demo/users/admin.ldif
然后我得到了这个错误:
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={2}bdb,cn=config"
ldap_modify: No such object (32)
matched DN: cn=config
我在使用 Centos 7 的其他系统中没有遇到此错误,所以我想知道这里发生了什么。
请帮忙。
答案1
我找到了问题所在。以下是解决方法:
改成olcDatabase={2}bdb
olcDatabase={2}hdb
确保事先运行这些:
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif