dpkg-reconfigure slapd
を使えば簡単に LDAP データベースを再設定することが可能です。
falcot.com
」。
dpkg-reconfigure slapd
を実行する場合など、空っぽのデータベースをから設定を再開したい場合、答えは「yes」です。
$
ldapsearch -x -b dc=falcot,dc=com
# extended LDIF # # LDAPv3 # base <dc=falcot,dc=com> with scope sub # filter: (objectclass=*) # requesting: ALL # # falcot.com dn: dc=falcot,dc=com objectClass: top objectClass: dcObject objectClass: organization o: Falcot Corp dc: falcot # admin, falcot.com dn: cn=admin,dc=falcot,dc=com objectClass: simpleSecurityObject objectClass: organizationalRole cn: admin description: LDAP administrator # search result search: 2 result: 0 Success # numResponses: 3 # numEntries: 2
/etc/passwd
、/etc/group
、/etc/services
、/etc/hosts
など) からのデータを展開するための一連のスクリプトが含まれます。スクリプトを使ってデータを変換し、LDAP データベースに投入します。
/etc/migrationtools/migrate_common.ph
を編集してください; IGNORE_UID_BELOW
と IGNORE_GID_BELOW
オプションを編集して (コメント解除するだけで十分です)、DEFAULT_MAIL_DOMAIN
/DEFAULT_BASE
を更新する必要があります。
migrate_all_online.sh
コマンドを使って行います、以下の通りです:
#
cd /usr/share/migrationtools
#
LDAPADD="/usr/bin/ldapadd -c" ETC_ALIASES=/dev/null ./migrate_all_online.sh
migrate_all_online.sh
から LDAP データベースに移行するデータの種類に関する数個の質問を尋ねられます。表 11.1には Falcot の使用例で使った回答がまとめられています。
表11.1 migrate_all_online.sh
スクリプトからの質問に対する回答
質問 | 回答 |
---|---|
X.500 命名コンテキスト | dc=falcot,dc=com |
LDAP サーバホスト名 | localhost |
管理者識別名 | cn=admin,dc=falcot,dc=com |
認証情報の紐付け | 管理用パスワード |
DUAConfigProfile を作成 | no |
/etc/aliases
ファイルの移行を行いませんでした。なぜなら、Debian の提供する標準的なスキーマには、このスクリプトが電子メールアドレスを表現するために使う構造が含まれないからです。このデータをディレクトリに統合したい場合、標準的なスキーマに /etc/ldap/schema/misc.schema
ファイルを追加するべきです。
ldapadd
コマンドの -c
オプションの利用について触れておきます; このオプションはエラーが起きた場合に処理を停止しないように要求するものです。このオプションを使うことが必要です。なぜなら、/etc/services
を変換する際に、無視しても問題無い数個のエラーが起きる事が多いからです。
表11.2 libnss-ldap パッケージの設定
質問 | 回答 |
---|---|
LDAP サーバの Uniform Resource Identifier | ldap://ldap.falcot.com |
検索起点の識別名 | dc=falcot,dc=com |
使用する LDAP バージョン | 3 |
LDAP データベースはログインを必要としますか? | no |
root 用の特別な LDAP 権限 | yes |
所有者だけが設定ファイルを読み取り可能/書き込み可能な状態にする | no |
root 用 LDAP アカウント | cn=admin,dc=falcot,dc=com |
LDAP root アカウントパスワード | 管理用パスワード |
/etc/nsswitch.conf
ファイルを変更し、最近インストールした ldap
モジュールを使うように NSS を設定する必要があります。
例11.30 /etc/nsswitch.conf
ファイル
# /etc/nsswitch.conf # # Example configuration of GNU Name Service Switch functionality. # If you have the `glibc-doc' and `info' packages installed, try: # `info libc "Name Service Switch"' for information about this file. passwd: ldap compat group: ldap compat shadow: ldap compat hosts: files dns ldap networks: ldap files protocols: ldap db files services: ldap db files ethers: ldap db files rpc: ldap db files netgroup: ldap files
ldap
モジュールは他のモジュールよりも前に書き込みます。こうすることで、先に使われるようになります。注目すべき除外例が hosts
サービスです。なぜなら、LDAP サーバに接続するには (ldap.falcot.com
の名前解決を行うためには) 先に DNS を調べる必要があるからですhosts
サービスで最初 ldap
モジュールを使うようにすると、LDAP サーバにホスト名を問い合わせる事になります; 名前解決を担当する LDAP サーバに接続するには LDAP サーバの名前解決が必要なので、無限ループすることになります。
files
モジュールの使うローカルファイルを軽視する場合)、以下の構文を使ってサービスを設定します:
service: ldap [NOTFOUND=return] files
.
/etc/environment
と /etc/default/locale
参照) を説明します。ここで説明した PAM 設定で、アプリケーションが LDAP データベースに向けて要求された認証を実行することを可能にします。
表11.3 libpam-ldap の設定
質問 | 回答 |
---|---|
LDAP 管理者がローカルの root の如く振る舞うことを許可しますか? | はい。こうすることで、通常の passwd コマンドから LDAP データベースに保存されているパスワードを変更する事が可能になります。 |
LDAP データベースはログインを要求しますか? | no |
root 用 LDAP アカウント | cn=admin,dc=falcot,dc=com |
LDAP root アカウントパスワード | LDAP データベース管理用パスワード |
パスワードに対して用いるローカル暗号化アルゴリズム | crypt |
/etc/pam.d/common-auth
、/etc/pam.d/common-password
、/etc/pam.d/common-account
ファイルで定義されたデフォルトの PAM 設定が適用されます。このメカニズムは専用の pam-auth-update
ツール (libpam-runtime パッケージから提供される) を使います。pam-auth-update
ツールは PAM モジュールを有効化または無効化したい管理者によって実行される場合もあります。
./build-server-key ldap.falcot.com
を実行すると、数個の一般的な (場所、組織名、などに関する) 質問を尋ねられます。「common name」に対する回答は必ず LDAP サーバの完全修飾ホスト名にしてください; 我々の場合 ldap.falcot.com
です。
keys/ldap.falcot.com.crt
ファイルに保存します; 対応する秘密鍵は keys/ldap.falcot.com.key
に保存されます。
openldap
ユーザ権限で実行されている LDAP サーバが秘密鍵を読み込み可能であることを保証しなければいけません:
#adduser openldap ssl-cert
Adding user `openldap' to group `ssl-cert' ... Adding user openldap to group ssl-cert Done. #mv keys/ldap.falcot.com.key /etc/ssl/private/ldap.falcot.com.key
#chown root:ssl-cert /etc/ssl/private/ldap.falcot.com.key
#chmod 0640 /etc/ssl/private/ldap.falcot.com.key
#mv newcert.pem /etc/ssl/certs/ldap.falcot.com.pem
slapd
デーモンにこれらの鍵を暗号化に使うように伝えることも必要です。LDAP サーバ設定は動的に管理されます: 設定は cn=config
オブジェクト階層に対する通常の LDAP 操作によって更新され、サーバは設定を永続的なものにするために /etc/ldap/slapd.d
をリアルタイムで更新します。このため、ldapmodify
が設定を更新する適切なツールです:
例11.31 暗号化用の slapd
の設定
#cat >ssl.ldif <<END dn: cn=config changetype: modify add: olcTLSCertificateFile olcTLSCertificateFile: /etc/ssl/certs/ldap.falcot.com.pem - add: olcTLSCertificateKeyFile olcTLSCertificateKeyFile: /etc/ssl/private/ldap.falcot.com.key - END
#ldapmodify -Y EXTERNAL -H ldapi:/// -f ssl.ldif
SASL/EXTERNAL authentication started SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth SASL SSF: 0 modifying entry "cn=config"
/etc/default/slapd
ファイル内の SLAPD_SERVICES
変数を変更することです。我々は大事を取って、安全対策されていない LDAP を無効化します。
例11.32 /etc/default/slapd
ファイル
# Default location of the slapd.conf file or slapd.d cn=config directory. If # empty, use the compiled-in default (/etc/ldap/slapd.d with a fallback to # /etc/ldap/slapd.conf). SLAPD_CONF= # System account to run the slapd server under. If empty the server # will run as root. SLAPD_USER="openldap" # System group to run the slapd server under. If empty the server will # run in the primary group of its user. SLAPD_GROUP="openldap" # Path to the pid file of the slapd server. If not set the init.d script # will try to figure it out from $SLAPD_CONF (/etc/ldap/slapd.conf by # default) SLAPD_PIDFILE= # slapd normally serves ldap only on all TCP-ports 389. slapd can also # service requests on TCP-port 636 (ldaps) and requests via unix # sockets. # Example usage: # SLAPD_SERVICES="ldap://127.0.0.1:389/ ldaps:/// ldapi:///" SLAPD_SERVICES="ldaps:/// ldapi:///" # If SLAPD_NO_START is set, the init script will not start or restart # slapd (but stop will still work). Uncomment this if you are # starting slapd via some other means or if you don't want slapd normally # started at boot. #SLAPD_NO_START=1 # If SLAPD_SENTINEL_FILE is set to path to a file and that file exists, # the init script will not start or restart slapd (but stop will still # work). Use this for temporarily disabling startup of slapd (when doing # maintenance, for example, or through a configuration management system) # when you don't want to edit a configuration file. SLAPD_SENTINEL_FILE=/etc/ldap/noslapd # For Kerberos authentication (via SASL), slapd by default uses the system # keytab file (/etc/krb5.keytab). To use a different keytab file, # uncomment this line and change the path. #export KRB5_KTNAME=/etc/krb5.keytab # Additional options to pass to slapd SLAPD_OPTIONS=""
ldaps://
URI を使うようにする作業が必要です。
/usr/local/share/ca-certificates
に配置して、update-ca-certificates
を実行します。
#cp keys/ca.crt /usr/local/share/ca-certificates/falcot.crt
#update-ca-certificates
Updating certificates in /etc/ssl/certs... 1 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d.... Adding debian:falcot.pem done. done.
/etc/ldap/ldap.conf
を編集すれば変更することが可能です。こうすることで、タイプする量を激減させることが可能です。
例11.33 /etc/ldap/ldap.conf
ファイル
# # LDAP Defaults # # See ldap.conf(5) for details # This file should be world readable but not world writable. BASE dc=falcot,dc=com URI ldaps://ldap.falcot.com #SIZELIMIT 12 #TIMELIMIT 15 #DEREF never # TLS certificates (needed for GnuTLS) TLS_CACERT /etc/ssl/certs/ca-certificates.crt