Bobcares

How to configure LDAP Client on Ubuntu?

by | Oct 28, 2020

LDAP helps us to provide centralized storage of usernames and passwords. After setting up a working LDAP server, we will need to install libraries and configure the client for connecting to it on an Ubuntu system.

As a part of our Server Management Services, we help our Customers with software installations regularly.

Let us today discuss the steps to configure LDAP Client on Ubuntu.

LDAP and its uses

LDAP (Lightweight Directory Access Protocol) is a set of protocols for accessing directory services.

A directory service stores and provides access to information that must either be shared between applications or is highly distributed.

Directory services play an important role in developing intranet and Internet applications by helping us to share information about users, systems, networks, applications, and services throughout the network.

For instance, it helps us to offer centralized storage of usernames and passwords. This allows various applications (or services) to connect to the LDAP server to validate users.

Install and Configure LDAP Client on Ubuntu

Initially, if we do not have an active DNS server in our network, we need to add an LDAP server address to /etc/hosts file.

$ echo “IP_address ldap.example.com” | sudo tee -a /etc/hosts

Install LDAP client utilities on an Ubuntu system

Now let us proceed to install the LDAP client utilities. Like in all other installation, we need to update the system prior to the installation

$ sudo apt-get update

$ sudo apt -y install libnss-ldap libpam-ldap ldap-utils

During the installation, the package installer will ask us a variety of questions. Enter the values according to the environment.

  1. Set LDAP URI – On the first screen, enter the LDAP server details. Enter the LDAP server’s IP address or hostname.
  2. Set a Distinguished name of the search base – Here enter the DN (Domain Name) of the LDAP search base
  3. Choose the LDAP version to use.
    configure ldap client ubuntu
  4. Select Yes to make local root Database admin
  5. Answer No for Does the LDAP database requires login?
  6. Set LDAP account for root, something like cn=admin,cd=example,cn=com
  7. Provide LDAP root account Password

Configure authentication:

The installer does most of the configurations based on our inputs given in the previous section. But, there are still some changes required for LDAP authentication to work.

After the installation, edit /etc/nsswitch.conf and add LDAP authentication to passwd and group lines.

passwd: compat systemd ldap
group:    compat systemd ldap
shadow: compat ldap

Modify the file /etc/pam.d/common-password. Remove use_authtok on line 26 to look like below.

password [success=1 user_unknown=ignore default=die] pam_ldap.so try_first_pass

Enable creation of home directory on the first login by adding the following line to the end of file /etc/pam.d/common-session

session optional pam_mkhomedir.so skel=/etc/skel umask=077

Restart the nscd service.

$ sudo service nscd restart

Test by switching to a user account on LDAP

root@server1:~# su - bob
Creating directory '/home/bob'.
bob@server1:~$ id
uid=10000(bob) gid=10000(sysadmins) groups=10000(sysadmins)

Use the getent command to get the LDAP entries from the LDAP server.

$ getent passwd ldapuser

ldapuser:x:9999:100:Test LdapUser:/home/ldapuser:/bin/bash

Further, to verify the LDAP, log in using the LDAP user “ldapuser” on the client machine.

[Need any further assistance to configure LDAP client on Ubuntu – We’re available 24*7]

Conclusion

In short, LDAP is a widely used protocol for querying and modifying a directory service. Today, we saw how our Support Engineers configure LDAP client on Ubuntu

 

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

8 Comments

  1. Amit

    Thanks for the configuration details.

    I am able to login ldap user while server is in network.
    But if i removed the network user not able to logged in (Ubuntu) machine

    Reply
    • Hiba Razak

      Hi,

      Our Experts can help you with the issue, we’ll be happy to talk to you on chat (click on the icon at right-bottom).

      Reply
    • aditya khandal

      hey , can you text me !! i want to know more about ldap !!

      Reply
      • Hiba Razak

        Hi,
        Please contact our support team via live chat(click on the icon at right-bottom).

        Reply
  2. Oscar

    I have a question, I use openldap user ssh is ok, but when to login to GUI, after fill in username and password, it will back to login page, what should I do?

    Reply
    • Hiba Razak

      Hi,
      Please contact our support through live chat(click on the icon at right-bottom).

      Reply
  3. Divya

    I followed the article and hit this error message.

    ~$ sudo service nscd restart
    Failed to restart nscd.service: Unit nscd.service not found.

    Reply
    • Hiba Razak

      Hi,
      Please contact our support team through live chat (click on the icon at right-bottom).

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF