Install LDAP Server in Centos Step by Step

Start by updating CentOS repositories and packages to ensure the latest versions are installed: sudo yum update

Update System Packages

Install the necessary OpenLDAP packages along with the utilities package: sudo yum install openldap openldap-servers openldap-clients

Install OpenLDAP and Utilities

Enable and start the LDAP service to run on boot: sudo systemctl enable slapd sudo systemctl start slapd

Enable and Start OpenLDAP Service

Use the slappasswd command to generate an encrypted password for the LDAP root user: slappasswd

Set LDAP Root Password

Edit the OpenLDAP configuration file to define your root domain and use the encrypted password: sudo nano /etc/openldap/slapd.d/cn=config/olcDatabase={2}hdb.ldif

Configure LDAP Database

Create an .ldif file with the base structure (e.g., domain and users) and load it with: ldapadd -x -D "cn=admin,dc=example,dc=com" -W -f base.ldif

Create Base LDAP Entries

Verify that the LDAP server is running and accessible by querying: ldapsearch -x -b "dc=example,dc=com" -D "cn=admin,dc=example,dc=com" -W

Test LDAP Configuration