(Last Updated On: October 20, 2018)

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

How to Install and Configure FreeIPA Server on Ubuntu 18.04 / Ubuntu 16.04

How to Configure FreeIPA Client on Ubuntu 18.04 / Ubuntu 16.04 / CentOS 7

How to Configure FreeIPA replication on Ubuntu / CentOS

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 asldapadd,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/etc/hosts.

sudo hostnamectl set-hostname ldap.example.com
echo " ldap.example.com" | sudo tee -a /etc/hosts

Replace 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 commandslapcat  to output SLAPD database contents.

[email protected]:~# slapcat 
dn: dc=example,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: example.com
dc: example
structuralObjectClass: organization
entryUUID: e2990be6-689b-1038-8d53-cd4ea0a9f2fa
creatorsName: cn=admin,dc=example,dc=com
createTimestamp: 20181020100850Z
entryCSN: 20181020100850.169668Z#000000#000#000000
modifiersName: cn=admin,dc=example,dc=com
modifyTimestamp: 20181020100850Z

dn: cn=admin,dc=example,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
userPassword:: e1NTSEF9ekc4WjVhTSt1RnBrTk1hb1hjRUt4S0cvbk8vSkNUS0k=
structuralObjectClass: organizationalRole
entryUUID: e29b65e4-689b-1038-8d54-cd4ea0a9f2fa
creatorsName: cn=admin,dc=example,dc=com
createTimestamp: 20181020100850Z
entryCSN: 20181020100850.185122Z#000000#000#000000
modifiersName: cn=admin,dc=example,dc=com
modifyTimestamp: 20181020100850Z

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

Replace 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

Enable php7.2-cgi extension

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

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 443

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.

How to install and configure LDAP Account Manager on Ubuntu 18.04 / Ubuntu 16.04 LTS.

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

Wrapping Up

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.