一、分析:

1、中心现有windows DC服务器,ISA服务器,以及一些以前更换下来的服务器硬件。

2、CBD中心可分IT部、账务部、人事行政部、教学部、客服部、销售部、管理层等部门。

3、要求有一共享目录存放全中心共享文件,每个人都可读写,但每个人只能删除所有者是自己的文件。

4、公司管理层对所有共享目录具有读权限,对自己主目录具读写权限。

5、域客户端在访问文件服务器时当其有访问权限的时候不需要输入用户名密码,非域客户端则需要提供帐户以及密码。

二、解决方法

1、利用公司现有资源windows 2003域控服务器作帐户认证管理,架设securty=ads集成windows 域的samba文件服务器。

2、2003域控上按部分划分IT、财务、销售、人事行政、教学、客服、管理等7OU单元,新建SAQTITCWXZCCGL7个用户组。

3、linux  /home下新建SAQTITCWXZCCGL等共享主目录,拥有者为root,所属用户组分别为CBDOFFICE+saCBDOFFICE+qtwbinfo -g可查看同步过来的windows用户组),拥有者权限为可读,所属组为读写权限,其它人权限为可读,最终权限设定为575( chmod -R 575  

4、为方便同组用户可能会编辑同一个文件,samba中加加入create mask = 0664.用户新建目录采用linux 默认权限umask = 022.

5、各共享主目录在valid users 字段后面添加管理层用户组CBDOFFICE+gl,以便管理层拥有查看权限。

6、新建/home/public主目录,利用SBIT功能实现用户只能删除、重命名、移动自己创建的文件和目录,赋1777权限(chmod -R 1777 public 

三、配置

1、配置krb5.conf  (Windows 网络验证kerberos)Win2003系统默认通过Kerberos做身份验证,Kerberos验证需要安装Krb5软件包

[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log

[libdefaults]
default_realm = CBDOFFICE.LOCAL   //改成你的域名
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
forwardable = yes

[realms]
CBDOFFICE.LOCAL = {          //域名
  kdc =172.16.3.1:88    
  admin_server = 172.16.3.1:749        //FQDNIP
  default_domain =CBDOFFICE.LOCAL     
}

[domain_realm]
sany.com.cn = CBDOFFICE.LOCAL //域名
.sany.com.cn = CBDOFFICE.LOCAL  
[appdefaults]
pam = {
   debug = false
   ticket_lifetime = 36000
   renew_lifetime = 36000
   forwardable = true
   krb4_convert = false
}

2、设置linux本机DNS    /etc/resolv.conf   nameserver=192.168.3.1

可用kinit adjustsoso@CBDOFFICE.LOCAL  //测试连通性,后面的域名要大写

3、配置sambasmb.conf文件

[global]

Workgroup=CBDOFFICE //域名

server string = Samba Server  Version %v //服务器说明

Netbios name = IT

#Display charset = utf8 

#Unix charset = utf8

#Dos charset = cp950 //控制客户端显示字符集

[domain members options]

Realm =CBDOFFICE.LOCAL

security = ads  /活动目录认证模式

password server = 10.0.3.1  /域控的IP

Encrypt passwords = yes  / /加密

idmap uid = 16777216-33554431

 idmap gid = 16777216-33554431
# template shell = /bin/bash  

 Template shell= /sbin/nologin

 template homedir = /home/%U


 #winbind use default domain = true

#winbind offline logon = true

#winbind separator = /  使用此项在域用用户环境下还需输入用户密码?

Winbind separator=+

winbind enum groups = yes
 winbind enum users = yes

Create mask = 0664

#如需在共享主目录里使用登录用户主目录则可使用[homes]

#[homes]

comment = Home Directories

path = /home/%U //共享的目录

valid users = CBDOFFICE.LOCAL/%U //认证的用户,

#read only = No

Writable = yes

browseable = No

root preexec = /root/mkhome.sh %U %G //执行创建目录的操作。

默认域用户使用samba登录linux不会创建用户主目录,以下为新建主目录sh

mkhome.sh

#!/bin/bash

user=$1

group=$2

home=/home/$1

if [  ! -d  $home  ]  ;  then

mkdir -p $home

chown $user $home

chgrp $group $home

chmod 700 $home

edquota -p administrator -u $user

Fi

[IT]

Comment = it directories

Path = /home/IT

Browseable= yes

Write list = @CBDOFFICE+it

Valid users= @CBDOFFICE+it,@CBDOFFICE+gl

[SA]

Comment =sa directories

Path=/home/SA

Browseable =yes

Write list = @CBDOFFICE+sa

Valid users=@CBDOFFICE+sa,@CBDOFFICE+gl

[CC]

[XZ]

[QT]

[CW]

[GL]

[public]

Comment = public directoies

Path =/home/public

Public=yes

Writeable=yes

依次配置好上面各部门共享目录

4、修改/etc/nsswitch.conf

NssName Service SwitchNsswitch.conf配置文件是用来控制在用户访问Samba服务器时与Windows域中DC中的用户账户的切换,使用DC中的用户账户来进行身份验证

编辑/etc/nsswitch.conf如下

passwd: files winbind
group: files winbind

Passwd: files winbind(先通过读files 再通过winbind验证)

5相关的服务:

 service  winbind  start
service   smb  restart

Chkconfig --level 35 smb on 开机启动SMB winbind 服务

Chkconfig --level 35 winbind on

关闭防火墙  service iptables stop

关闭selinux  vim /etc/selinux/config    修改SELINUX=disabled

6、加入域

net rpc join  -S CBDSERVER.CBDOFFICE.LOCAL 
(FQDN)-U adjustsoso

测试命令

Ntlm_auth --username=administrator    输入密码出现NT_STATUS_OK:seccuss(0x0)

表示域帐户administrator验证成功

root# wbinfo t

系统返回

CODE:

checking the trust secret via RPC calls succeeded

说明主机信任已成功建立
使用wbinfo u可以列出AD中注册的帐号信息。Wbinfo g可以返回AD中的组信息。

Locale -a查看系统所支持语系

注意:centos 5.5 gnomevirtual pc 2007中花屏 与不能用鼠标

1Vim /etc/X11/xorg.conf   defaultdepth的值从24改为16

2vim /etc/boot/grub/grub.conf   kernel-------quietr后面加i8042.noloop

3valid user = CBDOFFICE.LOCAL/%U 不能写成CBDOFFICE.LOCAL\%U

4、测试sh脚本有无错误  sh -x mkhome.sh

5winbind separator = + //写成 域用户环境下提示输入用户名密码