{"id":2519,"date":"2021-05-11T10:42:24","date_gmt":"2021-05-11T08:42:24","guid":{"rendered":"https:\/\/possiblelossofprecision.net\/?p=2519"},"modified":"2021-05-15T11:46:36","modified_gmt":"2021-05-15T09:46:36","slug":"ldap-server-with-389ds-part-1-installation","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=2519","title":{"rendered":"LDAP server with 389ds: Part 1 &#8211; Installation"},"content":{"rendered":"<p>The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Lightweight_Directory_Access_Protocol\">Lightweight Directory Access Protocol<\/a> or LDAP for short has been around for quite a while. While more modern technologies like <a href=\"https:\/\/en.wikipedia.org\/wiki\/OpenID\">OpenID<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/OAuth\">OAuth<\/a> or <a href=\"https:\/\/en.wikipedia.org\/wiki\/Security_Assertion_Markup_Language\">SAML<\/a> are often used for authentication and authorisation purposes when it comes to applications, APIs etc. on the internet these days, LDAP is still widely used for various use cases. For same-sign on purposes it is the de-facto industry standard as a reliable and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Single_sign-on#Security\">secure<\/a> technology and will probably stay relevant for a really long time to come.<\/p>\n<p>There are quite a few <a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_LDAP_software#Server_software\">LDAP server implemenations<\/a>, the most prominent probably Microsoft&#8217;s <a href=\"https:\/\/en.wikipedia.org\/wiki\/Active_Directory\">Active Directory<\/a> and <a href=\"https:\/\/en.wikipedia.org\/wiki\/OpenLDAP\">OpenLDAP<\/a>. Two notable free and open source implementations with a more modern codebase than OpenLDAP are <a href=\"https:\/\/en.wikipedia.org\/wiki\/Apache_Directory\">Apache Directory<\/a> and Redhat&#8217;s <a href=\"https:\/\/en.wikipedia.org\/wiki\/389_Directory_Server\">389 Directory Server<\/a>. Both do work really well but since ApacheDS lacks at least some features (e.g. <a href=\"https:\/\/issues.apache.org\/jira\/browse\/DIRSERVER-1844\">https:\/\/issues.apache.org\/jira\/browse\/DIRSERVER-1844<\/a>, the importance and implications of this, of course, depend on the use case) this series of posts will look at the 389 Directory Server and how to set it up in a secure manner.<\/p>\n<p><!--more--><\/p>\n<h2>1. Installation<\/h2>\n<p>Installation on Fedora or RHEL\/CentOS is farily straightforward:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ndnf install 389-ds-base\r\n<\/pre>\n<p>The 389 admin console that&#8217;s still referred to in some places in the <a href=\"https:\/\/directory.fedoraproject.org\/docs\/389ds\/documentation.html\">official documentation<\/a> has been <a href=\"https:\/\/lists.fedorahosted.org\/archives\/list\/389-users@lists.fedoraproject.org\/thread\/7G2Y2ZYBYB7JNOCMIGV5WQMYDAWSD6VM\/\">deprecated<\/a> for a while. If you still want to use a graphical user interface to interact with 389ds there is a UI plugin for cockpit that can be installed through<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ndnf install cockpit-389-ds\r\n<\/pre>\n<p>However, this does not have all the features of the original admin console implemented yet (e.g. <a href=\"https:\/\/github.com\/389ds\/389-ds-base\/issues\/4299\">users and groups management<\/a>). A convenient tool to complement the cockpit UI plugin in this regard is <a href=\"https:\/\/directory.apache.org\/studio\/downloads.html\">Apache Directory Studio<\/a>.<\/p>\n<p>Cockpit can be enabled and started right away:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsystemctl enable --now cockpit.socket\r\n<\/pre>\n<p>After that it&#8217;s available at <code>https:\/\/yourhost:9090<\/code>. For 389ds we have to do some homework first and&#8230;<\/p>\n<h2>2. Create an instance<\/h2>\n<p>A 389ds instance can be created through <code>dscreate<\/code>. There&#8217;s an interactive mode that goes through all available options one by one<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# dscreate interactive\r\nInstall Directory Server (interactive mode)\r\n===========================================\r\nEnter system's hostname &#x5B;fedora]: \r\nEnter the instance name &#x5B;fedora]: \r\nEnter port number &#x5B;389]: \r\n...\r\n<\/pre>\n<p>but the most convenient way is probably to create an instance from what&#8217;s called an <em>inf answer file<\/em>. Here&#8217;s an example that will serve as the basis for any further configuration:<\/p>\n<pre class=\"brush: plain; highlight: [2,7,14]; title: instance.inf; notranslate\" title=\"instance.inf\">\r\n&#x5B;general]\r\nfull_machine_name = ldap.example.com\r\nstart = True\r\n\r\n&#x5B;slapd]\r\ninstance_name = localhost\r\nroot_password = mysecret\r\nport = 389\r\nsecure_port = 636\r\nself_sign_cert = False\r\n\r\n&#x5B;backend-userroot]\r\nsample_entries = yes\r\nsuffix = dc=example,dc=com\r\n<\/pre>\n<p>To see all available options including a short description one can run <code>dscreate create-template<\/code> which generates an example <em>inf answer file<\/em>.<br \/>\nYou should <strong>change the highlighted lines<\/strong> to set a more secure password and alter the domain. This will also install some sample data and start the instance right after it&#8217;s created:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# dscreate from-file instance.inf \r\nStarting installation...\r\nCompleted installation for localhost\r\n<\/pre>\n<p>During the installation a systemd unit file called <code>dirsrv@INSTANCE_NAME.service<\/code> is created and enabled so the instance is automatically started on boot.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# systemctl status dirsrv@localhost.service \r\n\u25cf dirsrv@localhost.service - 389 Directory Server localhost.\r\n     Loaded: loaded (\/usr\/lib\/systemd\/system\/dirsrv@.service; enabled; vendor preset: disabled)\r\n    Drop-In: \/usr\/lib\/systemd\/system\/dirsrv@.service.d\r\n             \u2514\u2500custom.conf\r\n     Active: active (running) since Mon 2021-05-10 06:01:17 CEST; 13min ago\r\n    Process: 4817 ExecStartPre=\/usr\/libexec\/dirsrv\/ds_systemd_ask_password_acl \/etc\/dirsrv\/slapd-localhost\/dse.ldif (code=exited, status=0\/SUCCESS)\r\n   Main PID: 4822 (ns-slapd)\r\n     Status: &quot;slapd started: Ready to process requests&quot;\r\n      Tasks: 27 (limit: 2343)\r\n     Memory: 12.1M\r\n        CPU: 2.662s\r\n     CGroup: \/system.slice\/system-dirsrv.slice\/dirsrv@localhost.service\r\n             \u2514\u25004822 \/usr\/sbin\/ns-slapd -D \/etc\/dirsrv\/slapd-localhost -i \/run\/dirsrv\/slapd-localhost.pid\r\n<\/pre>\n<p>That&#8217;s it. You now have a running LDAP server. The <a href=\"https:\/\/possiblelossofprecision.net\/?p=2534\">next part<\/a> is going to cover some (essential) plugins.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Lightweight Directory Access Protocol or LDAP for short has been around for quite a while. While more modern technologies like OpenID, OAuth or SAML are often used for authentication and authorisation purposes when it comes to applications, APIs etc. on the internet these days, LDAP is still widely used for various use cases. For same-sign on purposes it is&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=2519\">Read more &raquo;<\/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":[84,13,7,83],"class_list":["post-2519","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-389ds","tag-centos","tag-fedora","tag-ldap"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/2519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2519"}],"version-history":[{"count":17,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/2519\/revisions"}],"predecessor-version":[{"id":2625,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/2519\/revisions\/2625"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}