Samba with LDAPでドメインコントローラ
・PDCとBDCの冗長構成。
・移動プロファイルは無し。
・ドメインログオンしてもユーザホームドライブは見えないようにする。
・PDCのIPアドレスは192.168.1.1、BDCのIPアドレスは192.168.1.2
という想定で。
------------------- PDCの作業 -------------------
【/etc/hosts】
現状はこんな感じ↓
# rpm -qa | grep ldap
openldap-devel-2.3.27-8.el5_1.1
openldap-2.3.27-8.el5_1.1
nss_ldap-253-5.el5
python-ldap-2.2.0-2.1
nss_ldap-253-5.el5
openldap-devel-2.3.27-8.el5_1.1
openldap-2.3.27-8.el5_1.1
なので、openldap-serversとopenldap-clientsを追加。
# yum install openldap-servers
# yum install openldap-clients
【Samba用スキーマを準備】
# cp /usr/share/doc/samba-3.0.25b/LDAP/samba.schema /etc/openldap/schema/samba.schema
【/etc/openldap/slapd.conf】
# slappasswd
の結果をコピペ。
【DB_CONFIG】
# cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
【設定ファイル確認】
# slaptest -f /etc/openldap/slapd.conf
↓こんなエラーが出た。
bdb_db_open: DB_CONFIG for suffix dc=hogehoge,dc=local has changed.
Performing database recovery to activate new settings.
bdb_db_open: Recovery skipped in read-only mode. Run manual recovery if errors are encountered.
bdb_db_open: db_open(/var/lib/ldap/id2entry.bdb) failed: No such file or directory (2)
bdb(dc=hogehoge,dc=local): Unknown locker ID: 0
backend_startup_one: bi_db_open failed! (2)
slap_startup failed (test would succeed using the -u switch)
↓をして、
# chown -R ldap:ldap /var/lib/ldap
とりあえず起動・停止。
# /etc/init.d/ldap start
# /etc/init.d/ldap stop
これで次回以降はエラーが出なくなる。
# slaptest -f /etc/openldap/slapd.conf
【/etc/openldap/ldap.conf】
# cp -p /etc/ldap.conf /etc/ldap.conf.default
# rm /etc/ldap.conf
# ln -s /etc/openldap/ldap.conf /etc/ldap.conf
# authconfig-tui
LDAPを使用
LDAP認証を使用
サーバ: 127.0.0.1
ベースDN: dc=hogehoge,dc=local
必要なperlモジュールをインストール
cpan> install Crypt::SmbHash
cpan> install Unicode::MapUTF8
cpan> install Digest::SHA1
Unicode::MapUTF8は↓みたいなエラーが出た。
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/callback....ok
t/compat......ok
t/map8........dubious
Test returned status 0 (wstat 11, 0xb)
t/unistr......ok
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/map8.t 0 11 ?? ?? % ??
Failed 1/4 test scripts, 75.00% okay. 0/6 subtests failed, 100.00% okay.
make: *** [test_dynamic] エラー 255
/usr/bin/make test -- NOT OK
とりあえず強制インストール。
cpan> force install Unicode::MapUTF8
cpan> q
本体をインストール。
# mkdir /etc/smbldap-tools
# cd /usr/share/doc/samba-3.0.25b/LDAP/smbldap-tools-0.9.2
# chmod 755 smbldap-*
# chmod 755 smbldap_tools.pm
# cp smbldap-* /usr/sbin
# cp smbldap_tools.pm /usr/sbin
# cp smbldap.conf /etc/smbldap-tools
# cp smbldap_bind.conf /etc/smbldap-tools
# chmod 644 /etc/smbldap-tools/smbldap.conf
# chmod 600 /etc/smbldap-tools/smbldap_bind.conf
【/etc/smbldap-tools/smbldap.conf】
# net rpc getsid
の結果をコピペ。
【/etc/smbldap-tools/smbldap_bind.conf】
# smbldap-populate
↓Administrator(root)のパスワードを設定する。
Please provide a password for the domain root:
Changing UNIX and samba passwords for root
New password:
Retype new password:
【/etc/samba/smb.conf】
# mkdir -p samba/netlogon
# smbpasswd -W ← SambaがLDAPに接続するためのLDAP管理者(cn=Manager,dc=hogehoge,dc=local)のパスワード。
# smbldap-populateで入力したやつ(# smbldap-passwd rootで変えられる)はドメイン参加時とかに入力する
管理者のパスワード。その管理者のデフォルトがAdministratorじゃなくてrootになってる。
rootはOSアカウントのrootと紛らわしいから削除してAdministratorを作った。
# smbldap-populate -a Administrator -k 998 -m 512
# smbldap-userdel root
smblda-populdateのオプション↓
-a user 管理者ユーザ名を指定(デフォルトroot)
-k uidNumber 管理者ユーザのuid(デフォルト0)
-m gidNumber 管理者ユーザのgid(デフォルト0)
この場合[global]に追加で管理者ユーザの指定が必要↓
【/etc/hosts】
【/etc/openldap/slapd.conf】
# slappasswd
の結果をコピペ。
【/etc/hosts.allow】
【/etc/smbldap-tools/smbldap.conf】
# net rpc getsid
の結果をコピペ。
# scp root@192.168.1.1:/var/lib/ldap/* /var/lib/ldap/
# cd /var/lib/ldap
# chown ldap:ldap *
# cd /var/lib
# mkdir -p samba/netlogon
------------------- PDCの作業 -------------------
【/etc/smbldap-tools/smbldap.conf】
・移動プロファイルは無し。
・ドメインログオンしてもユーザホームドライブは見えないようにする。
・PDCのIPアドレスは192.168.1.1、BDCのIPアドレスは192.168.1.2
という想定で。
------------------- PDCの作業 -------------------
【/etc/hosts】
slave_host 192.168.1.2 ← 追加【OpenLDAPをインストール】
現状はこんな感じ↓
# rpm -qa | grep ldap
openldap-devel-2.3.27-8.el5_1.1
openldap-2.3.27-8.el5_1.1
nss_ldap-253-5.el5
python-ldap-2.2.0-2.1
nss_ldap-253-5.el5
openldap-devel-2.3.27-8.el5_1.1
openldap-2.3.27-8.el5_1.1
なので、openldap-serversとopenldap-clientsを追加。
# yum install openldap-servers
# yum install openldap-clients
【Samba用スキーマを準備】
# cp /usr/share/doc/samba-3.0.25b/LDAP/samba.schema /etc/openldap/schema/samba.schema
【/etc/openldap/slapd.conf】
include /etc/openldap/schema/core.schemarootpwは
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/samba.schema ← 追加
allow bind_v2
pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args
access to attrs=userPassword ← 追加
by dn="cn=Manager,dc=hogehoge,dc=local" write ← 追加
by anonymous auth ← 追加
by self write ← 追加
by * none ← 追加
access to attrs=sambaLMPassword,sambaNTPassword ← 追加
by dn="cn=Manager,dc=hogehoge,dc=local" write ← 追加
by self ← 追加
by * none ← 追加
access to * ← 追加
by dn="cn=Manager,dc=hogehoge,dc=local" write ← 追加
by self write ← 追加
by * read ← 追加
database bdb
suffix "dc=hogehoge,dc=local" ← 変更
rootdn "cn=Manager,dc=hogehoge,dc=local" ← 変更
rootpw {SSHA}xxxxxxxxxxxxxxxxxxxxxxx ← 追加
directory /var/lib/ldap
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub
replogfile /var/lib/ldap/openldap-master-replog ← 追加
replica host=slave_host:389 ← 追加
binddn="uid=Replica,ou=Users,dc=hogehoge,dc=local" ← 追加
bindmethod=simple ← 追加
credentials=domname_replica ← 追加(ユーザReplicaのパスワードのこと)
# slappasswd
の結果をコピペ。
【DB_CONFIG】
# cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
【設定ファイル確認】
# slaptest -f /etc/openldap/slapd.conf
↓こんなエラーが出た。
bdb_db_open: DB_CONFIG for suffix dc=hogehoge,dc=local has changed.
Performing database recovery to activate new settings.
bdb_db_open: Recovery skipped in read-only mode. Run manual recovery if errors are encountered.
bdb_db_open: db_open(/var/lib/ldap/id2entry.bdb) failed: No such file or directory (2)
bdb(dc=hogehoge,dc=local): Unknown locker ID: 0
backend_startup_one: bi_db_open failed! (2)
slap_startup failed (test would succeed using the -u switch)
↓をして、
# chown -R ldap:ldap /var/lib/ldap
とりあえず起動・停止。
# /etc/init.d/ldap start
# /etc/init.d/ldap stop
これで次回以降はエラーが出なくなる。
# slaptest -f /etc/openldap/slapd.conf
【/etc/openldap/ldap.conf】
# cp -p /etc/ldap.conf /etc/ldap.conf.default
# rm /etc/ldap.conf
# ln -s /etc/openldap/ldap.conf /etc/ldap.conf
# authconfig-tui
LDAPを使用
LDAP認証を使用
サーバ: 127.0.0.1
ベースDN: dc=hogehoge,dc=local
uri ldap://127.0.0.1/【smbldap-toolsをインストール】
base dc=hogehoge,dc=local
TLS_CACERTDIR /etc/openldap/cacerts
bind_policy soft ← 追加
ssl no
pam_password md5
必要なperlモジュールをインストール
cpan> install Crypt::SmbHash
cpan> install Unicode::MapUTF8
cpan> install Digest::SHA1
Unicode::MapUTF8は↓みたいなエラーが出た。
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/callback....ok
t/compat......ok
t/map8........dubious
Test returned status 0 (wstat 11, 0xb)
t/unistr......ok
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/map8.t 0 11 ?? ?? % ??
Failed 1/4 test scripts, 75.00% okay. 0/6 subtests failed, 100.00% okay.
make: *** [test_dynamic] エラー 255
/usr/bin/make test -- NOT OK
とりあえず強制インストール。
cpan> force install Unicode::MapUTF8
cpan> q
本体をインストール。
# mkdir /etc/smbldap-tools
# cd /usr/share/doc/samba-3.0.25b/LDAP/smbldap-tools-0.9.2
# chmod 755 smbldap-*
# chmod 755 smbldap_tools.pm
# cp smbldap-* /usr/sbin
# cp smbldap_tools.pm /usr/sbin
# cp smbldap.conf /etc/smbldap-tools
# cp smbldap_bind.conf /etc/smbldap-tools
# chmod 644 /etc/smbldap-tools/smbldap.conf
# chmod 600 /etc/smbldap-tools/smbldap_bind.conf
【/etc/smbldap-tools/smbldap.conf】
SID="S-1-5-21-306814683-3173466983-4196480098" ← 変更SIDは
sambaDomain="DOMNAME" ← 変更
slaveLDAP="127.0.0.1"
slavePort="389"
masterLDAP="127.0.0.1"
masterPort="389"
ldapTLS="0" ← 変更
# verify="require"
# cafile="/etc/opt/IDEALX/smbldap-tools/ca.pem" ← コメントアウト
# clientcert="/etc/opt/IDEALX/smbldap-tools/smbldap-tools.pem" ← コメントアウト
# clientkey="/etc/opt/IDEALX/smbldap-tools/smbldap-tools.key" ← コメントアウト
suffix="dc=hogehoge,dc=local"
usersdn="ou=Users,${suffix}"
computersdn="ou=Computers,${suffix}"
groupsdn="ou=Groups,${suffix}"
idmapdn="ou=Idmap,${suffix}"
sambaUnixIdPooldn="sambaDomainName=${sambaDomain},${suffix}" ← 変更
scope="sub"
hash_encrypt="SSHA"
crypt_salt_format="%s"
userLoginShell="/sbin/nologin" ← 変更
userHome="/home/%U"
userHomeDirectoryMode="700"
userGecos="System User"
defaultUserGid="513"
defaultComputerGid="515"
skeletonDir="/etc/skel"
defaultMaxPasswordAge="99999" ← 変更
userSmbHome="" ← 変更
userProfile="" ← 変更
userHomeDrive="" ← 変更
userScript="%U.cmd" ← 変更
mailDomain="" ← 変更
# net rpc getsid
の結果をコピペ。
【/etc/smbldap-tools/smbldap_bind.conf】
slaveDN="cn=Manager,dc=hogehoge,dc=local" ← 変更【/etc/hosts.allow】
slavePw="xxxxxxxx" ← 変更(平文でrootpw)
masterDN="cn=Manager,dc=hogehoge,dc=local" ← 変更
masterPw="xxxxxxxx" ← 変更(平文でrootpw)
slapd: 127.0.0.1 slave_host ← 追加【LDAPデータベースの初期化】
# smbldap-populate
↓Administrator(root)のパスワードを設定する。
Please provide a password for the domain root:
Changing UNIX and samba passwords for root
New password:
Retype new password:
【/etc/samba/smb.conf】
[global]# cd /var/lib
workgroup = DOMNAME ← 変更
server string = Samba Server Version %v
log file = /var/log/samba/%m.log ← 変更
max log size = 50 ← 変更
security = user
passdb backend = ldapsam:ldap://localhost:389 ← 変更
ldap admin dn = cn=Manager,dc=hogehoge,dc=local ← 追加
ldap suffix = dc=hogehoge,dc=local ← 追加
ldap user suffix = ou=Users ← 追加
ldap group suffix = ou=Groups ← 追加
ldap machine suffix = ou=Computers ← 追加
ldap delete dn = yes ← 追加
ldap passwd sync = yes ← 追加
smb ports = 139 ← 追加
logon path = ← 変更
logon home = ← 追加
logon drive = ← 追加
add machine script = /usr/sbin/smbldap-useradd -a -w "%u" ← 追加
add user script = /usr/sbin/smbldap-useradd -a -m -C "" -D "" -F "" "%u" ← 追加
delete user script = /usr/sbin/smbldap-userdel -r "%u" ← 追加
add group script = /usr/sbin/smbldap-groupadd -a -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" ← 追加
set primary group script = /usr/sbin/smbldap-usermod -g "%g" "%u" ← 追加
domain master = yes ← 変更
domain logons = yes ← 変更
local master = yes ← 変更
os level = 64 ← 変更
preferred master = yes ← 変更
wins support = no ← 変更
dns proxy = no ← 変更
load printers = no ← 変更
[homes]
comment = Home Directories
browseable = no
writable = yes
profile acls = yes ← 追加
[netlogon] ← 変更
comment = Network Logon Service ← 変更
path = /var/lib/samba/netlogon ← 変更
guest ok = yes ← 変更
writable = no ← 変更
share modes = no ← 変更
# mkdir -p samba/netlogon
# smbpasswd -W ← SambaがLDAPに接続するためのLDAP管理者(cn=Manager,dc=hogehoge,dc=local)のパスワード。
# smbldap-populateで入力したやつ(# smbldap-passwd rootで変えられる)はドメイン参加時とかに入力する
管理者のパスワード。その管理者のデフォルトがAdministratorじゃなくてrootになってる。
rootはOSアカウントのrootと紛らわしいから削除してAdministratorを作った。
# smbldap-populate -a Administrator -k 998 -m 512
# smbldap-userdel root
smblda-populdateのオプション↓
-a user 管理者ユーザ名を指定(デフォルトroot)
-k uidNumber 管理者ユーザのuid(デフォルト0)
-m gidNumber 管理者ユーザのgid(デフォルト0)
この場合[global]に追加で管理者ユーザの指定が必要↓
admin users = Administrator------------------- BDCの作業 -------------------
【/etc/hosts】
master_host 192.168.1.1 ← 追加インストールはPDCと同じ。以降はPDCと違うところを。
【/etc/openldap/slapd.conf】
access to attrs=userPasswordrootpwは
by dn="uid=Replica,ou=Users,dc=hogehoge,dc=local" write ← 変更
by anonymous auth
by self write
by * none
access to attrs=sambaLMPassword,sambaNTPassword
by dn="uid=Replica,ou=Users,dc=hogehoge,dc=local" write ← 変更
by self
by * none
access to *
by dn="uid=Replica,ou=Users,dc=hogehoge,dc=local" write ← 変更
by self write
by * read
rootpw {SSHA}xxxxxxxxxxxxxxxxxxxxxxx ← 追加
updatedn "uid=Replica,ou=Users,dc=hogehoge,dc=local" ← 追加
updateref ldap://master_host:389/ ← 追加
# slappasswd
の結果をコピペ。
【/etc/hosts.allow】
slapd: 127.0.0.1 master_host ← 追加【/etc/samba/smb.conf】
domain master = no ← 変更# smbpasswd -W
os level = 32 ← 変更
【/etc/smbldap-tools/smbldap.conf】
SID="S-1-5-21-306814683-3173466983-4196480098" ← 変更SIDは
masterLDAP="master_host" ← 変更
# net rpc getsid
の結果をコピペ。
# scp root@192.168.1.1:/var/lib/ldap/* /var/lib/ldap/
# cd /var/lib/ldap
# chown ldap:ldap *
# cd /var/lib
# mkdir -p samba/netlogon
------------------- PDCの作業 -------------------
【/etc/smbldap-tools/smbldap.conf】
slaveLDAP="slave_host" ← 変更
スポンサーサイト