Build OpenLDAP server under CentOS7

LDAP is a Lightweight Directory Access Protocol (LDAP). The LDAP Lightweight Directory Access Protocol provides a unified authentication service for user management, which solves the long-standing isolation, complexity and difficulty of maintaining multiple sets of user authentication systems. The problem. With simple, efficient and easy-to-use features, it is the best choice for user authentication management. OpenLDAP is an implementation of open source centralized account management architecture

The following describes how to build an OpenLDAP server under CentOS7, the environment is as follows

1 ) One CentOS7 Linux server IP: 192.168.31.200 To build an OpenLDAP server, the LDAP domain information that needs to be deployed is walkingcloud.cn

2 ) One CentOS7 Linux server IP: 192.168.31.76 as the client machine of OpenLDAP for authentication

Management account information: dn:cn=Manager,dc=walkingcloud,dc=cn

1、 Install OpenLDAP service in yum mode

yum -y install openldap-servers openldap-clients

2、 Copy the database configuration configuration file and start the service

cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

chown ldap. /var/lib/ldap/DB_CONFIG

systemctl start slapd

systemctl enable slapd

3、 slappasswd generates OpenLDAP administrator password

  1. Use the slappasswd command to set the OpenLDAP administrator password and record it

  2. vi chrootpw.ldif

dn: olcDatabase={0}config,cn=config

changetype: modify

add: olcRootPW

olcRootPW: {SSHA}TNFs8yAo1VQ82uMAzK+1o8Q2XRgznBMb

Specify the password string generated by the slappasswd command above

  1. ldapadd -Y EXTERNAL -H ldapi:/// -f chrootpw.ldif

4、 Import basic patterns

ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif

ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif

ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif

5、 Configure domain information on OpenLDAP DB

1 ) Slappasswd generates the administrator's password

2 )vi chdomain.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=walkingcloud,dc=cn" read by * none

dn: olcDatabase={2}hdb,cn=config

changetype: modify

replace: olcSuffix

olcSuffix: dc=walkingcloud,dc=cn

dn: olcDatabase={2}hdb,cn=config

changetype: modify

replace: olcRootDN

olcRootDN: cn=Manager,dc=walkingcloud,dc=cn

dn: olcDatabase={2}hdb,cn=config

changetype: modify

add: olcRootPW

olcRootPW: {SSHA}XnSjDW+kj37E6TdwwkUw1P32ezGkkYPr

dn: olcDatabase={2}hdb,cn=config

changetype: modify

add: olcAccess

olcAccess: {0}to attrs=userPassword,shadowLastChange by

dn="cn=Manager,dc=walkingcloud,dc=cn" write by anonymous auth by self write by * none

olcAccess: {1}to dn.base="" by * read

olcAccess: {2}to * by dn="cn=Manager,dc=walkingcloud,dc=cn" write by * read

3 )ldapmodify -Y EXTERNAL -H ldapi:/// -f chdomain.ldif

4 )vi basedomain.ldif

dn: dc=walkingcloud,dc=cn

objectClass: top

objectClass: dcObject

objectclass: organization

o: Walking Cloud

dc: walkingcloud

dn: cn=Manager,dc=walkingcloud,dc=cn

objectClass: organizationalRole

cn: Manager

description: Directory Manager

dn: ou=People,dc=walkingcloud,dc=cn

objectClass: organizationalUnit

ou: People

dn: ou=Group,dc=walkingcloud,dc=cn

objectClass: organizationalUnit

ou: Group

5 )ldapadd -x -D cn=Manager,dc=walkingcloud,dc=cn -W -f basedomain.ldif

Now enter the Manager’s password

6、 Add a user

  1. slappasswd

New password:

Re-enter new password:

{ SSHA}R8l3FCSfEHN4vrFnTsGc9EOib71HPSN4

  1. vi ldapuser.ldif

dn: uid=yuanfan,ou=People,dc=walkingcloud,dc=cn

objectClass: inetOrgPerson

objectClass: posixAccount

objectClass: shadowAccount

cn: yuanfan

sn: Linux

userPassword: {SSHA}R8l3FCSfEHN4vrFnTsGc9EOib71HPSN4

loginShell: /bin/bash

uidNumber: 1000

gidNumber: 1000

homeDirectory: /home/yuanfan

dn: cn=yuanfan,ou=Group,dc=walkingcloud,dc=cn

objectClass: posixGroup

cn: yuanfan

gidNumber: 1000

memberUid: yuanfan

  1. ldapadd -x -D cn=Manager,dc=walkingcloud,dc=cn -W -f ldapuser.ldif

Enter the administrator's password

