Samba-PDC

Loading

把 samba server 當成 windows NT 4.X 的 PDC(Primary Domain Controller),至於為什麼要架設成 Microsoft Domain security,這樣可以達成 Single Sign On(SSO),也就是說同一個使用者可以使用網域中的任一機器來登入以及存取資源.

Step1 : Linux Samba server 修改 /etc/samba/smb.conf [global]區域內資料

[root@benjr ~]#vi /etc/samba/smb.conf
netbios name =  rh90       
#相當於 Windows 的電腦名稱
workgroup = SUN          
#這就是將來 Windows client 要登入網域名稱.
security = user                 
#指定 samba server 為身分驗證伺服器
encrypt password = yes   
#密碼的傳送要先加密,Win95 OSR2.NT4.0+SP3之後的版本密碼傳送皆經過加密.
domain logons = yes        
#將 samba server 當成 Windows 的登入網域主機

其他建議要開的設定

local master = yes
os level = 64
domain master = yes
prepferred master = yes

Step2 :加入 root,user 使用者至 samba server

以 root 身份登入並新增一位使用者為 user.

[root@benjr ~]#adduser user
[root@benjr ~]#passwd user
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

加入 root,user 使用者至 samba server

[root@benjr ~]#smbpasswd -a root
[root@benjr ~]#smbpasswd -a user

-a 第一次新增使用者至 sambapasswd 時要用這個參數,但使用者必先存在於 /etc/passwd
samba server 密碼存在 /etc/samba/smbpasswd

Note:只有 uid =0 (/etc/passwd , /etc/samba/smbpasswd 的 uid 皆為 0) 的使用者才有權限將電腦加入網域,預設只有 root.

Step3 : 重新啟動 samba server

[root@benjr ~]#chkconfig samba on
[root@benjr ~]#service smb restart
Shutting down SMB services:                 [  OK  ]
Shutting down NMB services:                 [  OK  ]
Starting down SMB services:                 [  OK  ]
Starting down NMB services:                 [  OK  ]

Step 4: Windows 98 Client 登入網域

98client
Windows 98 client 只要執行 start / settings /Control Panel / Network 如上圖 ,並修改 Primary Network Logon 成為 Client for Microsoft Networks .重新開機就可以登入了.

Step 5: Windows 2000 Client 登入網域

Windows 2000 Client 要先加入網域中方法如下
在 My Computer 按右鍵選 content,再選 Network Identification/Properties 如下圖
login1
選擇要加入的網域,先前 samba server 設定的網域為 SUN,所以在 Domain 填入 SUN.如下圖
login3
填入使用者名稱為 root ,以及 root 的密碼
login5
但會出現以下的錯誤訊息
login6
因為Windows 2000 Client 電腦名稱帳號必須先存在於 /etc/passwd 以及 /etc/samba/smbpasswd 中
所以要新增 /etc/samba/smb.conf [global]區域內資料

[root@benjr ~]#vi /etc/samba/smb.conf
add user script = /usr/sbin/useradd -d /dev/null -g 100 -s /bin/false -M %u 

-d /dev/null 指定使用者登入的家目錄(導進黑洞)
-g 100 指定登入後所屬的群組為Gid 100 的 users
-s /bin/false 指定登入後的shell為false(就是不給shell啦)
-M %u 不建立與目前使用者名稱相同的家目錄
當每次有新的電腦加入網域時, samba PDC 就會自動加入電腦名稱的帳號至 /etc/passwd 以及 /etc/samba/smbpasswd
這樣就可以讓 Windows 2000 加入 Samba PDC
接下來重新啟動 samba server

#service smb restart
Shutting down SMB services:            [  OK  ]
Shutting down NMB services:            [  OK  ]
Starting down SMB services:            [  OK  ]
Starting down NMB services:            [  OK  ]

重覆之前加入 Domain 步驟,成功便會出現以下的訊息.
login7
重開機後即可以用一般使用者帳號( "user" 之前用 smbpasswd -a 所建立的 )登入Samba網域.

Note: 那可不可以把 root 換成 administrator or admin 呢?
當然是可以的,請移除 /etc/samba/smb.conf 中
username map = /etc/samba/smbusers 的 ";"
其中所對應的那個檔,你再看看那個檔就會明白了!

Step 6: Windows XP Professional Client 登入網域

步驟同 windows 2000 client
但要修改下列的 windows XP 的 register 值方法如下
開始 / 執行 / regedit 會出現如下圖
regedit
並修改如下的值

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters]
"requiresignorseal" = dword:00000000                              
"signsecurechannel" = dword:00000000 

regedit1
regedit2
把值由 1 修改為 0
修改後需重新開機.接下來的步驟同 windows 2000 client
Note

  1. 但 Windows XP Home Client 無法登入網域,因為微軟的設計所限制.
  2. 請先修改 register 值,再加入 Domain.

