Installing OpenLDAP

This recipe covers the installation and initial configuration of LDAP. The Ubuntu package repository makes the installation easy by providing the required packages for the LDAP service.

Getting ready

You will need access to a root account or an account with sudo privileges.

How to do it…

Let's start with installing the LDAP package and helper utilities:

  1. Update your repository using the apt-get update command and then install the OpenLDAP package, slapd:
    $ sudo apt-get update
    $ sudo apt-get install slapd ldap-utils
    
  2. You will be asked to enter the admin password and to confirm it.
  3. The installation process simply installs the package without any configuration. We need to start the actual configuration process with the reconfiguration of the slapd package. Use the following command to start the re-configuration process:
    $ sudo dpkg-reconfigure slapd
    
  4. This command will ask you a series of questions including the domain name, admin account, password, database type, and others. Match your answers as follows:
    • Omit LDAP server configuration – NO.
    • DNS Domain name – Enter your domain name. You can use any domain name. For this setup, I will be using example.com. This domain name will determine the top structure of your directory:
      How to do it…
    • Organization name – Enter your organization name. I am using example as my organization.
    • Admin password – Enter a password for the admin account. It can be the same as the one entered during installation, or a totally different one. Make sure you note this password as it will be used to access the admin account.
    • Database backend – HDB
      How to do it…
    • Remove the database when slapd is purged - this is about removing the database in case you uninstall the slapd package. Choose NO as you don't want the database to be deleted:
    • Move old database - YES
    • Allow the LDAPv2 protocol - unless you are planning to use some old tools, choose NO:
    How to do it…
  5. Once you have answered all the questions, the process will reconfigure the LDAP service. Now your LDAP service is installed and ready to use:
    How to do it…
  6. Now you can use utility commands to query existing data. To test whether the LDAP service is installed and running properly, use the ldapsearch -x command. You should see output similar to following screenshot:
    How to do it…
  7. Use ldapsearch as follows to query our newly added domain, example.com:
    $ ldapsearch -x -LLL -H ldap:/// -b dc=example,dc=com dn
    
    How to do it…
  8. The following command will query the default content for example.com:
    $ ldapsearch -x -LLL -b dc=example,dc=com
    
    How to do it…

The ldap-utils package also provides more commands to configure the LDAP service, but it is quite a lengthy and complex task. In the next recipe, we will learn how to set up a web-based admin interface that make things a little easier.

How it works…

With the respective packages available in the Ubuntu package repository, installing OpenLDAP is quite an easy task. All we have to do is install the required binaries and then configure the LDAP system to serve our desired domain. We have installed two packages: one is slapd, the LDAP daemon, and the other is ldap-utils, which provides various commands to work with the LDAP daemon. After installation is complete, we have re-configured LDAP to match our required directory setup. We have chosen to go with LDAPv3 API and disabled LDAPv2. If you have any older systems working with LDAPv2, then you will need to enable support for old APIs.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset