(Last Updated On: October 24, 2018)

In this blog post. you’ll get to learn how to Install and configure OpenLDAP on Ubuntu 18.04 LTS. OpenLDAP is a free and open source implementation of the Lightweight Directory Access Protocol developed by the OpenLDAP Project and released under OpenLDAP Public License.

Before you start the installation, set your system hostname and add it to file/etc/hosts.

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

Replace ldap.example.com with your correct hostname/valid domain name. When done, install LDAP packages by running the commands below:

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 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 using our guide to install and configure OpenLDAP server on your Ubuntu 18.04. I recommend installing and using LDAP Account Manager to administer your LDAP server through a web interface.

If you need an 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