第3回、
第2回で説明したように、
今回は、
なお、
パッケージのインストールと設定
各ディストリビューションで必要なパッケージの名称を表1に示します。まずは、
CentOS | nss_ |
---|---|
Ubuntu | libnss-ldap |
Ubuntuの場合、
CentOS 7.3における設定
CentOS 7.
# authconfig --enableldap --enableldapauth --ldapserver=172.16.2.10 --ldapbasedn=DC=ADDOM11,DC=AD,DC=LOCAL --update
具体的には/etc/
前述したとおり、
# The distinguished name of the search base.
base DC=ADDOM11,DC=AD,DC=LOCAL
# The distinguished name to bind to the server with.
# Optional: default is to bind anonymously.
#binddn cn=proxyuser,dc=example,dc=com
binddn cn=ldap proxy,cn=users,dc=addom11,dc=ad,dc=local ←ADを参照する際に用いるユーザのDN
# The credentials to bind with.
# Optional: default is no credentials.
# Note that if you set a bindpw you should check the permissions of this file.
#bindpw secret
bindpw (上記ユーザのパスワード)
なお、
さらに、
# Mappings for Active Directory
pagesize 1000
referrals off
idle_timelimit 800
filter passwd (&(objectClass=user)(!(objectClass=computer))(uidNumber=*)(unixHomeDirectory=*))
map passwd uid sAMAccountName
map passwd homeDirectory unixHomeDirectory
map passwd gecos displayName
filter shadow (&(objectClass=user)(!(objectClass=computer))(uidNumber=*)(unixHomeDirectory=*))
map shadow uid sAMAccountName
map shadow shadowLastChange pwdLastSet
filter group (objectClass=group)
これでCentOSでの設定は完了です。
Ubuntu 16.04における設定
Ubuntuの場合はnslcdを使わないため、
……
# The distinguished name of the search base.
#base dc=example,dc=net
base dc=ADDOM11,dc=AD,dc=LOCAL
……
# Another way to specify your LDAP server is to provide an
#uri ldapi:///
uri ldap://172.16.2.10/ ←ADサーバのIPアドレスを指定
……
# The distinguished name to bind to the server with.
# Optional: default is to bind anonymously.
binddn cn=ldap proxy,cn=users,dc=ADDOM11,dc=AD,dc=LOCAL ← LDAPサーバに検索を行うときに用いるユーザのDN
# The credentials to bind with.
# Optional: default is no credential.
bindpw (上記ユーザのパスワード)
……
# RFC 2307 (AD) mappings ←これ以下の行について、コメントを外す
nss_map_objectclass posixAccount user
nss_map_objectclass shadowAccount user
nss_map_attribute uid sAMAccountName
nss_map_attribute homeDirectory unixHomeDirectory
nss_map_attribute shadowLastChange pwdLastSet
nss_map_objectclass posixGroup group
nss_map_attribute uniqueMember member
pam_login_attribute sAMAccountName
pam_filter objectclass=User
pam_password ad
binddnやbindpwといったキーワードの意味はCentOSと同様です。
前述の通り、
引き続き、
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat ldap
group: compat ldap
shadow: compat ldap
(以下略)
これでUbuntuでの設定は完了です。
Active Directoryでの設定
引き続き、
ADアクセス用ユーザの作成
まずは冒頭で説明したADアクセス用ユーザを作成します。Usersコンテナの下に図1のようにしてフルネーム

各ユーザに対するUNIX属性の追加
ここまでの設定を行った状態でgetent passwdやgetent groupを行っても、
Oct 9 17:23:31 centos73-01 nslcd[2094]: [495cff] <group(all)> CN=Domain Users,CN=Users,DC=ADDOM11,DC=AD,DC=LOCAL: gidNumber: missing
Oct 9 17:23:31 centos73-01 nslcd[2094]: [495cff] <group(all)> CN=Domain Guests,CN=Users,DC=ADDOM11,DC=AD,DC=LOCAL: gidNumber: missing
これは、
Windows Server 2012 R2までのWindowsサーバでは、

そのため、

ユーザについては、
さらにLinuxサーバへのログオンを可能とするためには、
属性名 | 意味 | 設定例 | 必須or任意 |
---|---|---|---|
gidNumber | 所属グループのGID | 100 | 必須 |
loginShell | シェル | /bin/ | 任意 |
uidNumber | UID | 10001 | 必須 |
unixHomeDirectory | ホームディレクトリのパス | /home/ | 任意 |
※ CentOSでのデフォルト設定では必須
グループの場合はgidNumber属性の設定のみが必須となります。
ここまでの設定を行うことで、
$ getent passwd ldap01 ldap01:*:10011:100:ldap 01.:/home/ldap01:/bin/bash $ id ldap01 uid=10011(ldap01) gid=100(users) groups=100(users)
認証連携の動作確認
ここまでの設定を適切に行うことで、
$ ssh ubuntu1604-01 -l ldap01 Password: Last login: Mon Oct 9 18:27:08 2017 Could not chdir to home directory /home/ldap01: No such file or directory
ホームディレクトリの自動作成
上記では指定したホームディレクトリを作成していないためエラーが発生していますが、
# authconfig --enablemkhomedir --update
Ubuntuの場合は、
LDAP認証の通信と問題点
ここでは、

大量のLDAPのやりとりが行われていますが、
実は、
なお、
$ passwd Changing password for user ldap01. (current) LDAP Password: New password: Retype new password: password change failed: Protocol error passwd: Authentication token manipulation error
これは、

パケット528以降でパスワード変更の通信が行われています。ここではパケットの詳細を示していませんが、
ADで匿名認証を有効化する
冒頭で紹介したように、

詳細についてはMicrosoft サポートの
匿名認証を許可したら、
ここではLDAPという名前のOUに適切な設定を行う際の例を説明します。

さらに
これで、
まとめ
今回は、
次回以降ではこれを解決する対策について紹介していきます。