OpenLDAP is a free and open source implementation of the Lightweight Directory Access Protocol developed by the OpenLDAP Project. OpenLDAP is released under OpenLDAP Public License. In this guide, we’ll look at how to install OpenLDAP and phpLDAPadmin on Ubuntu 18.04 LTS, and later add user accounts for central authentication in your Network.
Iyou need advanced centralized user management platform, see
What is phpLDAPadmin?
phpLDAPadmin is a web-based PHP application for administering Lightweight Directory Access Protocol servers. phpLDAPadmin is licensed under the GNU General Public License.
This tool exists to ease your OpenLDAP administration often done through commands such as
ldapadd,ldapdelete, ldapmodify, ldapsearch e.t.c.
Step 1: Install OpenLDAP on Ubuntu 18.04 LTS
We’ll start with the installation of OpenLDAP on Ubuntu 18.04 LTS. Set your system hostname and add it to file
sudo hostnamectl set-hostname ldap.example.com echo "192.168.18.50 ldap.example.com" | sudo tee -a /etc/hosts
ldap.example.com with your correct hostname/valid domain name.
The OpenLDAP packages are available on Ubuntu 18.04 upstream repositories, and you install them by just firing apt install commands.
sudo apt update sudo apt -y install slapd ldap-utils
During the installation, you’ll be prompted to set LDAP
admin password, provide your desired password, then press <OK>
Confirm the password and continue installation by selecting <ok> with TAB key.
You can confirm that your installation was successful using the command
slapcat to output SLAPD database contents.
Step 2: Add base dn for Users and Groups
The next step is adding a base DN for users and groups. Create a file named
basedn.ldif with below contents:
dn: ou=people,dc=example,dc=com objectClass: organizationalUnit ou: people dn: ou=groups,dc=example,dc=com objectClass: organizationalUnit ou: groups
example and com with your correct domain components.
Now add the file by running the command:
$ ldapadd -x -D cn=admin,dc=example,dc=com -W -f basedn.ldif Enter LDAP Password: adding new entry "ou=people,dc=example,dc=com" adding new entry "ou=groups,dc=example,dc=com"
Step 3: Install phpLDAPadmin on Ubuntu 18.04 LTS
Once we have OpenLDAP running, it is time to install phpLDAPadmin which will help you manage your LDAP server. phpLDAPadmin requires PHP and Apache web server installed on your Ubuntu system.
sudo apt -y install apache2 php php-cgi libapache2-mod-php php-mbstring php-common php-pear
sudo a2enconf php7.2-cgi sudo systemctl reload apache2
Install phpLDAPadmin by running the command:
sudo apt -y install phpldapadmin
Modify access permissions on
/etc/apache2/conf-enabled/phpldapadmin.conf to allow access only from your trusted subnets.
Order deny,allow Deny from all Allow from 127.0.0.1 192.168.18.0/24
You’ll need to restart apache web server after making the change:
sudo systemctl restart apache2
If you have active UFW firewall, open port
80 and port
sudo ufw allow proto tcp from any to any port 80,443
To access phpLDAPadmin, you’ve to access:
http://(server’s hostname or IP address)/phpldapadmin
Use a client machine allowed from the network to access the dashboard.
Click the “login” button at the top left corner to login to the admin dashboard.
Login DN: cn=admin,dc=example,dc=com Password: Use the admin password configured earlier.
Step 4: Install LDAP Account Manager on Ubuntu 18.04 LTS – Recommended
I noticed phpLDAPadmin doesn’t work well with PHP 7.2 which is a default version of PHP on Ubuntu 18.04. I recommend you use LDAP Account Manager instead. Follow our guide below to install and configure LDAP Account Manager on Ubuntu 18.04.
The guide also shows you how to add user accounts and groups to your LDAP server.
Step 6: Configure your Ubuntu 18.04 as LDAP Client
The last step is to configure the systems in your network to authenticate against the LDAP server we’ve just configured:
How to configure Ubuntu 18.04 LTS as LDAP Client
Thanks for installing and configuring your LDAP authentication environment using our guides. Until next time, I want to thank you for visiting. Don’t forget to follow us on social media to get the latest updates.