參見
yum install openldap-servers openldap-clients nss-pam-ldapd
** 單純 client 只要 openldap-clients nss-pam-ldapd 就可以了
cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
vi /etc/openldap/ldap.conf
加入URI ldap://127.0.0.1
BASE o=XXX, c=XXX
cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
slappasswd
New password:
Re-enter new password:
{SSHA}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
vi /etc/openldap/slapd.conf
:%s/dc=my-domain/dc=mycompany/g
rootpw {SSHA}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
vi /root/root.ldif
rm -rf /etc/openldap/slapd.d/*
slapadd -n 2 -l /root/root.ldif
slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
chown -R ldap:ldap /var/lib/ldap
chown -R ldap:ldap /etc/openldap/slapd.d
chkconfig slapd on
service slapd start
日後若變更 slapd.conf 內容, 則:
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 restart
***** CENTOS6 要求 LDAP 要 TLS
vim /etc/sysconfig/authconfi
FORCELEGACY=yes
***** geocs 無法使用中文
主因是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 )
就可以了。依照RFC 2252原本的gecos定義1.3.6.1.4.1.1466.115.121.1.26是IA5 String,改成1.3.6.1.4.1.1466.115.121.1.15的Directory String。
RFC中6.10. Directory String提到Directory String是使用UTF-8編碼的字串。但是6.15. IA5 String指出IA5 String只能使用字串本身的編碼,也就是ASCII 0-127。可參考維基上的IA5STRING。
Ref
*****
DB_KEYEXIST: Key/data pair already exists (-30995)
rm -rf /var/lib/ldap/*
warning - no DB_CONFIG file found in directory /var/lib/ldap: (2).
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
*****
(1) Geographic naming,例:suffix "o=組織名稱, c=國家名稱簡寫"
(2) Domain-based Naming,例:suffix "dc=組織名稱(簡稱), dc=網路域名"
*****
(1) Geographic naming,例:suffix "o=組織名稱, c=國家名稱簡寫"
(2) Domain-based Naming,例:suffix "dc=組織名稱(簡稱), dc=網路域名"
RFC 2253 LDAPv3 Distinguished Names
dn: distinguished name
cn: common name
l: locality name
st: state or provinceName
o: organizationalName
ou: organizationalUnitName
c: countryName
street: streetAddress
dc: domain component
uid: user id
cn: common name
l: locality name
st: state or provinceName
o: organizationalName
ou: organizationalUnitName
c: countryName
street: streetAddress
dc: domain component
uid: user id