{"id":910,"date":"2018-05-08T13:01:08","date_gmt":"2018-05-08T10:01:08","guid":{"rendered":"https:\/\/helia.ee\/koolitus\/?page_id=910"},"modified":"2018-05-08T13:18:41","modified_gmt":"2018-05-08T10:18:41","slug":"debian-how-to-install-openldap-server-on-debian-or-ubuntu","status":"publish","type":"page","link":"https:\/\/helia.ee\/koolitus\/?page_id=910","title":{"rendered":"Debian &#8211; How to install OpenLDAP Server on Debian or Ubuntu"},"content":{"rendered":"<p>This document describes how to install and configure OpenLDAP in Debian\/Ubuntu Server. I will use OpenLDAP to configure a corporate organizational structure through OpenLDAP.<\/p>\n<p>LDAP stands for Lightweight Directory Access Protocol. As the name suggests, it is a lightweight protocol for accessing directory services, specifically X.500-based directory services. LDAP runs over TCP\/IP or other connection oriented transfer services. The nitty-gritty details of LDAP are defined in\u00a0<a href=\"http:\/\/www.rfc-editor.org\/rfc\/rfc2251.txt\" target=\"_blank\" rel=\"noopener\">RFC2251<\/a>\u00a0&#8220;The Lightweight Directory Access Protocol (v3)&#8221; and other documents comprising the technical specification\u00a0<a href=\"http:\/\/www.rfc-editor.org\/rfc\/rfc3377.txt\" target=\"_blank\" rel=\"noopener\">RFC3377<\/a><\/p>\n<p>LDAP is a platform-independent protocol. Several common Linux distributions include OpenLDAP Software for LDAP support. The software also runs on BSD-variants, as well as AIX, Android, HP-UX, Mac OS X, Solaris, Microsoft Windows (NT and derivatives, e.g. 2000, XP, Vista, Windows 7, etc.), and z\/OS.<\/p>\n<div>\n<div id=\"google_ads_div_howtoforge_com_article_rectangle_a_300x250_ad_wrapper\">\n<div id=\"google_ads_div_howtoforge_com_article_rectangle_a_300x250_ad_container\">\n<div><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>This guide will work both in Debian\/Ubuntu server. I do not issue any guarantee that this will work for you!<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"-preliminary-note-\">1 Preliminary Note<\/h3>\n<p>This tutorial is based on Debian 7.6 server, so you should set up a basic Debian 7.6 server installation before you continue with this tutorial. The system should have a static IP address. I use\u00a0<span class=\"system\">192.168.0.100<\/span>\u00a0as my IP address in this tutorial and\u00a0<span class=\"system\">server1.example.com<\/span>\u00a0as the hostname. I am using root credentials for installations, you can use\u00a0<span class=\"system\">sudo<\/span>\u00a0before the commands if you are installing it without\u00a0<span class=\"system\">root<\/span>.<\/p>\n<p class=\"highlight\">Note:The guide can be used for both Ubuntu\/Debian server.<\/p>\n<h3 id=\"-install-openldap\">2 Install OpenLDAP<\/h3>\n<h4 id=\"-openldap-installation\">2.1 OpenLDAP installation<\/h4>\n<p>We will install OpenLDAP as follows:<\/p>\n<p class=\"command\">apt-get update<br \/>\napt-get install slapd ldap-utils<\/p>\n<p><a id=\"img-1\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/1.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/1.png\" alt=\"\" \/><\/a><\/p>\n<p>Put the password and press\u00a0<span class=\"system\">OK<\/span>. I am using password\u00a0<span class=\"system\">howtoforge<\/span>, input your desired password.<\/p>\n<p><a id=\"img-2\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/2.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/2.png\" alt=\"\" \/><\/a><\/p>\n<p>Confirm the password and press\u00a0<span class=\"system\">OK<\/span>.<\/p>\n<h4 id=\"-openldap-configuration\">2.2 OpenLDAP Configuration<\/h4>\n<p>Now we will edit the configuration file to make the OpenLDAP server according to our environment.<\/p>\n<p class=\"command\">nano \/etc\/ldap\/ldap.conf<\/p>\n<p>Give the entries as follows:<\/p>\n<table border=\"1\" width=\"100%\">\n<tbody>\n<tr>\n<td>\n<pre>#\r\n# LDAP Defaults\r\n#\r\n\r\n# See ldap.conf(5) for details\r\n# This file should be world readable but not world writable.\r\n\r\n<strong>BASE    dc=example,dc=com<\/strong>\r\nURI     <strong>ldap:\/\/192.168.0.100 ldap:\/\/192.168.0.100:666<\/strong>\r\n\r\n#SIZELIMIT      12\r\n#TIMELIMIT      15\r\n#DEREF          never\r\n\r\n# TLS certificates (needed for GnuTLS)\r\nTLS_CACERT      \/etc\/ssl\/certs\/ca-certificates.crt\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p class=\"highlight\">Note in my case hostname was server1.example.com so my dc=example and dc=com<\/p>\n<p>Save the file and run the following command to reconfigure the LDAP package.<\/p>\n<p class=\"command\">dpkg-reconfigure slapd<\/p>\n<p>It will ask some questionnaire, we will choose the values as follows:<br \/>\n<a id=\"img-3\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/3.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/3.png\" alt=\"\" \/><\/a><\/p>\n<p>Select\u00a0<span class=\"system\">No<\/span>:<br \/>\n<a id=\"img-4\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/4.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/4.png\" alt=\"\" \/><\/a><\/p>\n<p>Select\u00a0<span class=\"system\">Ok<\/span>:<br \/>\n<a id=\"img-5\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/5.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/5.png\" alt=\"\" \/><\/a><\/p>\n<p>Give any name as per your needs, in my case I am using\u00a0<span class=\"system\">Test-company<\/span>\u00a0as the company name. Further press\u00a0<span class=\"system\">Ok<\/span>.<\/p>\n<p><a id=\"img-6\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/6.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/6.png\" alt=\"\" \/><\/a><\/p>\n<p>Give an administrative password, and confirm the same.<\/p>\n<p><a id=\"img-7\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/7.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/7.png\" alt=\"\" \/><\/a><\/p>\n<p><a id=\"img-8\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/8.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/8.png\" alt=\"\" \/><\/a><\/p>\n<p>Select\u00a0<span class=\"system\">HDB<\/span>\u00a0and press\u00a0<span class=\"system\">Ok<\/span>.<br \/>\n<a id=\"img-9\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/9.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/9.png\" alt=\"\" \/><\/a><\/p>\n<p>Select\u00a0<span class=\"system\">Yes<\/span>.<br \/>\n<a id=\"img-10\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/10.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/10.png\" alt=\"\" \/><\/a><\/p>\n<p>Again select\u00a0<span class=\"system\">Yes<\/span>\u00a0and move the old database files.<br \/>\n<a id=\"img-11\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/11.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/11.png\" alt=\"\" \/><\/a><\/p>\n<p>We don&#8217;t want to use LDAPv2 protocol so select\u00a0<span class=\"system\">No<\/span>.<\/p>\n<p><strong>#vahepeal tuleb ldapi server restartida ja kontrollida kas see t\u00f6\u00f6tab ka<\/strong><br \/>\n<strong>\/etc\/init.d\/slapd restart<\/strong><\/p>\n<p>Now we are done with the configuration, we can check that our installation have all gone well with the command:<\/p>\n<p class=\"command\">ldapsearch -x<\/p>\n<p>It will show output like this:<\/p>\n<address class=\"system\">root@server1:~# ldapsearch -x<br \/>\n# extended LDIF<br \/>\n#<br \/>\n# LDAPv3<br \/>\n# base &lt;dc=example,dc=com&gt; (default) with scope subtree<br \/>\n# filter: (objectclass=*)<br \/>\n# requesting: ALL<br \/>\n## example.com<br \/>\ndn: dc=example,dc=com<br \/>\nobjectClass: top<br \/>\nobjectClass: dcObject<br \/>\nobjectClass: organization<br \/>\no: Test-company<br \/>\ndc: example<\/p>\n<p># admin, example.com<br \/>\ndn: cn=admin,dc=example,dc=com<br \/>\nobjectClass: simpleSecurityObject<br \/>\nobjectClass: organizationalRole<br \/>\ncn: admin<br \/>\ndescription: LDAP administrator<\/p>\n<p># search result<br \/>\nsearch: 2<br \/>\nresult: 0 Success<\/p>\n<p># numResponses: 3<br \/>\n# numEntries: 2<br \/>\nroot@server1:~#<\/p>\n<\/address>\n<p>It shows successful configuration for the OpenLDAP server.<\/p>\n<h3 id=\"-phpldapadmin-installation\">3 phpLDAPadmin installation<\/h3>\n<p>We can administrate the OpenLDAP with commands, but to make it an easier task I will install phpLDAPadmin. We need to have an Apache server and php installed before phpLDAPadmin installation:<\/p>\n<p class=\"command\">apt-get install apache2 php5 php5-mysql<\/p>\n<p>Next we can install phpLDAPadmin as follows:<\/p>\n<p class=\"command\">apt-get install phpldapadmin<\/p>\n<p>Now we need to modify phpLDAPadmin in accordance to our server requirement so that it will get controlled through it, edit the file\u00a0\u00a0<span class=\"system\">\/etc\/phpldapadmin\/config.php<\/span>\u00a0and give the values like this:<\/p>\n<p class=\"command\">nano \/etc\/phpldapadmin\/config.php<\/p>\n<p>Values will be like this:<\/p>\n<table border=\"1\" width=\"100%\">\n<tbody>\n<tr>\n<td>\n<pre>[...]\r\n<strong>$servers = new Datastore();\r\n$servers-&gt;newServer('ldap_pla');\r\n$servers-&gt;setValue('server','name','Test-company LDAP');\r\n$servers-&gt;setValue('server','host','127.0.0.1');\r\n$servers-&gt;setValue('server','base',array('dc=example,dc=com'));\r\n$servers-&gt;setValue('login','bind_id','cn=admin,dc=example,dc=com');<\/strong>\r\n?&gt;\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"highlight\">Note: In above file dc will vary according to your hostname, i have given my company name as Test-company you can use other name as per your choice.<\/p>\n<p>Now open the link\u00a0<span class=\"system\">http:\/\/192.168.0.100\/phpldapadmin<\/span>\u00a0in any browser of your choice.<\/p>\n<p><a id=\"img-12\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/12.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/12.png\" alt=\"\" \/><\/a><\/p>\n<p>Press\u00a0<span class=\"system\">Login<\/span>\u00a0at left of the panel.<\/p>\n<p><a id=\"img-13\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/13.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/13.png\" alt=\"\" \/><\/a><\/p>\n<p>Put the password used at the time of modifying the LDAP, in my case user=<span class=\"system\">admin<\/span>(it is preselected) and password=<span class=\"system\">howtoforge<\/span>.<\/p>\n<p><a id=\"img-14\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/14.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/14.png\" alt=\"\" \/><\/a><\/p>\n<p>It will be your default welcome page.<\/p>\n<h3 id=\"-adding-accounts-in-ldap-\">4 Adding accounts in LDAP<\/h3>\n<p>Next we will create a test entry in the LDAP server and verify the settings in admin panel itself. Suppose we are in a corporate company and we want to classify different teams with\u00a0 different team stucture, such as Teachnical-team, Accounts Department an HR department etc. Now click on\u00a0<span class=\"system\">+<\/span>\u00a0sign\u00a0<span class=\"system\">dc=example, dc=com<\/span>\u00a0and at\u00a0<span class=\"system\">cn=admin<\/span>\u00a0select<span class=\"system\">\u00a0Create a child entry<\/span>.<\/p>\n<p><a id=\"img-15\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/15.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/15.png\" alt=\"\" \/><\/a><\/p>\n<p>To have such functionality in LDAP select\u00a0<span class=\"system\">Generic: Posix Group<\/span><\/p>\n<p><a id=\"img-16\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/16.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/16.png\" alt=\"\" \/><\/a><\/p>\n<p>Next you will be redirected as:<\/p>\n<p><a id=\"img-17\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/17.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/17.png\" alt=\"\" \/><\/a><\/p>\n<p>I am just taking an example, and adding a test entry for\u00a0<span class=\"system\">Technical-team<\/span>\u00a0as my group. Press\u00a0<span class=\"system\">Create Object<\/span>.<\/p>\n<p><a id=\"img-18\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/18.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/18.png\" alt=\"\" \/><\/a><\/p>\n<p>Verify the things and Press\u00a0<span class=\"system\">Commit<\/span>.<\/p>\n<p><a id=\"img-19\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/19.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/19.png\" alt=\"\" \/><\/a><\/p>\n<p>It will create the group As Technical-team, similarily we can create other groups as per our corporate structure.<\/p>\n<p><a id=\"img-20\" class=\"fancybox\" href=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/big\/20.png\"><img decoding=\"async\" src=\"https:\/\/www.howtoforge.com\/images\/howto_install_openldapserver_in_debian_wheezy\/20.png\" alt=\"\" \/><\/a><\/p>\n<p>We can check the groups under\u00a0<span class=\"system\">cn=admin<\/span>\u00a0similarily add other groups as per our needs.<\/p>\n<p>Congratulations! Now we have successfully configured OpenLDAP in Debian Wheezy \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This document describes how to install and configure OpenLDAP in Debian\/Ubuntu Server. I will use OpenLDAP to configure a corporate organizational structure through OpenLDAP. LDAP stands for Lightweight Directory Access Protocol. As the name suggests, it is a lightweight protocol for accessing directory services, specifically X.500-based directory services. LDAP runs over TCP\/IP or other connection [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":621,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-910","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=910"}],"version-history":[{"count":3,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/910\/revisions"}],"predecessor-version":[{"id":913,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/910\/revisions\/913"}],"up":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/621"}],"wp:attachment":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}