#contents
*インストール [#w3163478]

 # yum install samba samba-client samba-common samba-swat

*SWATを動作させる [#q1fe8890]
ブラウザから管理できるようにSWATを動作させます

 # vi /etc/hosts.allow
 
 swat: 192.168.0.1
 
 # vi /etc/xinetd.d/swat
 
 service swat
 {
         port            = 901
         socket_type     = stream
         wait            = no
         only_from       = 127.0.0.1 192.168.0.1
         user            = root
         server          = /usr/sbin/swat
         log_on_failure  += USERID
         disable         = yes
 }
 
 # /etc/rc.d/init.d/xinetd restart
http://www.example.com:901/ でアクセス可能~
ただしSWAT経由で編集するとコメントが削除されたり、並び順が変わったりするので注意が必要

*認証にLDAPを使用する場合 [#id67a3a6]
事前にこちらで[[ユーザーを一元管理 LDAP]]OpenLDAPを利用できるようにしておく

**OpenLDAPの追加設定 [#ob41a5aa]

 # cp /usr/share/doc/samba-3.0.23c/LDAP/samba.schema /etc/openldap/schema/
 # vi /etc/openldap/slapd.conf
 
 include         /etc/openldap/schema/samba.schema
 
 lastmod on
 
 # UNIX password access
 access to attrs=userPassword
     by dn="cn=Manager,dc=example,dc=com" write
     by anonymous auth
     by self write
     by * none
 
 # Samba password access
 access to attrs=sambaLMPassword,sambaNTPassword
     by dn="cn=Manager,dc=example,dc=com" write
     by self write
     by * none
 
 # default access
 access to *
     by dn="cn=Manager,dc=example,dc=com" write
     by * read

**smbldap-toolsのインストール [#rbfff3d5]
まずは必要なPerlモジュールをインストール~
-Net::LDAP
-Digest::SHA1
-[[Jcode:http://dag.wieers.com/rpm/packages/perl-Jcode/]]
-[[Unicode::Map:http://dag.wieers.com/rpm/packages/perl-Unicode-Map/]]
-[[Unicode::String:http://dag.wieers.com/rpm/packages/perl-Unicode-String/]]
-[[Unicode::Map8:http://dag.wieers.com/rpm/packages/perl-Unicode-Map8/]]
-[[Unicode::MapUTF8:http://dag.wieers.com/rpm/packages/perl-Unicode-MapUTF8/]]
-[[Crypt::SmbHash:http://dag.wieers.com/rpm/packages/perl-Crypt-SmbHash/]]
 # yum install perl-Digest-SHA1 perl-LDAP
 # rpm -ivh perl-Jcode-2.06-1.el5.rf.noarch.rpm
 # rpm -ivh perl-Unicode-Map-0.112-1.el5.rf.i386.rpm
 # rpm -ivh perl-Unicode-String-2.09-1.2.el5.rf.i386.rpm
 # rpm -ivh perl-Unicode-Map8-0.12-1.el5.rf.i386.rpm
 # rpm -ivh perl-Unicode-MapUTF8-1.11-1.2.el5.rf.noarch.rpm
 # rpm -ivh perl-Crypt-SmbHash-0.12-1.2.el5.rf.noarch.rpm

ここからダウンロード~
http://sourceforge.net/projects/smbldap-tools/
 # rpm -ivh smbldap-tools-0.9.2-1a.noarch.rpm
 # mkdir -p /usr/local/samba/bin
 # mv /opt/IDEALX/sbin/* /usr/local/samba/bin/
 # rm -fr /opt/IDEALX
 # mkdir -p mkdir /usr/local/samba/lib/netlogon
 # mv /etc/opt/IDEALX/smbldap-tools/smbldap* /usr/local/samba/lib/
 # rm -fr /etc/opt/IDEALX/
 # vi /usr/local/samba/bin/smbldap_tools.pm
 
 #       $smbldap_conf="/etc/opt/IDEALX/smbldap-tools/smbldap.conf";
         $smbldap_conf="/usr/local/samba/lib/smbldap.conf";
 
 #       $smbldap_bind_conf="/etc/opt/IDEALX/smbldap-tools/smbldap_bind.conf";
         $smbldap_bind_conf="/usr/local/samba/lib/smbldap_bind.conf";

SIDを取得し、smbldap.confに使用
 # net getlocalsid
 # vi /usr/local/samba/lib/smbldap.conf
 
 SID="S-1-5-21-639836666-1375979563-1343089817"
 #sambaDomain="IDEALX-NT"
 slaveLDAP="127.0.0.1"
 slavePort="389"
 masterLDAP="localhost"
 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=example,dc=com"
 usersdn="ou=Users,${suffix}"
 computersdn="ou=Computers,${suffix}"
 groupsdn="ou=Groups,${suffix}"
 idmapdn="ou=Idmap,${suffix}"
 sambaUnixIdPooldn="cn=SambaUnixId,${suffix}"
 scope="sub"
 hash_encrypt="SSHA"
 crypt_salt_format="%s"
 userLoginShell="/bin/bash"
 userHome="/home/%U"
 userHomeDirectoryMode="700"
 userGecos="System User"
 defaultUserGid="513"
 defaultComputerGid="515"
 skeletonDir="/etc/skel"
 #defaultMaxPasswordAge="45"
 userSmbHome="\\PDC\%U"
 userProfile="\\PDC\profiles\%U"
 userHomeDrive="H:"
 userScript="%U.cmd"
 mailDomain="example.com"
 with_smbpasswd="0"
 smbpasswd="/usr/bin/smbpasswd"
 with_slappasswd="0"
 slappasswd="/usr/sbin/slappasswd"
 
 # vi /usr/local/samba/lib/smbldap_bind.conf
 
 slaveDN="cn=Manager,dc=example,dc=com"
 slavePw="secret"
 masterDN="cn=Manager,dc=example,dc=com"
 masterPw="secret"

rootで実行できるようにパスを通す
 # vi /root/.bashrc
 
 PATH="$PATH":/usr/local/samba/bin
 
 # source ~/.bashrc

**UNIXユーザーの情報をLDAPに格納する設定 [#x6780373]

 # authconfig
#ref(authconfig.gif,nolink,center)
「Use LDAP」と「Use LDAP Authentication」にチェック
#ref(authconfig2.gif,nolink,center)
「Server」に「ldap://127.0.0.1/」、「Base DN」に「dc=example,dc=com」を入力

以下2ファイルについて設定が反映されているか確認
 # cat /etc/ldap.conf
 
 base dc=example,dc=com
 uri ldap://127.0.0.1/
 
 # cat /etc/nsswitch.conf
 
 passwd:     files ldap
 shadow:     files ldap
 group:      files ldap

**LDAPデータベースの初期化 [#h431eff6]

 # cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
 # smbldap-populate

**Sambaの設定 [#jcbd22d2]
smbldap-toolsに対応した設定をsmb.confに対して行なう~
変更する部分だけ抽出

 # vi /etc/samba/smb.conf
 
 [global]
   passdb backend = ldapsam:ldap://localhost:389
   local master = yes
   os level = 32
   domain master = auto
   preferred master = auto
   domain logons = yes
   encrypt passwords = yes
   logon script =
   logon home = \\%N\%U
   logon path = \\%N\%U\profile
   logon drive = Z:
   wins support = 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
   ldap passwd sync = yes
   ldap delete dn = yes
 
   add machine script = /usr/local/samba/bin/smbldap-useradd -w %u
   add user script ~ /usr/local/samba/bin/smbldap-useradd -m %u
   delete user script = /usr/local/samba/bin/smbldap-userdel -r %u
   add group script = /usr/local/samba/bin/smbldap-groupadd -p %g
   delete group script = /usr/local/samba/bin/smbldap-groupdel %g
   add user to group script = /usr/local/samba/bin/sbmldap-groupmod -m %u %g
   delete user from group script = /usr/local/samba/bin/smbldap-groupmod -x %u %g
   set primary group script = /usr/local/samba/bin/smbldap-usermod -g %g %u
 
 # .で始まるファイルを表示させない
   veto files = /.*/
 
 [homes]
   comment = Home Directories
   browseable = no
   writable = yes
   profile acls = yes
 
 [netlogon]
   comment = Network Logon Service
   path = /usr/local/samba/lib/netlogon
   writable = no
   browseable = no

LDAPアクセス時のパスワード設定
 # smbpasswd -w secret

**ユーザー管理方法 [#pc3dd7df]
&color(red){※ユーザー操作は全てsmbldap-tools経由で行なわないとUNIXユーザーとSambaユーザーが同期しないので注意};

***ユーザー追加 [#d79b0067]
- -a:Sambaユーザーも同時に作成
- -m:ホームディレクトリを作成
- -s:シェルを指定
- -c:GECOSとdisplayNameを指定

 # smbldap-useradd -a -m -s /bin/false -c "LDAP01" ldap01

***ユーザーの情報確認 [#l4658ae0]
 # smbldap-usershow ldap01

***GECOSとdisplayNameの変更 [#f9a14852]
 # smbldap-usermod -c "LDAP01" ldap01

***パスワード変更 [#dee05809]
 # smbldap-passwd ldap01

***ユーザー削除 [#o4ecbbff]
- -r:ホームディレクトリも削除

 # smbldap-userdel -r ldap01

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS