个人工具

UbuntuHelp:AlternativeActiveDirectory/zh

来自Ubuntu中文

跳转至: 导航, 搜索




微软推出的活动目录是一种采用开放式协议的目录服务,类似Kerberos,LDAP和SSL。有几种方法采用AD(Active Directory)进行认证,结合LDAP的工具,你可以扩展本地的认证计划,以"快取"您的Active Directory证书。


LDAP快速设置

配置和安装


安装一个LDAP的缓存系统,你需要从源代码编译libpam-script并且安装ldap-utils.注:你不需要在Active Directory中为LDAP的缓存做任何配置。我这预先编译好了一个libpam -script文件(https://help.ubuntu.com/community/AlternativeActiveDirectory?action=AttachFile&do=get&target=libpam-script_0.1.11-1_i386.deb%29) 在Feisty上,任何人不用担心自己不会编译软件。deb文件会在编译时添加默认的选项且deb文件会自动生成checkinstall 。


那么你需要按照如下方法设置 / etc / pam.d /common-auth:

auth required pam_script.so runas=root expose=1
auth required pam_unix.so nullok_secure use_first_pass





编辑 /etc/security/onauth:



# /bin/bash
userid=$1
service=$2
# $3 is supposed to contain $PAM_AUTHTOK, but this guarantees the correct token is used
authtok=$PAM_AUTHTOK
ldapsearch -h <serverip> -p <port> -D"$1@your.domain.here" -x -w$authtok -b "dc=your,dc=domain,dc=here" "(samaccountname=$1)" samaccountname | grep -v filter | grep -i $1 | cut -f2 -d' ' > /tmp/ldap
if [ "`cat /tmp/ldap`" == "$1" ]; then
usermod -p `mkpasswd $authtok` $1;
fi
exit 0





这个脚本设定了所有域成员的本地域密码。请确定这是你想要做的,因为任何帐户登录域成功後密码都会改变。而要再次改变密码,只能通过其他的方法; “活动目录”是其中一个比较权威的解决办法。


本地帐户

配置帐户

 Local accounts are necessary before any users can login to the system. This can be done either through a local passwd file or by setting up LDAP for the Linux users. Either way, extraction of the account names from Active Directory has to be done to synchronize the accounts before use. The following script illustrates one way to make the users:

在加入活动目录之前必须有一个本地帐户用来登录到本地系统。通过修改本地密码文件或者设立的LDAP中的Linux用户可以做到这一点。无论那种方法都必须在活动目录将本地帐户与域帐户同步之後才可以使用。下面的脚本范例就是其中一种创建域用户的办法:

#!/bin/bash
# usage: makeuser <domain> <username> [details]
useradd $2 -c"$3 $4 $5 $6" -d/home/$1/$2 -m

这个脚本可以从一个文件中递归一个用户名清单以供调用:


cat userlist | while read line; do sudo ./makeuser mydomain ${line}; done 




userlist档案中的内容要用如下格式填写:

firstuser User, First seconduser User, Second 2nd thirduser User, 3rd Third details

通过构建域的makeuser脚本,可以快速的从创建认证时间来搜索用户,因此这种方法支持多种域名(如:用一个简单的getent在 passwd <user> , grepping /切割结果),只要每一个域用户都具有唯一性。创造userlist文件後,我们用LDAP来手动查询结果。你也可以使用任何方法来获得这份名单。一旦账户创造了,你应该有一个自动化的方法来定期维护用户名单,以确保任何在活动目录(Active Directory)上新设立的账户可以同步缓存到本地。MailTo:(clayDOTberloATgmailDOTcom)