LDAP+Linux+Sambaによる統合認証
前提条件
- DNSサフィックス example.com
- LDAP distinguishedName dc=example,dc=com
- カーネルはIPv6対応にしておく必要あり(slapd起動時に怒られる)
- Windowsドメイン名 EXAMPLE
インストール
- slapdがLDAPサーバ
- samba-docは/usr/share/doc/examle/LDAP内のLDAPスキーマを使用するために必要
# apt-get install samba samba-doc slapd
- slapdインストール時のdebconf設定は以下のとおり
- base dn : dc=example,dc=com
- cn=admin,dc=example,dc=com(LDAPの管理者)のパスワード : hogepass
- LDAP version 2は無効
schemaのコピー
# cp /usr/share/doc/samba-doc/example/LDAP/samba.schema /etc/ldap/schema/
/etc/ldap/slapd.confの編集
- LDAPのスキーマを追加
include /etc/ldap/schema/samba.schema
- 自分の設定が書きかえられるように以下のaccess *の項目に自身を追加
access to *
by dn="cn=admin,dc=example,dc=com" write
by self write
by * read
slapdの再起動
# /etc/init.d/slapd restart
クライアント側の設定
libnss-ldap, libpam-ldapのインストール
- libpam-ldapはPAM認証に用いられる
- libnss-ldapはホームディレクトリ、uid、gidをLDAPから取得するために使用される
# apt-get install libnss-ldap libpam-ldap
/etc/libnss-ldap.confの設定
アカウントの移行
ユーザ/グループの追加
- hogehoge.ldifファイルを以下の内容で作成する
dn: ou=People,dc=example,dc=com
ou: People
objectClass: organizationalUnit
objectClass: top
dn: uid=test,ou=People,dc=example,dc=com
uid: test
cn: test
objectClass: top
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
loginShell: /bin/bash
uidNumber: 1000
gidNumber: 1000
homeDirectory: /home/test
gecos: Test User
mail: test@example.com
sn: Test
givenName: User
dn: ou=Group,dc=example,dc=com
ou: Group
objectClass: organizationalUnit
objectClass: top
dn: cn=testgroup,ou=Group,dc=example,dc=com
cn: testgroup
objectClass: posixGroup
objectClass: top
gidNumber: 1000
memberUid: test
- testユーザのパスワードの変更
ldappasswd -W -x -D "cn=admin,dc=example,dc=com" -s newpasswd "uid=test,ou=People,dc=example,dc=com"
/etc/nsswitch.confの変更
passwd: files ldap
group: files ldap
/etc/libnss-ldap.confのパーミッションの変更
/etc/pam.d以下の変更
- /usr/share/doc/libpam-ldap/examples/pam.dを参考に、/etc/pam.d以下のファイルを編集する。
テスト
# id test
uid=1000(test) gid=1000(testgroup) groups=1000(testgroup)
と表示されれば成功。
Sambaの設定
- /etc/samba/smb.confに以下の行を追加/変更
[global]
....
passdb backend = ldapsam:ldap://localhost/
ldap suffix = dc=example,dc=com
ldap user suffix = ou=People
ldap machine suffix = ou=Computers
ldap admin dn = cn=admin,dc=example,dc=com
ldap delete dn = no
....
workgroup = EXAMPLE
domain master = yes
domain admin group = @root
domain logons = yes
logon script = %U.bat
wins support = yes
.....
cn=admin,dc=example,dc=comのパスワードをsecrets.tdbに登録
# smbpasswd -w hogepass
OU/ユーザの作成
- LDAPにOU=Users/OU=Computersを作成
- Sharedなフォルダへのアクセスをする場合には、nobodyユーザも作成する。
- LDAPにSambaの管理者(WindowsでのAdministratorに相当するユーザ)をuid=0,gid=0で作成
- 上記のユーザのhomedirは/nonexistent、shellは/bin/falseにする。
Sambaのドメインユーザの設定
- testユーザをドメインユーザにする場合、LDAPにsamba用属性を登録する。以下のように設定する
# smbpasswd -a test
- 同様の方法でSambaの管理者、nobodyユーザにもsamba用の属性を設定する。
コンピュータアカウントを登録
ドメインにコンピュータを参加させる
- WindowsXPではregeditで HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet?\Services\Netlogon\Parametersの
"requiresignorseal"をdword:00000000にする。
- 普通のドメインに参加させる方法で。
- 管理者ユーザはSambaの管理者を使用する。
Windowsの再起動後、ログオンしてみる
- EXAMPLEドメインにtestユーザでログオンする。
参考