How to install OpenLDAP on Ubuntu 18.04


LDAP is the Lightweight Directory Access Protocol, which allows for the querying and modification of an X.500-based directory service. LDAP is used over an IP network to manage and access a distributed directory service. The primary purpose of LDAP is to provide a set of records in a hierarchical structure. If you're curious as to how LDAP fits in with Active Directory, think of it this way: Active Directory is a directory service database, and LDAP is one of the protocols used to communicate with it. LDAP can be used for user validation, as well as the adding, updating, and removing of objects within a directory.

I want to show you how to install OpenLDAP on the latest iteration of Ubuntu, and then how to populate an LDAP database with a first entry. All you will need for this is a running instance of Ubuntu 18.04 and a user account with sudo privileges.

And with that said, let's install.

Step 1  Installation

The first thing you'll want to do is run an update/upgrade on the server. Remember, during this process the kernel could be upgraded, which will require a reboot. Because of this, run the update/upgrade during a time when a reboot is feasible.

To take care of the update/upgrade, open a terminal window and issue the commands:

Once that finishes, you're ready to install OpenLDAP. For this, go back to the terminal window and issue the command:


During the installation, you will be asked to create an admin password for the LDAP directory


You can confirm that your installation was successful using the commandslapcat  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:

Now add the file by running the command:

Step 3: Add User Accounts and Groups

Generate a password for the user account to add.


Create ldif file for adding users.

Do the same of group. Create ldif file:

Add group:


  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How to redirect HTTP to HTTPS

If you work with the Apache web server and can change its configuration, follow the Apache...

Install Postfix MTA on Ubuntu 16.04 / 17.10 / 18.04

Postfix is a widely used Mail Transfer Agent (MTA) that most Linux systems use to router email...

How to change the ssh port on Linux or Unix server

I am a new Linux/Unix server admin. How do I change the SSH Port for my Linux or Unix server...

How To Install Docker on Ubuntu 18.04 & 16.04 LTS

  Docker is container-based application framework, which wraps a specific application with all...

Install Apache, MariaDB, PHP and PhpMyAdmin in Ubuntu 18.04

Step 1: Install Apache Web Server on Ubuntu 18.04 1. First start by updating your software...