CentOS 6.2 に OpenLDAP をインストールしてみた

CentOS 6 では,CentOS 5 までは存在していた OpenLDAP の設定ファイルの slapd.conf が無くなり,その代わりに,/etc/openldap/slapd.d/ 以下に設定ファイル(とディレクトリ)が格納されるようになっています,

/etc/openldap/slapd.d/ 以下のファイル

# ls -R  /etc/openldap/slapd.d/
/etc/openldap/slapd.d/:
cn=config  cn=config.ldif

/etc/openldap/slapd.d/cn=config:
cn=schema       olcDatabase={0}config.ldif     olcDatabase={1}monitor.ldif
cn=schema.ldif  olcDatabase={-1}frontend.ldif  olcDatabase={2}bdb.ldif

/etc/openldap/slapd.d/cn=config/cn=schema:
cn={0}corba.ldif        cn={2}cosine.ldif         cn={6}java.ldif
cn={10}ppolicy.ldif     cn={3}duaconf.ldif        cn={7}misc.ldif
cn={11}collective.ldif  cn={4}dyngroup.ldif       cn={8}nis.ldif
cn={1}core.ldif         cn={5}inetorgperson.ldif  cn={9}openldap.ldif

これらのファイルを編集していけばいいような気がしますが,Red Hat のドキュメントを読んでみると,/etc/openldap/slapd.d/ 以下の直接の編集は推奨されていません.

このままではどうしようもないので,一度,slapd.conf を作成して,作成した slapd.conf から /etc/openldap/slapd.d/ の移行を試みます.

slapd.conf は下記のディレクトリにあります.

/usr/share/openldap-servers/slapd.conf.obsolete

移行

slaptest を使用して移行します.

# cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/
# vim /etc/openldap/slapd.conf.obsolete

## 変更点 ###
# 116c116
# < suffix                "dc=my-domain,dc=com"
# ---
# > suffix                "dc=ldap,dc=example,dc=com"
# 118c118
# < rootdn                "cn=Manager,dc=my-domain,dc=com"
# ---
# > rootdn                "cn=Manager,dc=ldap,dc=example,dc=com"
# 123c123
# < # rootpw              {crypt}ijFYNcSNctBYg
# ---
# > rootpw                {SSHA}QeqmMk3atYqjqXGaURtgB0mXSxHnhcFL
##########

# rm -rf /etc/openldap/slapd.d/*
# slaptest -f /etc/openldap/slapd.conf.obsolete -F /etc/openldap/slapd.d
# chown -R ldap:ldap /etc/openldap/slapd.d/
# chown -R ldap:ldap /var/lib/ldap
# service slapd start
# service slapd status
slapd (pid  2462) is running...

無事動きました.

確認

適当にエントリの追加と検索をおこなって,変更した設定が反映されていることを確認します.

# ldapadd -x -D 'cn=Manager,dc=ldap,dc=example,dc=com' -W -f person.ldif 
Enter LDAP Password: 
adding new entry "dc=ldap,dc=example,dc=com"

adding new entry "ou=person,dc=ldap,dc=example,dc=com"

adding new entry "cn=hexa,ou=person,dc=ldap,dc=example,dc=com"

# ldapsearch -x -D 'cn=Manager,dc=ldap,dc=example,dc=com' -W -b 'dc=ldap,dc=example,dc=com' '(cn=hexa)'
Enter LDAP Password: 
# extended LDIF
#
# LDAPv3
# base <dc=ldap,dc=example,dc=com> with scope subtree
# filter: (cn=hexa)
# requesting: ALL
#

# hexa, person, ldap.example.com
dn: cn=hexa,ou=person,dc=ldap,dc=example,dc=com
objectClass: person
cn: hexa
sn: blog
userPassword:: e1NTSEF9Tm9rQnBiYXc2MXpwRTRBUVRuQXo1cmxRM0lIT2hvbXE=

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

ldapadd で追加して,ldapsearch でその内容が確認できたので,設定は反映されているようです.

参考にしたページ