Linux About Puppet Virtualization: /slapd.d/ Directory
Linux About Puppet Virtualization: /slapd.d/ Directory
About
Puppet
Virtualization
75 Comments
Mar - 30 - 2011
laurent
Please note that all double quote characters in this example are plain ASCII characters not 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 under the /etc/openldap
/slapd.d/ directory.
Now create the ldap password:
#slappasswd
youll get something like this {SSHA}r2or9f2vYlvieCu0LP6wTnSdYfrddsuV as a result. This is the string we will have to add to the bdb.ldif config file.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
1 of 39 8/26/2013 10:17 AM
#vim /etc/openldap/slapd.d/cn=config/olcDatabase={1}bdb.ldif
substitute my-domain.com with yourdomain.com
:%s/dc=my-domain,dc=com/dc=yourdmain,dc=com/g
Step 3: We now set the admin password and specify the location of our encryption certificate and key.
add these 3 lines at the end of the file bdb.ldif file:
olcRootPW: {SSHA}r2or9f2vYlvieCu0LP6wTnSdYfrddsuV
olcTLSCertificateFile: /etc/pki/tls/certs/slapdcert.pem
olcTLSCertificateKeyFile: /etc/pki/tls/certs/slapdkey.pem
Step 4: Now we have to specify the monitoring privileges
#vim /etc/openldap/slapd.d/cn=config/olcDatabase={2}monitor.ldif
again, we have to replace the default domain name with our domain name
:%s/cn=manager,dc=my-domain,dc=com/cn=Manager,dc=yourdomain,dc=com/g
Step 5: Now its time for the Database Cache
#updatedb
#cp /usr/share/doc/openldap-servers-2.4.19/ DB_CONFIG.example /var/lib/ldap/DB_CONFIG
#chown -Rf ldap:ldap /var/lib/ldap/
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 fromno to yes.
#vi /etc/sysconfig/ldap
SLAPD_LDAPS=yes
Now we can create the certificate
#openssl req -new -x509 -nodes -out /etc/pki/tls/certs/slapdcert.pem -keyout /etc/pki/tls/certs/slapdkey.pem -days 365
This will create the two required keys in the /etc/pki/tls/certs/ directory. We need to make them readable for the ldap user.
#chown -Rf root:ldap /etc/pki/tls/certs/$cert.pem
#chmod -Rf 750 /etc/pki/tls/certs/$key.pem
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
2 of 39 8/26/2013 10:17 AM
Step 7: Time to test our configuration
#slaptest -u
config file testing succeeded
Step 8: Start the ldap server
#service sladp start
lets check if our ldap server really works:
#ldapsearch -x -b dc=yourdomain,dc=com
if you get a search: 2 then your on track!
Step 9: Configure the base domain
#vi base.ldif
dn: dc=yourdomain,dc=net
dc: yourdomain
objectClass: top
objectClass: domain
dn: ou=People,dc=yourdomain,dc=net
ou: People
objectClass: top
objectClass: organizationalUnit
dn: ou=Group,dc=yourdomain,dc=net
ou: Group
objectClass: top
objectClass: organizationalUnit
now we import our base information to the ldap directory:
#ldapadd -x -W -D cn=Manager,dc=yourdomain,dc=com -f base.ldif
Step 10: lets migrate the users
Go to the directory /usr/share/migrationtools. Edit the file
#vim /usr/share/migrationtools/migrate_common.ph
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
3 of 39 8/26/2013 10:17 AM
Set:
#Default DNS domain
$DEFAULT_MAIL_DOMAIN =yourdomain.com;
#Default base
$DEFAULT_BASE =dc=yourdomain,dc=com;
#grep :5[0-9][0-9] /etc/passwd >passwd
#grep :5[0-9][0-9] /etc/group >group
#./migrate_passwd.pl passwd >users.ldif
#./migrate_group.pl group >group.ldif
#sed -e s/ou=Group/ou=Groups/g group.ldif >groups.ldif
ldapadd -x -W -D cn=Manager,dc=yourdomain,dc=com -f users.ldif
ldapadd -x -W -D cn=Manager,dc=yourdomain,dc=com -f groups.ldif
Step 11: Testing the ldap server. We check if user mani exists
#ldapsearch -x cn=mani -b dc=mycompany,dc=com
If the test is successful your done
Categories: Linux
75 Responses so far.
Travis says:
April 6, 2011 at 5:37 pm
Hey, this is a great posting. Thanks so much for taking the time to do this.
I do have one question though..
When I add: olcRootPW: {SSHA}. as part of your instructions
1.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
4 of 39 8/26/2013 10:17 AM
I get the following message when I run the slaptest -u
olcRootPW: value #0: can only be set when rootdn is under suffix
I cant see what Ive missed. If I comment that line out of the olcDatabase={2}monitor.ldif the error goes away, but I of course cant authenticate either.
Any ideas?
Reply
laurent says:
April 6, 2011 at 10:24 pm
Yes the 3 lines
olcRootPW: {SSHA}r2or9f2vYlvieCu0LP6wTnSdYfrddsuV
olcTLSCertificateFile: /etc/pki/tls/certs/slapdcert.pem
olcTLSCertificateKeyFile: /etc/pki/tls/certs/slapdkey.pem
have to be added to the /etc/openldap/slapd.d/cn=config/olcDatabase={1}bdb.ldif file not the olcDatabase={2}monitor.ldif.
Reply
Robert says:
April 9, 2011 at 4:42 pm
Hi, thanks for the help. Ive been looking for some help for a while. I stuck on a certain point. Where you import base information:
ldapadd -x -W -D cn=Manager,dc=yourdomain,dc=com -f base.ldif
I get an error:
Enter LDAP Password:
ldap_bind: Invalid DN syntax (34)
additional info: invalid DN
I dont know why Im getting this error. I changed yourdomain to example which is my domain.
Any help would be appreciated, thanks,
Rob
Reply
laurent says:
April 11, 2011 at 6:35 pm
2.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
5 of 39 8/26/2013 10:17 AM
Hi Robert,
You have to pay attention the syntax in the ldif file:
Here an example:
dn: dc=domb,dc=net // (dn:[whitespace] dc=domb,dc=net [ENTER])
dc: domb
objectClass: top
objectClass: domain [ENTER]
[ENTER]
dn: ou=People,dc=domb,dc=net
ou: People
objectClass: top
objectClass: organizationalUnit[ENTER]
[ENTER]
dn: ou=Group,dc=domb,dc=net
ou: Group
objectClass: top
objectClass: organizationalUnit
Hope this helps to solve your problem. If not post me your base.ldif
Reply
dave says:
April 15, 2011 at 8:49 pm
hello i finally found someone doing it on rhel6 thanks, but when i run the
slaptest -u
i get
<=str2entry: str2ad({SSHA}bfHIutM8Pjx+379BVH0gvdhUdRNwq5cK): empty AttributeDescription
slaptest: bad configuration file!
the {SSHA..} string is what i added to my file /etc/openldap/slapd.d/cn=config/olcDatabase={1}bdb.ldif . these are the lines that i added to that file
(how it looks)
{SSHA}bfHIutM8Pjx+379BVH0gvdhUdRNwq5cK
olcRootPW: {SSHA}bfHIutM8Pjx+379BVH0gvdhUdRNwq5cK
olcTLSCertificateFile: /etc/pki/tls/certs/slapdcert.pem
olcTLSCertificateKeyFile: /etc/pki/tls/certs/slapdkey.pem
what am i doing wrong?
3.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
6 of 39 8/26/2013 10:17 AM
thank you
dave
Reply
laurent says:
April 18, 2011 at 3:50 am
create the ssl cert and run the test again. When you run the slaptest -u before creating the certificate youll get that error.
Reply
James says:
April 20, 2011 at 8:36 pm
Where can I find the official RHEL-6 document of the configuration of both LDAP server and client?
Thanks,
James
Reply
laurent says:
April 21, 2011 at 2:44 am
You can find it at http://docs.redhat.com/docs/en-US/index.html
Reply
4.
Eris says:
April 25, 2011 at 5:17 am
Thank you very much for the post, and all of the others here too! Im studying for the RHCE and although I have a good background with a lot of the
material from working in webhosting for many years, LDAP is brand new to me and this was the simplest and most lucid tutorial Ive yet found.
I do have one suggestion, and it may help others too. Please change the double quote characters in your example to use the plain ASCII character
instead of the typographical open and close quote characters. Like Robert above, the ldapadd command initially gave me this error
ldap_bind: Invalid DN syntax (34)
additional info: invalid DN
It turned out to be the result of the UTF-8 open and clsoe quote chars. I had to change the command from this
5.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
7 of 39 8/26/2013 10:17 AM
ldapadd -x -W -D cn=Manager,dc=yourdomain,dc=com -f base.ldif
to this
ldapadd -x -W -D cn=Manager,dc=yourdomain,dc=com -f base.ldif
(And I hope WordPress doesnt auto change those quotes on me! The second line should have the non-curved typewriter double quote symbol from the
ASCII set.)
Reply
Eris says:
April 25, 2011 at 5:18 am
Hmpf. WordPress changed the quotes on me automatically.
Reply
6.
Lyndon says:
May 1, 2011 at 9:01 am
Thank you very much for detailed instruction! When I restarted slapd, I met the following issue:
Checking configuration files for slapd: [FAILED]
PROXIED attributeDescription DC inserted.
<=str2entry: str2ad(dc): attribute type undefined
slaptest: bad configuration file!
If I did not do a slapd restart, the ldap server seemed working fine. Do you know why it happened?
Thanks.
Reply
Andries says:
July 10, 2012 at 9:01 am
Did you manage to solve this issue i am having the same problem
Reply
Mohamed says:
March 5, 2013 at 6:15 am
Did encounter this error, but resolved after removing my base.ldif and user.ldif files from the /etc/openldap/slapd.d/cn=config/ dir. Think that
7.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
8 of 39 8/26/2013 10:17 AM
no other files should be kept within this cn=config besides the slapd generated ldifs.
Reply
ramakrishna says:
May 31, 2011 at 6:02 am
hi
Thank you so much.
I been trying so long time with like old ldap configuration.
Finally I got though you. Thanking you lot
Thanks
Ramakrishna
Reply
8.
JD says:
June 29, 2011 at 12:28 am
#extended LDIF
#
#LDAPv3
#base with scope subtree
#filter: (objectclass=*)
#requesting: ALL
#
#search result
search: 2
result: 32 No such object
#numResponses: 1
After step #ldapsearch -x -b dc=yourdomain,dc=com
Also, I am not finding the following file to configure:
Step 9: Configure the base domain
#vi base.ldif
Where is this config file located at?
Any help would be great.
9.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
9 of 39 8/26/2013 10:17 AM
Reply
sridhar says:
June 30, 2011 at 10:38 am
plz tell me where is the error
dn: dc=sridhar,dc=net
dc: sridhar
objectClass: top
objectClass: domain
dn: ou=People,dc=sridhar,dc=net
ou: People
objectClass: top
objectClass: organizationalUnit
dn: ou=Group,dc=sridhar,dc=net
ou: Group
objectClass: top
objectClass: organizationalUnit
Reply
10.
sridhar says:
June 30, 2011 at 10:53 am
type ls from where you first typed vi base.ldif
JD
Reply
11.
venku says:
July 6, 2011 at 12:37 pm
Plz tell me how I can add a new custom attribute which is not included presently to this OpenLDAP server of RHEL 6. I would like to extend the schema
of the same.
Reply
12.
Nolan says:
July 18, 2011 at 3:55 pm
13.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
10 of 39 8/26/2013 10:17 AM
Hello, First of all thank you for the tutorial.
Running into a similar issue as the first comment. I have only add the 3 lines:
olcRootPW: {SSHA}my-hash
olcTLSCertificateFile: /etc/pki/tls/certs/slapdcert.pem
olcTLSCertificateKeyFile: /etc/pki/tls/certs/slapdkey.pem
To the end of:
/etc/openldap/slapd.d/cn=config/olcDatabase={1}bdb.ldif
And I get the error:
[root@directory ~]#slaptest -u
olcRootPW: value #0: can only be set when rootdn is under suffix
config error processing olcDatabase={1}bdb,cn=config: can only be set when rootdn is under suffix
slaptest: bad configuration file!
Not sure whats up and dont know what else to change. Thanks !
Reply
Nolan says:
July 18, 2011 at 4:45 pm
Solved it, quotes around hash helped.
Reply
14.
Jorell says:
July 22, 2011 at 11:33 am
I just have to say thank you for this how-to
I only had to do one thing differently:
1chown -f root:ldap /etc/pki/tls/certs/slapdcert.pem /etc/pki/tls/certs
Reply
15.
sangita says:
July 25, 2011 at 1:15 pm
I am tring on my localhost with dc=test,dc=com
however LDAPSEARCH gave the following output :
16.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
11 of 39 8/26/2013 10:17 AM
ldapsearch -x -b dc=test,dc=com
which gave me error as below:
ldap_sasl_bind(SIMPLE): Cant contact LDAP server (-1)
here I have added localhost and given me following output:
ldapsearch -x -h localhost -b dc=test,dc=com
#extended LDIF
#
#LDAPv3
#base with scope subtree
#filter: (objectclass=*)
#requesting: ALL
#
#search result
search: 2
result: 32 No such object
#numResponses: 1
-
Am I correct here?
I have created the base.ldif and tried ldapadd command as:
ldapadd -x -h 127.0.0.1 -D cn=Manager,dc=test,dc=com -W -f base.ldif
ldapadd -x -h locahost -D cn=Manager,dc=test,dc=com -W -f base.ldif
ldapadd -x -h -D cn=Manager,dc=test,dc=com -W -f base.ldif
with the password which was generated with cammand
#slappasswd
This gaves error as:
ldap_bind: Invalid credentials (49)
What is wrong ? Please help!!!!
Reply
Stas says: 17.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
12 of 39 8/26/2013 10:17 AM
July 28, 2011 at 7:03 am
Thank you for this how-to. Everything works.
NOTE: Do not directly copy text of this how-to, better you enter the text on a new
Reply
Abhinav says:
August 3, 2011 at 8:54 am
Iam not able to find the the DB_CONFIG File in openldap-servers path
#cp /usr/share/doc/openldap-servers-2.4.19/ DB_CONFIG.example /var/lib/ldap/DB_CONFIG
AND
Please tell me the location of base.ldif file
Reply
18.
mohit says:
August 8, 2011 at 1:55 pm
Please tell me the location of base.ldif file
Reply
19.
shashank agarwal says:
August 9, 2011 at 11:58 am
i have done all steps upto 7 steps and all are working fine but when i start the slapd service ,it failed,when i start the slapd service 1st time it show me the
warning suffix of DB_CONFIG file has changed,performing data base recovery to apply new settings
dbb_db_open: database dc=example.com,dc=com:recpvery skipped in read only mode.run manual recovery if error persist
config file testing succeded.
starting slapd: [Failed]
and it shows service failed whenever i start the service
please help
Reply
20.
Robeto Mason says:
August 10, 2011 at 5:29 pm
Thanks for he tutorial. Im not proficient with Openldap. This is he first time Im trying to implement it at home. Im running Centos 6.0 Im stuck on step
21.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
13 of 39 8/26/2013 10:17 AM
#9. When I do the <>I get the following error
ldap_bind: Invalid credentials (49)
where do u think I may have gone wrong?
Thanks
Reply
Roberto Mason says:
August 10, 2011 at 5:32 pm
Sorry, had to repost
Thanks for he tutorial. Im not proficient with Openldap. This is he first time Im trying to implement it at home. Im running Centos 6.0 Im stuck on step
#9. When I do the
#ldapadd -x -W -D cn=Manager,dc=rmasonfamily,dc=info -f /root/base.ldif
I get the following error
ldap_bind: Invalid credentials (49)
where do u think I may have gone wrong?
Thanks
Reply
22.
sandy says:
August 10, 2011 at 6:27 pm
Hey any one can help me to build my ldapserver after slaptest -u.
i have successfully tested my slaptest -u opting but as I start my slapd deamon it get failed neither it stops nor starts. And I want to inform that my eth0 is
also creating problem I cant configure Static IP it fails after service network restart. I am using COMPAQ CQ 40 series laptop. and RHEL 6.0. Plz help
me.
Reply
23.
Anonymous says:
August 12, 2011 at 4:54 am
what is wrong with my configuration? please see message below. tnx
#ldapadd -x -W -D cn=Manager,dc=ncfs -f ncfs.ldif
24.
RHEL6 openldap server : Laurent Domb OSS Blog http://blog.domb.net/?p=74
14 of 39 8/26/2013 10:17 AM
Enter LDAP Password:
ldap_bind: Invalid DN syntax (34)
additional info: invalid DN
My ldif file:
==============
dn: dc=ncfs
dc: ncfs
objectClass: top
objectClass: domain
dn: ou=People,dc=ncfs
ou: People
objectClass: top
objectClass: organizationalUnit
dn: ou=Group,dc=ncfs
ou: Group
objectClass: top
objectClass: organizationalUnit
Reply
Aik Zu Shyong says:
August 18, 2011 at 6:29 am
For those of you with errors:
PROBLEM