環(huán)境
系統(tǒng):CentOS 6.8
ldap server端
- 安裝migrationtools工具
yum install migrationtools -y
- 添加uid>10000用戶
#!/bin/bash
for i in name1、name2·········nameN
do
for j in `seq -w 10000 10050`
do
useradd -d /home/$i $i -u $j
done
done
- 修改migrate_common.ph文件
# Default DNS domain
$DEFAULT_MAIL_DOMAIN = "zijian.com";
# Default base
$DEFAULT_BASE = "dc=zijian,dc=com";
- 將用戶和用戶組轉(zhuǎn)換成LDIF文件
# tail -n 51 /etc/passwd > system
# /usr/share/migrationtools/migrate_passwd.pl system people.ldif
# tail -n 10 /etc/group > group
# /usr/share/migrationtools/migrate_group.pl group group.ldif
注:生成ldif文件在導(dǎo)入openldap時會出現(xiàn)屬性確實或沖突,報錯很明顯,根據(jù)報錯進行相應(yīng)調(diào)整;
導(dǎo)入openldap
# ldapadd -x -W -D "cn=manager,dc=zijian,dc=com" -f people.ldif
Enter LDAP Password: 輸入管理員密碼
ldap client端
- 安裝軟件包
yum install openldap-clients nss-pam-ldapd -y
- 修改nslcd.conf配置文件
# vim /etc/nslcd.conf
uri ldap://192.168.2.2/
base dc=zijian,dc=com
ssl no
tls_cacertdir /etc/openldap/certs
- 修改pam_ldap.conf配置文件
# vim /etc/pam_ldap.conf
uri ldap://192.168.2.2/
ssl no
tls_cacertdir /etc/openldap/certs
bind_policy soft
- 修改system-auth認證文件
# vim /etc/pam.d/system-auth
auth sufficient pam_ldap.so use_first_pass
account [default=bad success=ok user_unknown=ignore] pam_ldap.so
password sufficient pam_ldap.so use_authtok
session optional pam_ldap.so
session optional pam_mkhomedir.so skel=/etc/skel/ umask=0077
- 修改nsswitch.conf配置文件
# vim /etc/nsswitch.conf
passwd: files ldap
shadow: files ldap
group: files ldap
- 修改authconfig認證文件
# vim /etc/sysconfig/authconfig
USELDAP=yes
USELDAPAUTH=yes
USELOCAUTHORIZE=yes
USESHADOW=yes
- 啟動nslcd
# /etc/init.d/nslcd restart
# chkconfig nslcd on