{"id":11742,"date":"2019-03-16T04:18:35","date_gmt":"2019-03-16T04:18:35","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11742"},"modified":"2019-03-16T04:18:35","modified_gmt":"2019-03-16T04:18:35","slug":"how-to-configure-ldap-client-to-connect-external-authentication","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/16\/how-to-configure-ldap-client-to-connect-external-authentication\/","title":{"rendered":"How to Configure LDAP Client to Connect External Authentication"},"content":{"rendered":"<p><strong>LDAP<\/strong>\u00a0(short for\u00a0<strong>Lightweight Directory Access Protocol<\/strong>) is an industry standard, widely used set of protocols for accessing directory services.<\/p>\n<p>A directory service in simple terms is a centralized, network-based database optimized for read access. It stores and provides access to information that must either be shared between applications or is highly distributed.<\/p>\n<p>Directory services play an important role in developing intranet and Internet applications by helping you share information about users, systems, networks, applications, and services throughout the network.<\/p>\n<p>A typical use case for\u00a0<strong>LDAP<\/strong>\u00a0is to offer a centralized storage of usernames and passwords. This allows various applications (or services) to connect to the LDAP server to validate users.<\/p>\n<p>After setting up a working\u00a0<strong>LDAP<\/strong>\u00a0server, you will need to install libraries on the client for connecting to it. In this article, we will show how to configure an LDAP client to connect to an external authentication source.<\/p>\n<p>I hope you already having a working LDAP server environment, if not\u00a0<a href=\"https:\/\/www.tecmint.com\/install-openldap-server-for-centralized-authentication\/\" target=\"_blank\" rel=\"noopener\">setup Up LDAP Server for LDAP-based Authentication<\/a>.<\/p>\n<h3>How to Install and Configure LDAP Client in Ubuntu and CentOS<\/h3>\n<p>On the client systems, you will needs to install a few necessary packages to make authentication mechanism function correctly with an LDAP server.<\/p>\n<h4>Configure LDAP Client in Ubuntu 16.04 and 18.04<\/h4>\n<p>First start by installing the necessary packages by running the following command.<\/p>\n<pre>$ sudo apt update &amp;&amp; sudo apt install libnss-ldap libpam-ldap ldap-utils nscd\r\n<\/pre>\n<p>During the installation, you will be prompted for details of your\u00a0<strong>LDAP<\/strong>\u00a0server (provide the values according to your environment). Note that the\u00a0<strong>ldap-auth-config<\/strong>\u00a0package which is auto-installed does the most of the configurations based on the inputs you enter.<\/p>\n<div id=\"attachment_31318\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/enter-ldap-server-uri.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31318\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/enter-ldap-server-uri.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/enter-ldap-server-uri.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/enter-ldap-server-uri-768x439.png 768w\" alt=\"Enter LDAP Server URI\" width=\"802\" height=\"458\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Enter LDAP Server URI<\/p>\n<\/div>\n<p>Next, enter the name of the LDAP search base, you can use the components of their domain names for this purpose as shown in the screenshot.<\/p>\n<div id=\"attachment_31319\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/provide-ldap-search-base.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31319\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/provide-ldap-search-base.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/provide-ldap-search-base.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/provide-ldap-search-base-768x439.png 768w\" alt=\"Enter LDAP Search Base\" width=\"802\" height=\"458\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Enter LDAP Search Base<\/p>\n<\/div>\n<p>Also choose the LDAP version to use and click\u00a0<strong>Ok<\/strong>.<\/p>\n<div id=\"attachment_31320\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/choose-ldap-version.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31320\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/choose-ldap-version.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/choose-ldap-version.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/choose-ldap-version-768x439.png 768w\" alt=\"Select LDAP Version\" width=\"802\" height=\"458\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Select LDAP Version<\/p>\n<\/div>\n<p>Now configure the option to allow you to make password utilities that use\u00a0<strong>pam<\/strong>\u00a0to behave like you would be changing local passwords and click\u00a0<strong>Yes<\/strong>\u00a0to continue..<\/p>\n<div id=\"attachment_31321\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/accept-option-to-make-local-root-db-admin.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31321\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/accept-option-to-make-local-root-db-admin.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/accept-option-to-make-local-root-db-admin.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/accept-option-to-make-local-root-db-admin-768x439.png 768w\" alt=\"Make Local Root Database Admin\" width=\"802\" height=\"458\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Make Local Root Database Admin<\/p>\n<\/div>\n<p>Next, disable login requirement to the LDAP database using the next option.<\/p>\n<div id=\"attachment_31322\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/disable-login-to-the-ldap-db.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31322\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/disable-login-to-the-ldap-db.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/disable-login-to-the-ldap-db.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/disable-login-to-the-ldap-db-768x439.png 768w\" alt=\"Disable Login to LDAP Database\" width=\"802\" height=\"458\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Disable Login to LDAP Database<\/p>\n<\/div>\n<p>Also define LDAP account for root and click Ok.<\/p>\n<div id=\"attachment_31323\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/define-ldap-account-for-root.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31323\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/define-ldap-account-for-root.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/define-ldap-account-for-root.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/define-ldap-account-for-root-768x439.png 768w\" alt=\"Define LDAP Account for Root\" width=\"802\" height=\"458\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Define LDAP Account for Root<\/p>\n<\/div>\n<p>Next, enter the password to use when\u00a0<strong>ldap-auth-config<\/strong>\u00a0tries to login to the LDAP directory using the LDAP account for root.<\/p>\n<div id=\"attachment_31324\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/enter-ldap-root-password.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31324\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/enter-ldap-root-password.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/enter-ldap-root-password.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/enter-ldap-root-password-768x439.png 768w\" alt=\"Enter LDAP Root Password\" width=\"802\" height=\"458\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Enter LDAP Root Password<\/p>\n<\/div>\n<p>The results of the dialog will be stored in the file\u00a0<strong>\/etc\/ldap.conf<\/strong>. If you want to make any alterations, open and edit this file using your favorite command line editor.<\/p>\n<p>Next, configure the LDAP profile for NSS by running.<\/p>\n<pre>$ sudo auth-client-config -t nss -p lac_ldap\r\n<\/pre>\n<p>Then configure the system to use LDAP for authentication by updating\u00a0<a href=\"https:\/\/www.tecmint.com\/configure-pam-in-centos-ubuntu-linux\/\" target=\"_blank\" rel=\"noopener\">PAM configurations<\/a>. From the menu, choose LDAP and any other authentication mechanisms you need. You should now be able to log in using LDAP-based credentials.<\/p>\n<pre>$ sudo pam-auth-update\r\n<\/pre>\n<div id=\"attachment_31326\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Configure-PAM-Authentication-Mechanism.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31326\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Configure-PAM-Authentication-Mechanism.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Configure-PAM-Authentication-Mechanism.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Configure-PAM-Authentication-Mechanism-768x439.png 768w\" alt=\"Configure PAM Authentication Mechanism\" width=\"802\" height=\"458\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Configure PAM Authentication Mechanism<\/p>\n<\/div>\n<p>In case you want the home directory of the user to be created automatically, then you need to perform one more configuration in the common-session PAM file.<\/p>\n<pre>$ sudo vim \/etc\/pam.d\/common-session\r\n<\/pre>\n<p>Add this line in it.<\/p>\n<pre>session required pam_mkhomedir.so skel=\/etc\/skel umask=077\r\n<\/pre>\n<p>Save the changes and close the file. Then restart the\u00a0<strong>NCSD<\/strong>\u00a0(<strong>Name Service Cache Daemon<\/strong>) service with the following command.<\/p>\n<pre>$ sudo systemctl restart nscd\r\n$ sudo systemctl enable nscd\r\n<\/pre>\n<p><strong>Note<\/strong>: If you are using replication, LDAP clients will need to refer to multiple servers specified in\u00a0<strong>\/etc\/ldap.conf<\/strong>. You can specify all the servers in this form:<\/p>\n<pre>uri ldap:\/\/ldap1.example.com  ldap:\/\/ldap2.example.com\r\n<\/pre>\n<p>This implies that the request will time out and if the\u00a0<strong>Provider<\/strong>\u00a0(<strong>ldap1.example.com<\/strong>) becomes unresponsive, the\u00a0<strong>Consumer<\/strong>\u00a0(<strong>ldap2.example.com<\/strong>) will attempt to be reached to process it.<\/p>\n<p>To check the LDAP entries for a particular user from the server, run the\u00a0<strong>getent command<\/strong>, for example.<\/p>\n<pre>$ getent passwd tecmint\r\n<\/pre>\n<p>If the above command displays details of the specified user from the\u00a0<strong>\/etc\/passwd<\/strong>\u00a0file, your client machine is now configured to authenticate with the LDAP server, you should be able to log in using LDAP-based credentials.<\/p>\n<h3>Configure LDAP Client in CentOS 7<\/h3>\n<p>To install the necessary packages, run the following command. Note that in this section, if you are operating the system as a non-root administrative user, use the\u00a0<strong>sudo command<\/strong>\u00a0to run all commands.<\/p>\n<pre># yum update &amp;&amp; yum install openldap openldap-clients nss-pam-ldapd\r\n<\/pre>\n<p>Next, enable the client system to authenticate using LDAP. You can use the\u00a0<strong>authconfig<\/strong>\u00a0utility, which is an interface for configuring system authentication resources.<\/p>\n<p>Run the following command and replace\u00a0<strong>example.com<\/strong>\u00a0with your domain and\u00a0<strong>dc=example,dc=com<\/strong>\u00a0with your LDAP domain controller.<\/p>\n<pre># authconfig --enableldap --enableldapauth --ldapserver=ldap.example.com --ldapbasedn=\"dc=example,dc=com\" --enablemkhomedir --update\r\n<\/pre>\n<p>In the above command, the\u00a0<code>--enablemkhomedir<\/code>\u00a0option creates a local user home directory at the first connection if none exists.<\/p>\n<p>Next, test if the LDAP entries for a particular user from the server, for example user\u00a0<strong>tecmint<\/strong>.<\/p>\n<pre>$ getent passwd tecmint\r\n<\/pre>\n<p>The above command should display details of the specified user from the\u00a0<strong>\/etc\/passwd<\/strong>\u00a0file, which implies that the client machine is now configured to authenticate with the LDAP server.<\/p>\n<p><strong>Important<\/strong>: If\u00a0<a href=\"https:\/\/www.tecmint.com\/enable-or-disable-selinux-boolean-values\/\" target=\"_blank\" rel=\"noopener\">SELinux is enabled on your system<\/a>, you need to add a rule to allow creating home directories automatically by\u00a0<strong>mkhomedir<\/strong>.<\/p>\n<div class=\"google-auto-placed ap_container\">\n<p>For more information, consult the appropriate documentation from\u00a0<a href=\"https:\/\/www.openldap.org\/doc\/\" target=\"_blank\" rel=\"nofollow noopener\">OpenLDAP Software document catalog<\/a>.<\/p>\n<h5>Summary<\/h5>\n<p><strong>LDAP<\/strong>, is a widely used protocol for querying and modifying a directory service. In this guide, we have shown how to configure an LDAP client to connect to an external authentication source, in Ubuntu and CentOS client machines. You can leave any questions or comments you may have using the feedback form below.<\/p>\n<p><a style=\"font-size: 1rem;\" href=\"https:\/\/www.tecmint.com\/configure-ldap-client-to-connect-external-authentication\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>LDAP\u00a0(short for\u00a0Lightweight Directory Access Protocol) is an industry standard, widely used set of protocols for accessing directory services. A directory service in simple terms is a centralized, network-based database optimized for read access. It stores and provides access to information that must either be shared between applications or is highly distributed. Directory services play an &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/16\/how-to-configure-ldap-client-to-connect-external-authentication\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Configure LDAP Client to Connect External Authentication&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11742","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11742"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11742\/revisions"}],"predecessor-version":[{"id":11743,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11742\/revisions\/11743"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}