モジュールのインストール
yum -y install openldap-servers openldap-clients
|
パスワード
# openssl passwd
Password:
Verifying - Password:
4e3wiBPp/SJGk
|
/etc/openldap/slapd.d の初期化
# cd /etc/openldap
# cp -pR slapd.d slapd.d.org
# rm -fr slapd.d/*
|
DBの準備
# cd /var/lib/ldap
# cp -p /usr/share/openldap-servers/DB_CONFIG.example DB_CONFIG
|
/etc/openl/etqdap/slapd.conf の作成
# vi /etc/openldap/slapd.conf
・
・
・
database config
rootdn "cn=config"
rootpw {crypt}4e3wiBPp/SJGk
access to attrs=userPassword
by self write
by anonymous auth
by * none
access to *
by self write
by * read
・
・
・
database bdb
#suffix "dc=my-domain,dc=com"
suffix "dc=example,dc=com"
checkpoint 1024 15
#rootdn "cn=Manager,dc=my-domain,dc=com"
rootdn "cn=Manager,dc=example,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoided. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
#rootpw secret
rootpw {crypt}4e3wiBPp/SJGk
・
・
・
|
/etc/openldap/slapd.conf のチェック
# slaptest -u -f /etc/openldap/slapd.conf -v
/etc/openldap/slapd.d の更新
# 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
|
cn=configへアクセスするためのパスワード設定
OpenLDAPの設定が格納される識別名cn=configへアクセスするためのパスワードが未定義のため、デフォルトだとアクセスが拒否される。
そのため、パスワードを設定する。
# slappasswd -s secret
{SSHA}lNAQeitRMqr/ZNFFi+C5lIsfeInrz3jX
# vi /etc/openldap/slapd.d/cn=config/olcDatabase={0}config.ldif
以下を追記
olcRootPW: {SSHA}lNAQeitRMqr/ZNFFi+C5lIsfeInrz3jX
|
LDAP サーバーの起動
# /etc/init.d/slapd start
|
init.ldifの編集
vi /etc/openldap/init.ldif
dn: dc=example,dc=com
objectClass: organization
objectClass: dcObject
o: example.com
dc: example
dn: cn=Manager,dc=example,dc=com
objectClass: organizationalRole
cn: Manager
|
init.ldifの適応
ldapadd -x -D "cn=Manager,dc=example,dc=com" -W -f ./init.ldif
|
ldap.confの編集
# vim ldap.conf
#BASE dc=example,dc=com
↓※コメントアウトを外す
BASE dc=example,dc=com
|
LDAP サーバーの再起動
# /etc/init.d/slapd restart
|
LDAP サーバーへのアクセスの確認
# ldapsearch -x -D "cn=Manager,dc=example,dc=com" -W
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
↑これにかわった。。。。
この段階ではこうなる。
理由はクライアントの認証モジュールを入れていないため。
導入後、接続出きることを確認。
# ldapsearch -x -D "cn=Manager,dc=example,dc=com" -W
# extended LDIF
#
# LDAPv3
# base <dc=example,dc=com> (default) with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#
# example.com
dn: dc=example,dc=com
objectClass: organization
objectClass: dcObject
o: example.com
dc: example
# Manager, example.com
dn: cn=Manager,dc=example,dc=com
objectClass: organizationalRole
cn: Manager
# ldapsearch -x -LLL -D "cn=config" -W -b "cn=config" '(objectClass=*)'
※設定が出力されることを確認
|