{"id":74,"date":"2011-03-30T21:16:14","date_gmt":"2011-03-30T21:16:14","guid":{"rendered":"http:\/\/www.salsaunited.net\/blog\/?p=74"},"modified":"2013-06-01T07:31:45","modified_gmt":"2013-06-01T11:31:45","slug":"rhel6-openldap-server","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=74","title":{"rendered":"RHEL6 openldap server"},"content":{"rendered":"<p>Please note that all\u00a0 double quote characters in this example are plain ASCII &#8221; characters not\u00a0 typographical ones!<\/p>\n<p>Step 1: first we need to install the required packages:<\/p>\n<p>#yum install openldap-servers migrationtools<\/p>\n<p>Step2: As the configuration for LDAP is stored inside the LDAP server itself the configuration has to be done by editing LDIF files under the <em>\/etc\/<\/em>openldap<em>\/slapd.d\/<\/em> directory.<\/p>\n<p>Now create the ldap password:<\/p>\n<p>#slappasswd<\/p>\n<p>you&#8217;ll get something like this &#8221;{SSHA}r2or9f2vYlvieCu0LP6wTnSdYfrddsuV&#8221; as a result. This is the string  we will have to add to the bdb.ldif config file.<\/p>\n<p># vim <strong>\/<\/strong>etc<strong>\/<\/strong>openldap<strong>\/<\/strong>slapd.d<strong>\/<\/strong>cn=config<strong>\/<\/strong>olcDatabase={1}bdb.ldif<\/p>\n<p>substitute my-domain.com with yourdomain.com<\/p>\n<p>:%s<strong>\/<\/strong>dc=my-domain,dc=com<strong>\/<\/strong>dc=<strong>yourdmain<\/strong>,dc=<strong>com\/<\/strong>g<\/p>\n<p>Step 3: We now\u00a0 set the admin password and specify the location of our encryption certificate and key.<\/p>\n<p>add these 3 lines at the end of the file bdb.ldif file:<\/p>\n<p>olcRootPW: {SSHA}r2or9f2vYlvieCu0LP6wTnSdYfrddsuV<br \/>\nolcTLSCertificateFile: \/etc\/pki\/tls\/certs\/slapdcert.pem<br \/>\nolcTLSCertificateKeyFile: \/etc\/pki\/tls\/certs\/slapdkey.pem<\/p>\n<p>Step 4: Now we have to specify the monitoring privileges<\/p>\n<p>#vim <strong>\/<\/strong>etc<strong>\/<\/strong>openldap<strong>\/<\/strong>slapd.d<strong>\/<\/strong>cn=config<strong>\/<\/strong>olcDatabase={2}monitor.ldif<\/p>\n<p>again, we have to replace the default domain name with our domain name<\/p>\n<p>:%s<strong>\/<\/strong>cn=manager,dc=my-domain,dc=com<strong>\/<\/strong>cn=Manager,dc=yourdomain,dc=com<strong>\/<\/strong>g<\/p>\n<p>Step 5: Now its time for the Database Cache<\/p>\n<p>#updatedb<\/p>\n<p><strong>#<\/strong>cp <strong>\/<\/strong>usr<strong>\/<\/strong>share<strong>\/<\/strong>doc<strong>\/<\/strong>openldap-servers-2.4.19\/<strong> <\/strong>DB_CONFIG.example <strong>\/<\/strong>var<strong>\/<\/strong>lib<strong>\/<\/strong>ldap<strong>\/<\/strong>DB_CONFIG<\/p>\n<p><strong>#<\/strong>chown -Rf ldap:ldap <strong>\/<\/strong>var<strong>\/<\/strong>lib<strong>\/<\/strong>ldap<strong>\/<\/strong><\/p>\n<p>Step 6: Now we will need to set up a certificate for TLS. First we need to edit \/etc\/sysconfig\/ldap and change SLAPD_LDAPS from no to yes<strong>.<\/strong><\/p>\n<p>#vi \/etc\/sysconfig\/ldap<br \/>\nSLAPD_LDAPS=yes<\/p>\n<p>Now we can create the certificate<\/p>\n<p>#openssl req -new -x509 -nodes -out \/etc\/pki\/tls\/certs\/slapdcert.pem -keyout \/etc\/pki\/tls\/certs\/slapdkey.pem -days 365<\/p>\n<p>This will create the two required keys in the \/etc\/pki\/tls\/certs\/ directory. We need to make them readable for the ldap user.<\/p>\n<p># chown -Rf root:ldap \/etc\/pki\/tls\/certs\/$cert.pem<br \/>\n# chmod -Rf 750 \/etc\/pki\/tls\/certs\/$key.pem<\/p>\n<p>Step 7<strong>:<\/strong> Time to test our configuration<\/p>\n<p># slaptest -u<br \/>\nconfig file testing succeeded<\/p>\n<p>Step 8:\u00a0 Start the ldap server<\/p>\n<p>#service sladp start<\/p>\n<p>lets check if our ldap server really works:<\/p>\n<p>#ldapsearch -x\u00a0 -b &#8221;dc=yourdomain,dc=com&#8221;<\/p>\n<p>if you get a search: 2 then your on track!<\/p>\n<p>Step 9: Configure the base domain<\/p>\n<p>#vi base.ldif<\/p>\n<p>dn: dc=yourdomain,dc=net<br \/>\ndc: yourdomain<br \/>\nobjectClass: top<br \/>\nobjectClass: domain<\/p>\n<p>dn: ou=People,dc=yourdomain,dc=net<br \/>\nou: People<br \/>\nobjectClass: top<br \/>\nobjectClass: organizationalUnit<\/p>\n<p>dn: ou=Group,dc=yourdomain,dc=net<br \/>\nou: Group<br \/>\nobjectClass: top<br \/>\nobjectClass: organizationalUnit<\/p>\n<p>now we import our base information to the ldap directory:<\/p>\n<p>#ldapadd -x -W -D &#8221;cn=Manager,dc=yourdomain,dc=com&#8221; -f base.ldif<\/p>\n<p>Step 10: lets migrate the users<\/p>\n<p>Go to the directory \/usr\/share\/migrationtools. Edit the file<\/p>\n<p># vim \/usr\/share\/migrationtools\/migrate_common.ph<\/p>\n<p>Set:<br \/>\n# Default DNS domain<br \/>\n$DEFAULT_MAIL_DOMAIN = &#8221;yourdomain.com&#8221;;<br \/>\n# Default base<br \/>\n$DEFAULT_BASE = &#8221;dc=yourdomain,dc=com&#8221;;<\/p>\n<p>#grep &#8221;:5[0-9][0-9]&#8221; \/etc\/passwd &gt; passwd<br \/>\n#grep &#8221;:5[0-9][0-9]&#8221; \/etc\/group &gt; group<br \/>\n#.\/migrate_passwd.pl passwd &gt; users.ldif<br \/>\n#.\/migrate_group.pl group &gt; group.ldif<br \/>\n#sed -e &#8221;s\/ou=Group\/ou=Groups\/g&#8221; group.ldif &gt; groups.ldif<br \/>\nldapadd -x -W -D &#8221;cn=Manager,dc=yourdomain,dc=com&#8221; -f users.ldif<br \/>\nldapadd -x -W -D &#8221;cn=Manager,dc=yourdomain,dc=com&#8221; -f groups.ldif<\/p>\n<p>Step 11: Testing the ldap server. We check if user mani exists<\/p>\n<p>#ldapsearch -x &#8221;cn=mani&#8221;\u00a0 -b &#8221;dc=mycompany,dc=com&#8221;<\/p>\n<p>If the test is successful your done \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Please note that all\u00a0 double quote characters in this example are plain ASCII &#8221; characters not\u00a0 typographical ones! Step 1: first we need to install the required packages: #yum install openldap-servers migrationtools Step2: As the configuration for LDAP is stored inside the LDAP server itself the configuration has to be done by editing LDIF files&#8230;<\/p>\n","protected":false},"author":2,"featured_media":162,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-74","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=74"}],"version-history":[{"count":2,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":504,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions\/504"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/media\/162"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}