Debian

使用全新安裝的 OpenLdap 將 slapd.conf 轉換為 cn=config 後無法修改或添加資訊

  • January 10, 2012

我從在 debian 上全新安裝 openldap 2.4.28 開始。它們是 debian 包和 gnuTLS 的一些問題,所以我用 opennSSL 庫編譯了一個版本。

官方文件很難理解如何使用 openLDAP 的新 cn=config 管理從頭開始安裝。因此,我在第一次啟動 openLDAP 時使用以下命令將 slapd.conf 轉換為 cn=config:

/usr/local/libexec/slapd -u openldap -g openldap -f slapd.conf.seb -F /usr/local/etc/openldap/slapd.d/ -d -1

我的 slapd.conf.seb 相等:

include         /usr/local/etc/openldap/schema/cosine.schema
include         /usr/local/etc/openldap/schema/nis.schema
include         /usr/local/etc/openldap/schema/inetorgperson.schema
include         /usr/local/etc/openldap/schema/openldap.schema
include         /usr/local/etc/openldap/schema/misc.schema
include         /usr/local/etc/openldap/schema/ppolicy.schema
include         /usr/local/etc/openldap/schema/gosa/samba3.schema
include         /usr/local/etc/openldap/schema/gosa/trust.schema
include         /usr/local/etc/openldap/schema/gosa/gofax.schema
include         /usr/local/etc/openldap/schema/gosa/gofon.schema
include         /usr/local/etc/openldap/schema/gosa/gosystem.schema
include         /usr/local/etc/openldap/schema/gosa/goto-mime.schema
include         /usr/local/etc/openldap/schema/gosa/goto.schema
include         /usr/local/etc/openldap/schema/gosa/goserver.schema
include         /usr/local/etc/openldap/schema/gosa/gosa-samba3.schema
include         /usr/local/etc/openldap/schema/gosa/openssh-lpk.schema
include         /usr/local/etc/openldap/schema/gosa/dnszone.schema
include         /usr/local/etc/openldap/schema/gosa/nagios.schema
include         /usr/local/etc/openldap/schema/gosa/dhcp.schema
include         /usr/local/etc/openldap/schema/gosa/sudo.schema

pidfile         /usr/local/var/run/slapd.pid
argsfile        /usr/local/var/run/slapd.args

database        bdb
suffix          "dc=parisgeo,dc=cnrs,dc=fr"
rootdn          "cn=admin,cn=config,dc=parisgeo,dc=cnrs,dc=fr"
rootpw  {SSHA} secret
directory       /srv/openldap-data
index   objectClass     eq

我對這個簡單的轉換沒有任何問題,但是在那之後,用這個命令 ldapadd 或 ldapmodify 導入數據是不可能的。

我不了解 openLDAP 的預設讀/寫權限,我嘗試使用 ldapmodify,使用綁定和密碼,但我遇到了同樣的問題:

root@xxxx:/usr/local/etc/openldap# ldapadd -x -D "cn=admin,cn=config,dc=parisgeo,dc=cnrs,dc=fr" -W -f sauvegarde.ldif 
Enter LDAP Password: xxx
adding new entry "cn=admin,dc=parisgeo,dc=cnrs,dc=fr"
ldap_add: Constraint violation (19)
   additional info: structuralObjectClass: no user modification allowed

我嘗試使用此範例修改 cn=config 的權利:

dn: olcDatabase={-1}frontend,cn=config
changetype: modify
delete: olcAccess

dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootDN
olcRootDN: cn=admin,cn=config

dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA} secret

dn: olcDatabase={0}config,cn=config
changetype: modify
delete: olcAccess

ldapadd -Y EXTERNAL -H ldapi:/// -f slapd.modify.root.ldif 

同樣的問題,我無權這樣做,有或沒有選項密碼輸入 -W 或綁定選項 -D “cn=config,cn=admin,dc=parisgeo,dc=cnrs,dc=fr”

root@xxxx:/usr/local/etc/openldap# ldapadd -Y EXTERNAL -H ldapi:/// -f slapd.modify.root.ldif 

SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={-1}frontend,cn=config"
ldap_modify: Insufficient access (50)

root@xxxx:/usr/local/etc/openldap# ldapadd -x -W -H ldapi:/// -f slapd.modify.root.ldif Enter LDAP Password: 
ldap_bind: Invalid credentials (49)

root@xxxxx:/usr/local/etc/openldap# ldapadd -D "cn=config,cn=admin,dc=parisgeo,dc=cnrs,dc=fr" -W -Y EXTERNAL -H ldapi:/// -f slapd.modify.root.ldif 
Enter LDAP Password: 
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={-1}frontend,cn=config"
ldap_modify: Insufficient access (50)

您是否知道從頭開始安裝的解決方案?

我理解我的錯誤,我們需要在轉換之前將這三行添加到 slapd.conf :

database config
rootdn "cn=admin,cn=config"
rootpw {SSHA} secret 

轉換後,我們可以測試一下:

ldapwhoami -x -D cn=config -W

引用自:https://serverfault.com/questions/342086