标签:shadow 部署 初始 equal class one 定义 openssl example
yum install openssl-devel gcc libtool-ltdl-devel -y
yum install openldap-servers openldap-clients -y
[root@master ldap]# id ldap # 默认安装完成后默认创建
uid=55(ldap) gid=55(ldap) 组=55(ldap)
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
chown ldap:ldap /var/lib/ldap/DB_CONFIG
[root@master ldap]# cat /var/lib/ldap/DB_CONFIG |grep -v "^#"|grep -v "^$"
set_cachesize 0 268435456 1
set_lg_regionmax 262144
set_lg_bsize 2097152
[root@master ldap]# service slapd start
正在启动 slapd: [确定]
[root@master ldap_ldif]# ss -ntl|grep 389
LISTEN 0 128 :::389 :::*
LISTEN 0 128 *:389 *:*
[root@master ldap_ldif]# slappasswd
New password: # 我这里输入的是 123456
Re-enter new password:
{SSHA}mqDbkQdCLjLLai6jkXiuS3IFjoV0q7XQ # 这个字符串就是根据你输入的密码得到的,一会我们会用到他。
[root@master ldap_ldif]# cat password.ldif
dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}51JBhgYyPdBnAy8/UbVwMtWzPR4hz/R8
以上配置文件关键参数说明:
ldif即LDAP Data Interchange Format,是LDAP中数据交换的一种文件格式。文件内容采用的是key-value形式,注意value后面不能有空格。
上面内容中dn即distingush name
olc即Online Configuration 表示写入LDAP后不需要重启即可生效
changetype: modify 表示修改一个entry,changetype的值可以是add,delete, modify等。
add: olcRootPW 表示对这个entry新增了一个olcRootPW的属性
olcRootPW: {SSHA}51JBhgYyPdBnAy8/UbVwMtWzPR4hz/R8 指定了属性值
#使用 ldapadd 命令讲我们上一步自定义的文件属性写入LADP中
[root@master ldap_ldif]# ldapadd -Y EXTERNAL -H ldapi:/// -f password.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={0}config,cn=config"
将全部的schema都导入到ldap中
ls /etc/openldap/schema/*.ldif | while read f; do ldapadd -Y EXTERNAL -H ldapi:/// -f $f; done
我这里输入的是 123456 这个密码用来作为管理员密码,可以与上面的密码不一致
[root@master ldap_ldif]# slappasswd
New password:
Re-enter new password:
{SSHA}mqDbkQdCLjLLai6jkXiuS3IFjoV0q7XQ
[root@master ldap_ldif]# cat domain.ldif
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read by dn.base="cn=Manager,dc=suixingpay,dc=com" read by * none
dn: olcDatabase={2}bdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=suixingpay,dc=com
dn: olcDatabase={2}bdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=Manager,dc=suixingpay,dc=com
dn: olcDatabase={2}bdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}51JBhgYyPdBnAy8/UbVwMtWzPR4hz/R8
dn: olcDatabase={2}bdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange by
dn="cn=Manager,dc=suixingpay,dc=com" write by anonymous auth by self write by * none
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=Manager,dc=suixingpay,dc=com" write by * read
[root@master ldap_ldif]# ldapmodify -Y EXTERNAL -H ldapi:/// -f domain.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={1}monitor,cn=config"
modifying entry "olcDatabase={2}bdb,cn=config"
modifying entry "olcDatabase={2}bdb,cn=config"
modifying entry "olcDatabase={2}bdb,cn=config"
ldap_modify: Inappropriate matching (18)
additional info: modify/add: olcRootPW: no equality matching rule
[root@master ldap_ldif]# cat basedomain.ldif
dn: dc=suixingpay,dc=com
objectClass: top
objectClass: dcObject
objectclass: organization
o: suixingpay com
dc: suixingpay
dn: cn=Manager,dc=suixingpay,dc=com
objectClass: organizationalRole
cn: Manager
description: Directory Manager
dn: ou=People,dc=suixingpay,dc=com
objectClass: organizationalUnit
ou: People
dn: ou=Group,dc=suixingpay,dc=com
objectClass: organizationalUnit
ou: Group
这个位置输入的密码为 三、设定默认域 中设置的密码
[root@master ldap_ldif]# ldapadd -x -D cn=Manager,dc=suixingpay,dc=com -W -f basedomain.ldif
Enter LDAP Password:
adding new entry "dc=suixingpay,dc=com"
[root@master ldap_ldif]# ldapsearch -LLL -W -x -D "cn=Manager,dc=suixingpay,dc=com" -H ldap://localhost -b "dc=suixingpay,dc=com"
Enter LDAP Password:
dn: dc=suixingpay,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: suixingpay com
dc: suixingpay
yum install httpd php php-bcmath php-gd php-mbstring php-xml php-ldap -y
yum install phpldapadmin -y
yum 安装完phpldapadmin 后会默认在 /etc/httpd/conf.d 加入
[root@master conf.d]# cat phpldapadmin.conf
Alias /phpldapadmin /usr/share/phpldapadmin/htdocs
Alias /ldapadmin /usr/share/phpldapadmin/htdocs
<Directory /usr/share/phpldapadmin/htdocs>
<IfModule mod_authz_core.c>
# Apache 2.4
Require local
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.0.0/16 # 这个需要开放网段访问
</IfModule>
</Directory>
[root@master config]# pwd
/usr/share/phpldapadmin/config
[root@master config]# cat config.php
<?php
$servers = new Datastore();
$servers->newServer('ldap_pla');
$servers->setValue('server','name','LDAP Server');
$servers->setValue('server','host','127.0.0.1');
$servers->setValue('server','port',389);
$servers->setValue('server','base',array('dc=suixingpay,dc=com'));
$servers->setValue('login','auth_type','cookie');
$servers->setValue('login','bind_id','cn=Manager,dc=suixingpay,dc=com');
$servers->setValue('login','bind_pass','123456');
$servers->setValue('server','tls',false);
?>
service httpd start
访问地址: http://192.168.13.133:8080/phpldapadmin
标签:shadow 部署 初始 equal class one 定义 openssl example
原文地址:https://www.cnblogs.com/NoSong/p/11904299.html