phpldapadmin需要使用这个程序来生成samba的加密密码。debian没有这个包,需要自己编译,编译之前可能需要安装make,gcc和libc-dev包。
#apt-get install make gcc libc-dev
#wget http://www.nomis52.net/data/mkntpwd.tar.gz
#tar -zxf mkntpwd.tar.gz
#cd mkntpwd
#make
#cp mkntpwd /usr/local/bin
修改/usr/share/phpldapadmin/templates/template_config.php文件。
查找
// uncomment to set the base dn of posix groups
// default is set to the base dn of the server
//$base_posix_groups=”ou=People,dc=example,dc=com”;
$samba3_domains[] =
array( ‘name’ => ‘My Samba domain Name’,
’sid’ => ‘S-1-5-21-4147564533-719371898-3834029857′ );
// The base dn of samba group. (CUSTOMIZE)
//$samba_base_groups = “ou=Groups,ou=samba,dc=example,dc=org”;
修改为
// uncomment to set the base dn of posix groups
// default is set to the base dn of the server
$base_posix_groups=”ou=groups,dc=nomis52,dc=net”;
$samba3_domains[] =
array( ‘name’ => ‘TEST-DOMAIN’,
’sid’ => ‘S-1-5-21-3248317815-3353503310-553435137′ );
// The base dn of samba group. (CUSTOMIZE)
$samba_base_groups = “ou=groups,dc=abc,dc=com”
6 安装libnss-ldap
用来做linux验证。使得LDAP用户就像普通linux帐号一样。
#apt-get install libnss-ldap
libnss-ldap设置
1) 默认。
2) 查找基准。输入dc=abc,dc=com。
3) 选3。
4) 选否。
5) 选是。
6) 确定。
修改/etc/nsswitch.conf。
passwd: compat ldap
group: compat ldap
shadow: compat ldap
这样验证密码的时候会先搜索/etc/passwd,然后才是ldap。
使用getent命令查看一下计算机上面的用户组,在最后会看到ldap的。
#getent group
…..
Domain Admins:x:512:Administrator
Domain Users:x:513:
Domain Guests:x:514:
Domain Computers:x:515:
Administrators:x:544:
Print Operators:x:550:
Backup Operators:x:551:
Replicators:x:552:
7 安装libpam-ldap
#apt-get install libpam-ldap
libpam-ldap设置
1) 使root成为数据库的管理员?选是。
2) 选否。
3) 输入admin的dn,cm=admin,dc=abc,dc=com。
4) 输入root使用的密码,留空使用原来的root密码。
5) 选md5。
修改 /etc/pam-ldap.conf。
pam_filter !(uidNumber=0)
设置不允许root通过ldap登陆linux。
修改下面文件使得pam使用ldap。
/etc/pam.d/common-account
# 注释掉这行
#account required pam_unix.so
# 添加下面两行
account sufficient pam_ldap.so
account required pam_unix.so try_first_pass
/etc/pam.d/common-auth
# 注释掉这行
#auth required pam_unix.so nullok_secure
# 添加下面两行
auth sufficient pam_ldap.so
auth required pam_unix.so nullok_secure use_first_pass
/etc/pam.d/common-password
# 注释掉这行
#password required pam_unix.so nullok obscure min=4 max=8 md5
# 添加下面两行
password sufficient pam_ldap.so
password required pam_unix.so nullok obscure min=4 max=8 md5 use_first_pass
重启ssh和samba。
安装nscd。
#apt-get install nscd
8 添加用户
smbldap-useradd : to add an user account (by default a posixAccount. Using ‘-a’ option for a sambaSAMAccount, ‘-w’ option for a machine sambaAccount),
smbldap-userdel : to delete an existing user account
smbldap-usermod : to modify an user account.
smbldap-userinfo : to allow users to modify some informations themselves
修改/etc/samba/smb.conf。
guest account = nobody
add user script = /usr/sbin/smbldap-useradd -m “%u”
#delete user script = /usr/sbin/smbldap-userdel “%u”
add machine script = /usr/sbin/smbldap-useradd -w “%u”
add group script = /usr/sbin/smbldap-groupadd -p “%g”
#delete group script = /usr/sbin/smbldap-groupdel “%g”
add user to group script = /usr/sbin/smbldap-groupmod -m “%u” “%g”
delete user from group script = /usr/sbin/smbldap-groupmod -x “%u” “%g”
set primary group script = /usr/sbin/smbldap-usermod -g “%g” “%u”
ldap passwd sync = yes
添加一个测试用户。
#smbldap-useradd -a -m testuser
#smbldap-passwd testuser
#smbldap-passwd Administrator
重启一下电脑,然后使用下面的命令。
#net rpc -U Administrator rights grant testuser SeMachineAccountPrivilege
然后使用这个用户登陆一下域看看。
$ smbcontrol smbd reload-config
and grant the necessary rights to Administrator:
$ net -U Administrator rpc rights list
SeMachineAccountPrivilege Add machines to domain
SePrintOperatorPrivilege Manage printers
SeAddUsersPrivilege Add users and groups to the domain
SeRemoteShutdownPrivilege Force shutdown from a remote system
SeDiskOperatorPrivilege Manage disk shares
$ net -U Administrator rpc rights list Administrator
$ net -U Administrator rpc rights grant Administrator SeMachineAccountPrivilege
Successfully granted rights.
9 登陆脚本
创建网络共享
# mkdir -p /data/samba/netlogon
# chgrp “Domain Admins” /data/samba/netlogon
修改/etc/samba/smb.conf
# put this in the main section
logon script = logon.bat
# share for the logon scripts
[netlogon]
comment = Network logon service
path = /data/samba/netlogon
write list = “@Domain Admins”
guest ok = Yes
下载KiXtart,解压到/data/samba/netlogon。
#cd /data/samba/netlogon
#wget “http://www.adminscripteditor.com/downloads.asp?act=v&id=39″
#apt-get install unzip
#unzip KiX2010_451.zip
#cp ./KiX2010.451/{KIX32.EXE,KX32.dll} ./
创建logon.bat。
\\debian\netlogon\kix32 \\debian\netlogon\logon.kix /f
原文:http://blog.wdicc.com/wordpress/2006/05/14/158/
