{"id":215,"date":"2011-02-17T18:23:33","date_gmt":"2011-02-17T17:23:33","guid":{"rendered":"http:\/\/locallost.net\/?p=215"},"modified":"2011-02-18T12:29:14","modified_gmt":"2011-02-18T11:29:14","slug":"openldap-2-4-x-with-cnconfig-configuration","status":"publish","type":"post","link":"https:\/\/locallost.net\/?p=215","title":{"rendered":"OpenLDAP 2.4.x with `cn=config&rsquo; configuration"},"content":{"rendered":"<p>Today I upgraded an OpenLDAP 2.3.x running on an aging custom Linux distro to a brand new Ubuntu 10.04 LTS with OpenLDAP 2.4.x.<\/p>\n<p>I was surprised by the lack of a `slapd.conf&rsquo; config file, which is replaced by a `cn=config&rsquo; subdir, with a bunch of .ldif files in it.<\/p>\n<p>You&rsquo;ll find the documentation for this new config layout there : http:\/\/www.openldap.org\/doc\/admin24\/slapdconf2.html<\/p>\n<p>This is in fact a rewrite of the usual`slapd.conf&rsquo; directives with a LDIF notation.<\/p>\n<p>So here is a quick overview to create the first database.<\/p>\n<p><!--more--><\/p>\n<p>&#8211; Load de bdb backend module:<\/p>\n<pre>\r\n# cat &lt;&lt;EOF &gt; \/etc\/ldap\/slapd.d\/cn=config\/cn=module.ldif\r\ndn: cn=module\r\nobjectClass: olcModuleList\r\ncn: module\r\nolcModulepath: \/usr\/lib\/ldap\r\nolcModuleload: back_bdb<\/pre>\n<p>&#8211; Declare and prepare your database:<\/p>\n<pre>\r\n# mkdir -p \/var\/lib\/ldap\/dc=example,dc=net\r\n# chown openldap: \/var\/lib\/ldap\/dc=example,dc=net\r\n\r\n# cat &lt;&lt;EOF &gt; \/etc\/ldap\/slapd.d\/cn=config\/olcDatabase={0}bdb.ldif\r\ndn: olcDatabase=bdb\r\nobjectClass: olcDatabaseConfig\r\nobjectClass: olcBdbConfig\r\nolcDatabase: bdb\r\nolcDbDirectory: \/var\/lib\/ldap\/dc=example,dc=net\r\nolcSuffix: dc=example,dc=net\r\nolcRootDN: cn=Manager,dc=example,dc=net\r\nolcRootPW: {SSHA}FoViJYh9j7H4vw9ELVXzhKuXEMJwXOzJ\r\nolcDbIndex: objectClass eq,pres\r\nolcDbIndex: ou,sn,cn,mail,givenName eq,pres,sub\r\nolcAccess: to dn.regex=\"^ou=([^,]*),dc=people,(.*)$\"\r\n  by dn.regex=\"uid=$1,dc=users,$2\" read\r\n  by group.expand=\"cn=$1,dc=people,$2\" read by * none\r\nolcAccess: to dn.regex=\"^uid.*,ou=([^,]*),dc=people,(.*)$\"\r\n  by dn.regex=\"uid=$1,dc=users,$2\" read\r\n  by group.expand=\"cn=$1,dc=people,$2\" read\r\n  by * none\r\nolcAccess: to attrs=userPassword\r\n  by anonymous auth\r\n  by self read\r\n  by * none\r\nolcAccess: to *\r\n  by dn=\"cn=Manager,dc=example,dc=net\" write\r\n  by anonymous read\r\n  by * read<\/pre>\n<p>&#8211; Activate the \u00ab\u00a0cosine\u00a0\u00bb, \u00ab\u00a0nis\u00a0\u00bb and \u00ab\u00a0inetorgperson\u00a0\u00bb schema:<\/p>\n<pre># ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f \/etc\/ldap\/schema\/cosine.ldif\r\n# ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f \/etc\/ldap\/schema\/nis.ldif\r\n# ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f \/etc\/ldap\/schema\/inetorgperson.ldif<\/pre>\n<p>&#8211; Check your configuration by running `slapd&rsquo; manually with debug:<\/p>\n<pre># slapd -d 3 -h 'ldap:\/\/\/ ldapi:\/\/\/' -g openldap -u openldap -F \/etc\/ldap\/slapd.d\/<\/pre>\n<p>&#8211; Dump your data on the old server with `slapcat&rsquo;:<\/p>\n<pre># slapcat -b dc=example,dc=net -l dump.ldif<\/pre>\n<p>&#8211; Load the dumped data on the new server with `slapadd&rsquo;:<\/p>\n<pre># slapadd -b dc=example,dc=net -l dump.ldif<\/pre>\n<p>&#8211; Restart LDAP on new server:<\/p>\n<pre># \/etc\/init.d\/slapd start<\/pre>\n<p>&#8211; Do a `ldapsearch&rsquo; to test that everything is present:<\/p>\n<pre># ldapsearch -H ldapi:\/\/\/ -b dc=example,dc=net -D cn=Manager,dc=example,dc=net -W -x<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today I upgraded an OpenLDAP 2.3.x running on an aging custom Linux distro to a brand new Ubuntu 10.04 LTS with OpenLDAP 2.4.x. I was surprised by the lack of a `slapd.conf&rsquo; config file, which is replaced by a `cn=config&rsquo; &hellip; <a href=\"https:\/\/locallost.net\/?p=215\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[17],"tags":[],"class_list":["post-215","post","type-post","status-publish","format-standard","hentry","category-system"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2Bei9-3t","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts\/215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=215"}],"version-history":[{"count":7,"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts\/215\/revisions"}],"predecessor-version":[{"id":224,"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts\/215\/revisions\/224"}],"wp:attachment":[{"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}