How to install OpenLDAP on Ubuntu 18.04 – A quick and easy guide

How to install OpenLDAP on Ubuntu 18.04 - A quick and easy guide

You want to install OpenLDAP on Ubuntu 18.04 and you’re looking at the man pages and getting confused? Well, that’s why we’re here, to help you! In this guide we will show you how to install OpenLDAP on Ubuntu 18.04 in just a few steps (and configure it too). Let’s get started!


Ubuntu is one of the most popular Linux distributions. It has a wide variety of packages and repositories that can be installed with a few clicks in the software center, but it’s also possible to install additional software from the command line using apt-get or aptitude. One piece of software that you might need for network administration is OpenLDAP, which you can use for authentication, authorization, and data storage via LDAP directories. There are two steps for installing this on Ubuntu 18.04: first installing some dependencies needed by the package manager, then actually installing it with apt-get or aptitude based on your needs.

For example, if you’re trying to configure an existing LDAP directory server as a replica of an existing master server elsewhere, you’ll want to do ‘apt-get install slapd ldb-tools’ rather than just ‘apt-get install openldap’. You may have noticed that there was no mention of installing bind9 in order to run slapd. That’s because Ubuntu already includes the BIND DNS server, so binding slapd and BIND together isn’t necessary. Note that if you’re running systemd (Ubuntu 18.04 uses this instead of unit), then your installation will differ slightly due to some changes made by Ubuntu developers and Debian packagers.


  •  You need a running Linux Server with root access (Ubuntu, CentOS)
  •  You’ll need an LDAP client that can connect to the localhost port 389
  •  Open Terminal and type: sudo apt-get update sudo apt-get upgrade sudo apt-get install openldap ldap-utils slapd ldapconf bind9 krb5-user avahi-daemon libkrb5-dev bison libpcre3-dev systemctl start slapd systemctl enable slapd
  • Sudo ldapadd -x -D cn=Manager,dc=example,dc=com
  • Sudo ldapiadd -x -D cn=Manager,dc=example,dc=com
  • Sudo service avahi-daemon restart
  • Sudo service krb5-configurator restart

Install OpenLDAP

To install OpenLDAP, open terminal and type: sudo apt update && sudo apt upgrade && sudo apt-get install slapd ldap-utils && sudo systemctl enable slapd && sudo systemctl restart slapd -Accessing LDAP Server with ADAMon: The default LDAP port is 389, but it is not configurable from the GUI configuration file.

The default LDAP password for localhost is secret. If you have a firewall or an intrusion prevention system (IPS) that does not allow outgoing traffic on TCP port 389 (default LDAP), use TCP port 636 instead. For instance, if your internal LDAP server was running at IP address, then the remote connection command would be like this:

ldapsearch -x -h –binddn cn=adminuser–bindpw mypasswd –port 636 uid=* uid

Create a user account

Open up a terminal window and type in the following: sudo su apt-get update && apt-get upgrade The first command will make sure you have the latest updates for your distribution of Linux, while the second command will update any outdated packages for your software library. Next, type in apt-cache search openldap This command will search for any packages that match openldap in the package name or description. You should see a list of all possible packages related to LDAP that are available for installation on Ubuntu 18.04 from this point forward. Scroll through the list until you find one titled openldap-servers. Click on it and then press Enter to install it (or use the arrow keys if your keyboard has them). When asked whether to continue with the installation, type in y followed by pressing Enter.

To create an account, use these commands: dpkg-query -W –showformat=’$

‘ grep ldap_2 cut -f1 -d ‘:’ sort > /tmp/mylist ls /tmp/mylist xargs chown root: root;chmod 644 ./chowned_files/*

Test access

You can test the installation by running: sudo ldapsearch -x -LLL cn=test1,dc=example,dc=com

You should get an output that looks something like this:

cn = test1,dc = example,dc = com ), sAMAccountName ( cn = test1 ), userPassword (secret), givenName (John), surname (Doe), uidNumber (1025). OpenLDAP is a mature open-source software package for LDAP directory services that provides all of the features needed for a full-featured directory service.

Ubuntu is one of the most popular Linux distributions used in server environments due to its relative ease of use, generous support options, and moderate price point.

Installing LDAP server on Ubuntu 18.04 is a straightforward process using packages from their default repositories as well as external sources such as APT from other repositories or binary packages from external vendors such as Red Hat or Novell/SUSE.