經過 utf8 轉換過的 LDIF 格式檔,在匯入時會出現下面的錯誤的訊息
# slapadd -l /root/ldif/t850008.ldif
The first database does not allow slapadd; using the first available one (2)
str2entry: invalid value for attributeType gecos #0 (syntax 1.3.6.1.4.1.1466.115.121.1.26)
slapadd: could not parse entry (line=1)
_#################### 100.00% eta none elapsed none fast!
Closing DB…
看起來似乎是 gecos 的問題[@more@]在網路上搜尋了一下,似乎預設的 LDAP schema 在 gecos 的部分不支援中文
解決方法:
1. 先備份原檔 /etc/openldap/schema/nis.schema
# cp /etc/openldap/schema/nis.schema /etc/openldap/schema/nis.schema.bak
2. 修改設定檔 /etc/openldap/schema/nis.schema
# vim /etc/openldap/schema/nis.schema
把
attributetype ( 1.3.6.1.1.1.1.2 NAME ‘gecos’
DESC ‘The GECOS field; the common name’
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
修改成
attributetype ( 1.3.6.1.1.1.1.2 NAME ‘gecos’
DESC ‘The GECOS field; the common name’
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
3. 重新匯入
# slapadd -l /root/ldif/t850008.ldif
The first database does not allow slapadd; using the first available one (2)
_#################### 100.00% eta none elapsed none fast!
Closing DB…
4. 如果還是不行的話,就只要把 LDIF 中的 gecos 那一行刪除即可!