OpenLDAP is an open-source implementation of the Lightweight Directory Access Protocol (LDAP), which is a popular protocol for managing and organizing user and group information. It is commonly used in large organizations to centralize user and group information, making it easier to manage and access. In this article, we will explain how to install and configure OpenLDAP on Ubuntu 22.04.
To begin, we need to update our system packages and install the necessary dependencies:
sudo apt update
sudo apt install -y libsasl2-dev libldap2-dev
Next, we need to download and extract the latest version of OpenLDAP from the project’s website:
wget <https://download.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.4.56.tgz>
tar -xzf openldap-2.4.56.tgz
cd openldap-2.4.56
Now we are ready to compile and install OpenLDAP. First, we need to configure the build process with the ./configure
script:
./configure --prefix=/usr/local/openldap \\
--enable-dynamic \\
--enable-crypt \\
--enable-slapd \\
--enable-spasswd \\
--enable-modules \\
--enable-rlookups \\
--enable-backends=mod \\
--disable-ndb
This will configure OpenLDAP to be installed in the /usr/local/openldap
directory, with a number of optional features enabled, such as support for dynamic loading of modules and encryption.
Next, we can compile and install OpenLDAP with the following commands:
make
sudo make install
This will compile the OpenLDAP source code and install it to the specified prefix directory.
Once OpenLDAP is installed, we need to create a directory for the OpenLDAP database and set the ownership and permissions appropriately:
sudo mkdir -p /usr/local/openldap/var/openldap-data
sudo chown -R ldap:ldap /usr/local/openldap/var/openldap-data
sudo chmod -R 700 /usr/local/openldap/var/openldap-data
Next, we need to create a default configuration file for OpenLDAP. We can do this by copying the sample configuration file and modifying it as needed:
sudo cp /usr/local/openldap/etc/openldap/slapd.conf.default /usr/local/openldap/etc/openldap/slapd.conf
We can then edit the slapd.conf
file to specify the directory for the OpenLDAP database and set the root password for the directory:
database bdb
suffix "dc=my-domain,dc=com"
rootdn "cn=Manager,dc=my-domain,dc=com"
rootpw secret
Once the configuration is in place, we can start the OpenLDAP server with the following command:
sudo /usr/local/openldap/libexec/slapd -u ldap -h "