Step 7:Roaming Profiles 使用者的漫遊設定

使用者的漫遊設定存在 samba server 端,所以使用者一些設定值會跟著使用者因使用不同機器而移動(如:桌面,我的最愛,我的文件…)不是存在本端機器的資料夾中.但是只有 Windows 2000,XP 才能使用這項功能.windows 98 還要修改一些設定才能使用.
先確定 /etc/samba/smb.conf 皆已設定

[root@benjr ~]#vi /etc/samba/smb.conf
logon path = \\%L\%U\profile 
#定義profile漫游的設定檔所存放位置 /home/username/profiles ,%L代表本機的 netbios name,%U 代表使用者登入時所使用的名稱 ,雖然使用者的家目錄在 /home/user 之下,但logon path 必須用網路路徑為設定值(如 \\rh90\user).
client quote page = 950 
#中文支援 --需自行加入.
preserve case = yes 
#保留文字的大小寫
short preserve case = yes 
#檔名為8.3格式時之文字大小寫設定

接下來重新啟動 samba server

[root@benjr ~]#service smb restart
Shutting down SMB services:            [  OK  ]
Shutting down NMB services:            [  OK  ]
Starting down SMB services:            [  OK  ]
Starting down NMB services:            [  OK  ]

Windows clients 就會在登出後將設定值回存至 samba server
note:你如果不想讓某位使用者更改設定時只要修改 NTUSER.dat 成 NTUSER.MAN 就不會將設定值回寫至 samba server.
如果只想讓某些使用者的資訊存放在 samba server 那就要修改 Windows client 的 regedit 值

Wab File Name.reg : 更改通訊錄的位置.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\WAB\WAB4\Wab File Name] @="U:\\mydata\\Outlook Express\\address.wab"
記得只要機碼中有使用者機碼,就要改成您當下的機碼,最後將這四個內容,存成reg檔就可執行.
Outlook Express:原始位置C:\Documents and Settings\%UserName%\Local Settings\Application Data\Identities\{使用者機碼}\Microsoft\Outlook Express
我的文件:原始位置C:\Documents and Settings\%UserName%\My Documents
我的最愛:原始位置C:\Documents and Settings\%UserName%\Favorites
通訊錄:搜尋*.wab 便知

Step 8: Login Scripts

先確定 /etc/samba/smb.conf 皆已設定

[root@benjr ~]#vi /etc/samba/smb.conf 
[global]
workgroup = test-domain
security = user
domain logons = yes
logon script = U.bat  
[netlogon]
comment = Network Logon Service
path = /usr/local/samba/lib/netlogon  
guest ok = yes
writable = no
share modes = no
[tmp]
comment = Temporary file space
path = /tmp
read only = no
public = yes

logon script = U.bat #當所有client用一個 login script 時就用固定名稱,%u代表不同的使用者用不同的login script (ex:user1 登入就用 user1.bat 為login script)%m代表不同機器的 netBIOS name 使用不同的login script.
path = /usr/local/samba/lib/netlogon #需在系統中實際立該目錄,並先把其他人權限設成可讀以及可執行(#chmod o+rx /usr/local/samba/lib/netlogon).
接下來重新啟動 samba server

# service smb restart
Shutting down SMB services:           [  OK  ]
Shutting down NMB services:           [  OK  ]
Starting down SMB services:           [  OK  ]
Starting down NMB services:           [  OK  ]

接下來編輯 r.bat 檔,並存放在 /usr/local/samba/lib/netlogon 目錄下

#vi /usr/local/samba/lib/r.bat
net use u: \\rh90\tmp

但在 Linux 下編輯 MS-DOS文字檔要注意跳脫字元(Unix like system 行結束字元為 \n , 但 Windows base system 除了換行字元 \n 還包括跳脫字元 \r)
如果要在 Linux下編輯 MS-DOS 格式文字檔 可以用以下的方法解決
方法一:使用 vi 編輯的時候,在下面命令列輸入「 :set ff=dos 」,才開始編輯即可
方法二:使用 unix2dos 指令轉換格式:在 Linux 下用任何一種編輯軟體編好 U.bat 之後,下「 unix2dos U.bat 」即可(需要有安裝 unix2dos 套件,才會有此指令)

在 Linux 下如何判斷 U.bat 是否為 M$-DOS 格式
可以使用「 od -c U.bat 」指令
修改 r.bat 檔案的其他人權限設成可讀以及可執行(#chmod o+rx /usr/local/samba/lib/r.bat).
使用者登入就會多一個網路磁碟機 U

沒有解決問題,試試搜尋本站其他內容

3 thoughts on “Samba-PDC

  1. 自動引用通知: samba | Benjr.tw

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料