用在Windows下的NIS
[root@Centosszm ~]# grep -v '[#|;]' /etc/samba/smb.conf
[global]
workgroup = vbirdhouse
server string = Samba Server Version %v , this is szm's samba server
netbios name = MYSERVER
unix charset=utf8
display charset=utf8
dos charset=850
hosts allow = 127. 192.168.12. 192.168.13. 192.168.179. 172.16.128.
log file = /var/log/samba/log.%m
max log size = 50
security = user
passdb backend = tdbsam
domain master = yes
#成为本局域网内的主要名称解析器
domain logons = yes
#可以域登录
logon drive = K:
#登录后用户主目录挂载目录
time server =yes
#自动调整Windows时间与SAMBA同步
admin users=root
#默认的管理员账号。默认为root
logon script = startup.bat
#用户登录执行的程序
logon path =\\%N\%U\profile
#用户的个人化设置,桌面文件等,N为PDC位置,U为User
logon home=\\%N\%U
#用户的用户主目录位置
os level = 100
#等级越高才能成为主网络的控制者,一般NT为32,2000
为64
preferred master = yes
#成为本局域网内的主要名称解析器
wins support = yes
#成为本局域网内的主要名称解析器
load printers = yes
cups options = raw
printcap name = cups
printing = cups
[homes]
comment = Home Directories
browseable = no
writable = yes
create mode=0664
directory mode=0775
[project]
comment=smbuser's project
path=/home/project
browseable=yes
writable=yes
write list=@users
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[print$]
comment=Printer drivers
path=/etc/samba/drivers
browseable=yes
guest ok=no
read only=yes
write list=root
#这个指定登录用户能够进行的工作,里面主要是具有许多执行程序;
[netlogon]
comment = Network Logon Service
path = /winhome/netlogon
writable = no
write list=root
follow symlinks=yes
[root@Centosszm ~]# /etc/init.d/smb restart
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]
[root@Centosszm ~]# /etc/init.d/nmb restart
Shutting down NMB services: [ OK ]
Starting NMB services: [ OK ]
[root@Centosszm ~]# mkdir -p /winhome/netlogon
[root@Centosszm ~]# vim /winhome/netlogon/startup.bat
net time \\vbirdserver /set /yes
net use K: /home
#和上面的设置重复了,这里只是一个例子
#因为是给Windows用的,所以要用DoS的断行符。
[root@Centosszm ~]# unix2dos /winhome/netlogon/startup.bat
unix2dos: converting file /winhome/netlogon/startup.bat to DOS format ...
[root@Centosszm ~]# cat -A //winhome/netlogon/startup.bat
net time \\vbirdserver /set /yes^M$
net use K: /home^M$
[root@Centosszm ~]# mkdir /etc/skel/profile
#没个用户建立后都有这么一个文件夹,这是 Linux的预配文件
[root@Centosszm ~]# useradd -d /winhome/dmtsai dmtsai
[root@Centosszm ~]# useradd -d /winhome/nikky nikky
[root@Centosszm ~]# smbpasswd -a root
New SMB password:
Retype new SMB password:
[root@Centosszm ~]# smbpasswd -a dmtsai
New SMB password:
Retype new SMB password:
Added user dmtsai.
[root@Centosszm ~]# smbpasswd -a nikky
New SMB password:
Retype new SMB password:
Added user nikky.
[root@Centosszm ~]# ll /winhome/
total 12
drwx------. 5 dmtsai dmtsai 4096 Apr 7 21:34 dmtsai
drwxr-xr-x. 2 root root 4096 Apr 7 21:29 netlogon
drwx------. 5 nikky nikky 4096 Apr 7 21:34 nikky
#SAMBA PDC可以通过“主机账号”来判断Windows客户端能否连上来。
[root@Centosszm ~]# useradd -M -s /sbin/nologin -d /dev/null vbirdwinxp$
[root@Centosszm ~]# useradd -M -s /sbin/nologin -d /dev/null vbirdwin7$
[root@Centosszm ~]# smbpasswd -a -m vbirdwinxp$
Added user vbirdwinxp$.
[root@Centosszm ~]# smbpasswd -a -m vbirdwin7$
Added user vbirdwin7$.
[root@Centosszm ~]# chcon -R -t samba_share_t /winhome/
客户端设置:
XP:
Win7:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanworkstation\parameters]
"DomainCompatibilityMode"=dword:00000001
"DNSNameResolutionRequired"=dword:00000000
[root@Centosszm ~]# ll /winhome/dmtsai/profile/
total 564
drwxr-xr-x. 4 dmtsai dmtsai 4096 Aug 20 2008 Application Data
drwxrwxr-x. 2 dmtsai dmtsai 4096 Aug 20 2008 Cookies
drwxr-xr-x. 3 dmtsai dmtsai 4096 Apr 7 21:55 Favorites
drwxr-xr-x. 4 dmtsai dmtsai 4096 Apr 7 21:55 My Documents
drwxrwxr-x. 2 dmtsai dmtsai 4096 Aug 20 2008 NetHood
-rw-rw-r--. 1 dmtsai dmtsai 524288 Apr 7 22:09 NTUSER.DAT
-rw-rw-r--. 1 dmtsai dmtsai 1024 Apr 7 22:09 NTUSER.DAT.LOG
-rw-rw-r--. 1 dmtsai dmtsai 268 Apr 7 22:09 ntuser.ini
drwxrwxr-x. 2 dmtsai dmtsai 4096 Aug 20 2008 PrintHood
drwxr-xr-x. 2 dmtsai dmtsai 4096 Apr 7 21:55 Recent
drwxr-xr-x. 2 dmtsai dmtsai 4096 Aug 20 2008 SendTo
drwxrwxr-x. 2 dmtsai dmtsai 4096 Aug 20 2008 Templates
drwxr-xr-x. 3 dmtsai dmtsai 4096 Aug 20 2008 「开始」菜单
drwxrwxr-x. 2 dmtsai dmtsai 4096 Aug 20 2008 桌面
Troubleshoot For PDC
1./var/log/samba
2.lmhosts增加对应关系
3.关闭smb,等待时间超时后启动
log file = /var/log/samba/log.%m #客户端的NetBIOS Name
如果SAMBA明明已经启动完成了,却偏偏总是无法成功,又无法查出问题时,建议先关闭SAMBA一阵子,再重新启动。
让用户修改SAMBA密码同时同步更新/etc/shadow密码;
[root@Centosszm ~]# vi /etc/samba/smb.conf
unix password sync=yes #让SAMBA与Linux密码同步
passwd program=/usr/bin/passwd %u #以Root呼叫修改的命令
pam password change=yes #并且支持pam模块