Samba ファイルサーバの LDAP 認証でのトラブル (2011/06/26)

Linux をインストールしたデスクトップPCの大容量ハードディスクを Windows からも利用できるようにするため,Samba によるファイルサーバを構築しました.Samba ファイルサーバは,Samba/LDAPサーバの構築で構築した Primary Domain Controller (PDC) のドメインに入ることを想定します.PDC の LDAP データベースを利用しますが,簡単に構築できると予想していたのに反して,LDAP 認証ができないというトラブルが発生しました.今回は,そのトラブルの解消について記載します.

/etc/samba/smb.conf は次のように作成しました.ここでは,仮に,Samba ドメイン名を EXAMPLE_COM,Netbios 名を client,LDAP サーバの IP アドレスを 192.168.0.2,ベース DN を dc=example,dc=com,ユーザのグループを user,マシンのグループを computer としています.ここで,共有ディレクトリにしたいのが,/local/home で,Windows 側からは,local home と見えるようにしています.

[global]
#
# Character settings
#
dos charset = CP932
unix charset = UTF-8
display charset = UTF-8
#
# Browsing/Identification
#
workgroup = EXAMPLE_COM
netbios name = client
server string = %h
local master = yes
wins support = no
dns proxy = yes
time server = no
#
# PDC settings
#
domain logons = no
domain master = no
os level = 20
preferred master = auto
server schannel = auto
#
# Authentication
#
security = user
encrypt passwords = true
passdb backend = ldapsam:"ldap://192.168.0.2"
obey pam restrictions = yes
unix password sync = yes
pam password change = yes
passwd program = /usr/bin/passwd %u
passwd chat = *New*password* %n\n *Re*new*password* %n\n *success*
username map = /etc/samba/smbusers
#
# LDAP settings
#
ldap ssl = off
ldap passwd sync = yes
ldap delete dn = yes
ldap admin dn = cn=Manager,dc=example,dc=com
ldap suffix = dc=example,dc=com
ldap user suffix = ou=Users
ldap group suffix = ou=Groups
ldap machine suffix = ou=Computers
#
# UNIX user/group management
#
add user script = /usr/sbin/smbldap-useradd -g user -m '%u'
rename user script = /usr/sbin/smbldap-usermod -r '%unew' '%uold'
delete user script = /usr/sbin/smbldap-userdel '%u'
set primary group script = /usr/sbin/smbldap-usermod -g '%g' '%u'
add group script = /usr/sbin/smbldap-groupadd -p '%g'
delete group script = /usr/sbin/smbldap-groupdel '%g'
add user to group script = /usr/sbin/smbldap-groupmod -m '%u' '%g'
delete user from group script = /usr/sbin/smbldap-groupmod -x '%u' '%g'
add machine script = /usr/sbin/smbldap-useradd -g computer -w '%u'
#
# Logon settings
#
logon home = \\%L\%U
logon path =
logon script =
logon drive = z:
#
# Access control
#
hosts allow = 192.168.0.0/255.255.255.0
#
# Debugging/Accounting
#
log level = 2
log file = /var/log/samba/log.%m
max log size = 5000
syslog only = no
syslog = 0
#
# Printing
#
load printers = yes
printing = cups
printcap name = cups
printer admin = @admin
#
# Misc
#
socket options = TCP_NODELAY
dos filetime resolution = yes
client ntlmv2 auth = yes

[homes]
comment = %U's Home Directories
read only = no
browseable = no
create mask = 0644
directory mask = 0755
hide dot files = yes

[printers]
comment = All Printers
path = /var/spool/samba
guest only = no
printable = yes
browseable = no

[local home]
comment = Local Directory
path = /local/home
read only = no
guest ok = yes
create mask = 0644
directory mask = 0755
hide dot files = yes

上記の設定が終了後,nmbd, smbd を再起動しましたが,Windows からは認証の問題からアクセスできませんでした./var/log/samba/log.smbd を見ると,

[2011/06/21 18:07:27.954089,  1] lib/smbldap.c:1330(another_ldap_try)
  Connection to LDAP server failed for the 1 try!
[2011/06/21 18:07:28.954287,  0] passdb/secrets.c:806(fetch_ldap_pw)
  fetch_ldap_pw: neither ldap secret retrieved!
[2011/06/21 18:07:28.954371,  0] lib/smbldap.c:1107(smbldap_connect_system)
  ldap_connect_system: Failed to retrieve password from secrets.tdb
というエラーが出されていました.secrets.tdb はそれぞれのローカルマシンで作成されるもので,そこに,LDAP のパスワードを登録しないと LDAP サーバにて認証が通りません.そこで,secrets.tdb に LDAP の管理者パスワードを登録する必要があります.次のコマンドを実行します.

root@client# smbpasswd -W
Setting stored password for "cn=manager,dc=example,dc=com" in secrets.tdb
New SMB password: (LDAPの管理用パスワードを入力)
Retype new SMB password: (LDAPの管理用パスワードをもう一度入力)

上記のパスワードの登録は,当初,Samba PDC サーバ側でしていれば十分かと勘違いしていましたが,LDAP 認証を必要とするすべての Samba サーバで実行する必要がある点に注意して下さい.


梅原 大祐 / UMEHARA Daisuke umehara@kit.ac.jp
Last modified: 2020/05/01 15:37
Total Access Count