CentOS

How to Set up OpenLDAP on CentOS 8

This blog will give a brief on OpenLDAP on Centos 8 because OpenLDAP is a server software that works in Linux distributions, also known as the OpenLDAP Public License. In which LDAP is an independent protocol.

How to Set up OpenLDAP on CentOS 8

  • This is a free source for OpenLDAP on the LDAP protocol. And OpenLDAP is considered to be LDAP, but it is software and lightweight LDAP.
  • OpenLDAP is widely used due to its flexibility and cost savings, and it works well with Windows. However, users of Mac, Linux, and others also choose it.
  • It can also be compared to Microsoft’s Active Directory.
  • An LDAP server is a non-relational database that Access is optimized for use but not for writing data.
  • The LDAP server essentially serves to store users’ names and passwords in a centralized server. Against which it can authenticate for further use of existing applications and services.
  • It is mainly used as a backend or for the address book.
  • Software packages have emerged to streamline LDAP directory creation, implementation, and management. The first is OpenLDAP which streamlines directory creation, implementation, and management.

Now, let’s understand how to set up OpenLDAP. This will require root or sudo.

OpenLDAP does not come directly with Centos 8, so it has to be updated with the apt command “sudo update -y”.

Now, we will install the OpenLDAP server using the command “sudo install openldap openldap-servers -y”.

The following command, “install openldap-clients -y” will install the OpenLDAP client.

After this, to start the sldap service and immediately stop it, use the following two commands:

"systemctl start slapd"

"systemctl enable slapd"

Now, the root password has to be set through the password command, for which the command is “slappasswd”.

Next, take the old password in it and use the two following commands to configure it:

"vi ldaprootpasswd.ldif"

"ldapadd -Y EXTERNAL -H ldapi:/// -f ldaprootpasswd.ldif"

After configuration, it has to use the appropriate command for OpenLDAP sample configuration:

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

chown -R ldap:ldap /var/lib/ldap/DB_CONFIG

systemctl restart slapd

Then, the following two commands are used to add the domain to it and make some changes:

vi ldapdomain.ldif

ldapmodify -Y EXTERNAL -H ldapi:/// -f ldapdomain.ldif

Now, the process of adding the database is done with these commands:

cat baseldapdomain.ldif

ldapadd -x -D cn=service,dc=test,dc=com -W -f baseldapdomain.ldif

Then, let us use the following command to create LDAP users and groups:

useradd cyberithub

passwd cyberithub

vi ldapgroup.ldif

ldapadd -x -W -D "cn=service,dc=test,dc=com" -f ldapgroup.ldif

The last step is to create and define LDAP, and then, use the command to test it.

vi ldapuser.ldif

ldapadd -x -D cn=service,dc=test,dc=com -W -f ldapuser.ldif

authconfig --enableldap --enableldapauth --ldapserver=ldap.test.com --ldapbasedn="dc=test,dc=com" --enablemkhomedir --update

Conclusion

In this article, we discussed the uses and features of OpenLDAP in Centos 8. Also, how it is set up in the system is shown in this article. We hope that this article will be useful for you.

About the author

Ankit Sharma