7、 OpenLDAP client configuration

1 )yum -y install openldap-clients nss-pam-ldapd

2 )authconfig --enableldap --enableldapauth --ldapserver=192.168.31.200 --ldapbasedn="dc=walkingcloud,dc=cn" --enablemkhomedir --update

  1. Next log in with the LDAP user created above

Enter the password of the openLDAP user, you can log in normally

8、 Install phpLDAPadmin to manage LDAP service through Web

1 )yum install -y httpd

  1. mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf_bak

  2. vi /etc/httpd/conf/httpd.conf

95 Add a line below the line

95 # ServerName www.example.com:80

96 ServerName www.walkingcloud.cn

Change at line 151 to

AllowOverride All

164 Change the line to

DirectoryIndex index.html index.php index.cgi

Add the following two lines at the bottom

ServerTokens Prod

KeepAlive On

systemctl start httpd

systemctl enable httpd.service

  1. Install php

yum install php php-mbstring php-pear

systemctl restart httpd

  1. yum --enablerepo=epel -y install phpldapadmin

  2. vi /etc/phpldapadmin/config.php

397 Uncomment line, comment out line 398

$servers->setValue('login','attr','dn');

//$servers->setValue('login','attr','uid');

  1. vi /etc/httpd/conf.d/phpldapadmin.conf

12 Add the access network segment information at the line, for example 192.168.31.0/24

Require ip 192.168.31.0/24

Then restart httpd service

  1. Verify that phpldapadmin can be opened

11 ) Log in with an administrator account

cn=Manager,dc=walkingcloud,dc=cn

You can see the account yuanfan added before

9、 LDAPadmin client tool

Ldap Admin is a free Windows LDAP client and management tool for LDAP directory management. This application allows you to browse, search, modify, create and delete objects on the LDAP server. It also supports more complex operations, such as directory copying and moving between remote servers, and extends common editing functions to support specific object types (such as groups and accounts).

http://www.ldapadmin.org/

Recommended Posts

Build OpenLDAP server under CentOS7
Build OpenV** Server under CentOS7
Build an FTP server under centos7
How to quickly build Nginx server under CentOS
Build docker environment under Centos6.5
CentOS8.1 build Gitlab server detailed tutorial
Build a PXC cluster under CentOS8
Centos7 build java web server tomcat
CentOS7 build jenkins
Centos build lnmp
Centos7 build python3.8.5+scrapy+gerapy
[PHP] Build a PHP operating environment under CentOS
Build a ScaleIO distributed storage cluster under CentOS7
Build Discuz Forum in LNMP Environment under CentOS7
Centos7 tutorial to build a master-slave DNS server
Notes on installing pptp server under CentOS 7 ok
Build LEMP (Linux+Nginx+MySQL+PHP) environment under CentOS 8.1 (detailed tutorial)
Installation and configuration of rsync server under CentOS 6.5
Build Dedecms website in LNMP environment under CentOS7
CentOS7.3 64 bit, build Zabbix3.4
CentOS build private git
Deploy GitBook under CentOS7
Linux (centos7) build gitlab
Build k8s1.9.9 on centos7
CentOS6.7 build LNMP environment
Centos6.9 build rabbitmq 3.6.8 cluster
CentOS 7.3 + Server JRE 1.8 + Hadoop-2.8.0
Install mysql5.7 under CentOS7
CentOS server deployment (YUM)
Install ActiveMQ under Centos7
Centos7.6 build LNMP environment
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
Centos7 build Kubernetes cluster
Jenkins build on centos
Deploy JDK+Tomcat8 under CentOS
Install mysql under Centos 7
Configure lamp under centos6.8
Build Hadoop in CentOS
Install Jenkins under Centos 7
Redis3 installation under Centos7
Centos7 build DNS service
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
CentOS 7 build LNMP environment
CentOS7.6 server deployment VNC
3 minutes to teach you to build gitea on Centos server
Build a basic environment for Java development under Centos7
Use Rancher to build a K8s cluster under CentOS7
CentOS uses Nginx to build a download function server
Centos8 implementation steps to build a local web server
Xen virtualization combat under CentOS 6.6
[CentOS environment deployment] Java7/Java8 deployment under CentOS
Deploy FTP server under ubuntu
[Linux] Build Samba server (ubuntu16.04)
CentOs7.3 build Solr stand-alone service
CentOs7.3 build RabbitMQ 3.6 stand-alone service
Build zabbix monitoring zabbix4.2 in CentOS7.6
ubuntu 16.04 build pptpd V** server
Redis cluster installation under CentOS
Build zabbix monitoring zabbix4.2 in CentOS7.6