OpenLDAP is a free, open-source implementation of the Lightweight Directory Access Protocol (LDAP). With it, you can get a centralized authentication between the members of a network. So, I will show you how to install OpenLDAP on Ubuntu 18.04.
Let’s do it.
0. What you need
Also, your user needs to be able to execute commands with sudo because some commands require root.
With this in mind, you can start the installation without problems.
1. Upgrade the system
In the first place, you need to upgrade the system. It is recommended to get the latest security patches on your system.
:~$ sudo apt update && sudo apt upgrade
Now, you can continue.
2. Set the hostname
The first step is to define the hostname. Run this command:
:~$ sudo hostnamectl set-hostname ldap.osradar.local
And add it to your
:~$ echo "192.168.250.6 ldap.osradar.com" | sudo tee -a /etc/hosts
3. Install OpenLDAP
A great advantage of OpenLDAP is that its packages are in the official Ubuntu repositories, which makes installation easy. Just write the following.
:~$ sudo apt install slapd ldap-utils
After downloading the package and during installation you will have to define and confirm the root password.
If you wish to verify that the installation has been carried out effectively. You can use the following command:
:~$ sudo slapcat
As you can see in the image above, OpenLDAP is installed correctly.
4. Add base dn for Users and Groups
it is now necessary to configure OpenLDAP. To do this, the first step is to add to base DN for users and groups.
Create a file called
basedn.ldif in your home folder or wherever you want.
:~$ nano basedn.ldif
And add the following:
dn: ou=people,dc=example,dc=com objectClass: organizationalUnit ou: people dn: ou=groups,dc=example,dc=com objectClass: organizationalUnit ou: groups
Of course, replace
com, for your domain properties.
Next, add the configuration file. Run:
:~$ ldapadd -x -D cn=admin,dc=osradar,dc=local -W -f basedn.ldif
Next, install phpLDAPadmin.
5. Install phpLDAPadmin
In order to manage OpenLDAP in a quick and easy way is that you have to install phpLDAPadmin. Let’s do it.
First, install some necessary packages. Among them are Apache web server and PHP.
:~$ sudo apt install apache2 php php-cgi libapache2-mod-php php-mbstring php-common php-pear
Next, it is necessary to enable the php7.2-cgi extension. Then, restart Apache service.
:~$ sudo a2enconf php7.2-cgi :~$ sudo systemctl reload apache2
Then install phpLDAPadmin.
:~$ sudo apt install phpldapadmin
The next step is to modify the permissions in the phpLDAPadmin configuration file to receive requests from network members.
:~$ sudo nano /etc/apache2/conf-enabled/phpldapadmin.conf
And leave it as I show you in the picture.
With this, we are simply telling phpLDAPadmin to accept requests from network members.
Then, restart Apache.
:~$ sudo systemctl restart apache2
If you use
ufw, you must open ports 80 and 443.
:~$ sudo ufw allow 80 :~$ sudo ufw allow 443
Finally, open your favorite web browser and go to
Next, log in.
Finally, you will see this.
And that’s it.
As you can see OpenLDAP is easy to install and configure in Ubuntu, it just remains that you can configure it to your needs.
Please share this article with friends.