linux 加入到 windows域

1 samba
首先确保你的 Linux 系统中安装了 samba 包,并用下述命令来检查 samba 包的基础库支持,一般的 RPM 安装都不会有问题。
# smbd -b | grep LDAP
HAVE_LDAP_H
HAVE_LDAP
HAVE_LDAP_DOMAIN2HOSTLIST
...
# smbd -b | grep KRB
HAVE_KRB5_H
HAVE_ADDRTYPE_IN_KRB5_ADDRESS
HAVE_KRB5
...
# smbd -b | grep ADS
WITH_ADS
WITH_ADS
# smbd -b | grep WINBIND
WITH_WINBIND
WITH_WINBIND
2
krb5 配置
编辑 /etc/krb5.conf 中以下三节 : 假设你的域名是 SZ.AAA.COM ,域控制器是 dc01.sz.aaa.com/192.168.1.200
[libdefaults]
default_realm = SZ.AAA.COM
dns_lookup_realm = false
dns_lookup_kdc = true
[realms]
SZ.AAA.COM= {
  kdc = 192.168.1.200:88
  admin_server = 192.168.1.200:749
  default_domain = SZ.AAA.COM
}
[domain_realm]
  .SZ.AAA.COM= SZ.AAA.COM
  SZ.AAA.COM= SZ.AAA.COM
        
确保你的配置严格区分大小写,否则你可能在用 kinit 测试连接时可能遇到错误 “Cannot find KDC for requested realm while getting initial credentials”.
# kinit
[email protected]

Password for
[email protected]
3 Samba 配置
编辑修改 /etc/samba/smb.conf 如下:
[global]
workgroup = SZ
realm = SZ.AAA.COM
security = ADS
password server = 192.168.1.200
encrypt passwords = yes
winbind separator = +
idmap uid = 10000-20000
idmap gid = 10000-20000
winbind use default domain = Yes
[homes]
comment = Home Directories
valid users = %S
read .ly = No
browseable = No
保存并用 testparm 来检查配置中可能的语法错误。
若无错误,(重)启动 samba 服务。
然后用 net ads join -S 192.168.1.200 -U Administrator 来加入域,这时需要输入域管理员密码。
4
winbind 配置
编辑 /etc/nsswitch.conf ,更改 passwd group (files 需视你 linux 系统配置 NIS 与否,如配置 NIS ,则为 compat)
passwd:  files winbind  
group:  files winbind  
保存后(重)启动 samba 服务。(重)启动 winbind
wbinfo -u 检索用户, wbinfo -g 检索用户组来测试 winbind 是否正常。
5
Apache NTLM 用户校验模块,用下面的链接可以得到其源代码。
[url]http://samba.org/ftp/unpacked/lorikeet/mod_auth_ntlm_winbind/[/url]
该源代码需要 APACHE 源码安装版本后的 apxs ,把 apxs 路径设入 PATH 变量或在 Makefile 中更改执行 make install ,进入模块目录,执行如下安装:
autoconf
./configure
apxs -DAPACHE2 -c -i mod_auth_ntlm_winbind.c
应该在 /usr/local/apache2/modules 下生成 mod_auth_ntlm_winbind.so 模块。
6
Apache 配置
httpd.conf 中加入
LoadModule auth_ntlm_winbind_module modules/mod_auth_ntlm_winbind.so
并在需要 NTLM 校验的 DIRECTORY 配置如下内容:
  AuthName "SZ.AAA.COM"
  NTLMAuth .
  NTLMAuthHelper "/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp"
  NTLMBasicAuthoritative .
  AuthType NTLM
  require valid-user
  
并对相应目录可以设置域用户 / 用户组权限。

经验总结:
1
、据 winbind 开发者说 CentOS 自带的 samba+winbind 会带来许多意料不到的问题,用 Version 3.0.26a-SerNet-RedHat( 可从
[url]http://enterprisesamba.com/index.php?id=64[/url]
得到需要的 client,common, winbind ).
CentOS 4.2(2.6.9-22)
带的是 samba 3.0.10-1.4E.2
2
Version 3.0.26a-SerNet-RedHat 版的 /var/lib/samba/winbindd_privileged(CentOS 集成 samba 版的 /var/cache/samba/winbindd_privileged) 文件权限为 777 ,否则 Apache 可能报 500 internal server error
3
、在重启 winbind 服务前,手工删除 2 中所述文件,否则重启会因该文件权限更改了导致失败。
4
kinit net ads join -S 用户不一定要 administrator ,一致既可,当然该用户必须要有加 Windows NT 域的权限。
5
、通过更改 /etc/pam.d/ 下相关验证配置文件,可以很容易地为 su, ssh, login, ftp 等配置 domain user 集成。

你可能感兴趣的:(linux,windows,职场,休闲,域)