距離上一次摸 LDAP Server 真是有些久了,該忘了也都忘光了,只能靠自己以前的筆記和舊的 LDAP Server 的設定檔,和 Google 搜尋網頁,所以要不斷測試設定檔和匯入 ldif 設定檔,但如果沒有先把舊的資料先清除,直接匯入新的資料,就會出現類似下面的畫面:
# slapadd -v -l /root/ldif/s0990.passwd.ldif_N
The first database does not allow slapadd; using the first available one (2)
=> bdb_tool_entry_put: id2entry_add failed: DB_KEYEXIST: Key/data pair already exists (-30995)
=> bdb_tool_entry_put: txn_aborted! DB_KEYEXIST: Key/data pair already exists (-30995)
slapadd: could not add entry dn=”uid=s0990001,ou=Student,dc=ldap,dc=tces.ilc.edu.tw” (line=1): txn_aborted! DB_KEYEXIST: Key/data pair already exists (-30995)
_ 0.77% eta none elapsed none spd 118.5 k/s
Closing DB…[@more@]如果是修改 /etc/openldap/slapd.conf 設定檔
要做下面的處理
# service slapd stop
# rm -rf /etc/openldap/slapd.d/*
# slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
# chown -R ldap:ldap /etc/openldap/slapd.d
# service slapd start
如果要重新匯入全部的資料
# service slapd stop
# rm -rf /var/lib/ldap/*
# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
匯入 LDIF 格式檔後
# chown -R ldap:ldap /var/lib/ldap
# service slapd start