安装 ldap

来源:互联网 发布:js重置table 编辑:程序博客网 时间:2024/06/05 09:16
1、安装软件包
yum -y install openldap openldap-clients openldap-servers  openldap-devel

如果你是64位系统。为了让php编译ldap扩展模块时能找到ldap.h执行以下命令
cp -frp /usr/lib64/libldap* /usr/lib/
2、生成root用户密码,一会儿用到
[root]# slappasswd
New password : password_string
Re-enter new password : password_string
{SSHA}5lPFVw19zeh7LT53hQH69znzj8TuBrLv
3、修改配置文件
cd /etc/openldap/slapd.d/cn\=config
[root]# vi olcDatabase\=\{2\}bdb.ldif
添加下面一行
olcRootPW: {SSHA}5lPFVw19zeh7LT53hQH69znzj8TuBrLv
修改这两行,改成自己的域名
olcSuffix: dc=1v,dc=cn
olcRootDN: cn=Manager,dc=1v,dc=cn
让用户看不见其他用户的密码的hash值
olcAccess: {0}to attrs=userPassword by self write by dn.base="cn=Manager,dc=1v,dc=cn" write by anonymous auth by * none
olcAccess: {1}to * by dn.base="cn=Manager,dc=1v,dc=cn" write by self write by * read
4、修改配置文件
vi olcDatabase\=\{1\}monitor.ldif
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read by dn.base="cn=Manager,dc=1v,dc=cn" read by * none

5、启动服务
chkconfig slapd on
service slapd start
6、测试
vim test.ldif
dn: dc=1v,dc=cn
objectClass: dcObject
objectClass: organization
dc: 1v
o : 1v

ldapadd -f test.ldif -D cn=Manager,dc=1v,dc=cn -w password_string

ldap_bind: Invalid credentials (49)
vim /etc/openldap/ldap.conf
屏蔽所有行
ldapadd -f test.ldif -D cn=Manager,dc=1v,dc=cn -w password_string
ldapsearch -x -LLL -b dc=acme,dc=com -h localhost


7、如果有其他程序支持LDAP验证
那么每个用户需要设置userPassword密码字段
0 0
原创粉丝点击