- Log in as root user and install the following three packages:
-
openldap-servers: This package contains the main LDAP server.
-
openldap-clients: This package contains all required LDAP client utilities.
-
openldap: This packages contains the LDAP support libraries.
- To install, run the following command: yum install -y openldap openldap-clients openldap-servers.
- Edit the ldap.conf file and enter the IP address or domain name of your server.
STEP RESULT: vi /etc/openldap/ldap.conf
URI ldap://10.133.132.210
BASE dc=avaya,dc=com
- Copy the parameter file to the LDAP database directory.
ADDITIONAL INFORMATION: cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
LDAP needs the parameter file to start a new database.
- Copy the sample slapd file from /usr/share/openldap-servers to /etc/openldap.
STEP RESULT: cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
- Setup a new root password and run the password utility to run generate a secure password and copy the password as you need to enter the password in slapd.conf.
STEP RESULT: Slappasswd
New password:openldap
Re-enter new password:openldap
{SSHA}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Update the slapd.conf file to reflect your environment: database section where the domain and password are updated.
ADDITIONAL INFORMATION: vi /etc/openldap/slapd.conf
:%s/dc=my-domain/dc=avaya/g #This regex will replace all the instances of my-domain with your domain name.
#Enter the below key with password value which is generated in previous steps
rootpw {SSHA}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The password is the output of the slappasswd utility.
- Create a root.ldif file and enter the following details.
STEP RESULT: vi /root/root.ldif
#root
dn: dc=avaya,dc=com
dc: avaya
objectClass: dcObject
objectClass: organizationalUnit
ou: avaya.com
- Remove everything in slapd.d directory and tell the slapd for root.ldif file
STEP RESULT: rm -rf /etc/openldap/slapd.d/*
slapadd -n 2 -l /root/root.ldif
- Verify The Configuration files. Use slaptest command to verify the configuration file.
STEP RESULT: slaptest -u
config file testing succeededslaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
config file testing succeeded
- Set the appropriate permissions.
STEP RESULT: chown -R ldap:ldap /var/lib/ldap
chown -R ldap:ldap /etc/openldap/slapd.d
- Make sure the service is on on the runlevel 3.
STEP RESULT: chkconfig --level 235 slapd on
- To start the ldap server, enter the following command from a terminal window.
STEP RESULT: service slapd start
- Restart the service again after setting up.
STEP RESULT: rm -rf /etc/openldap/slapd.d/*
slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
chown -R ldap:ldap /etc/openldap/slapd.d
service slapd restart
- Test that you can connect to the LDAP server.
STEP RESULT: ldapsearch -h localhost -D "cn=Manager,dc=avaya,dc=com" -w <openldap_root_password> -b "dc=avaya,dc=com" -s sub "objectclass=*"
<openldap_root_password> is the Open LDAP root password which was configured in Step 5.
- Create sample LDIF file to create LDAP directory structure.
STEP RESULT: vi ldap_init.ldif
dn: dc=avaya,dc=com
dc: avaya
objectClass: dcObject
objectClass: organizationalUnit
ou: avaya.com
dn: ou=dev,dc=avaya,dc=com
objectClass: top
objectClass: OrganizationalUnit
ou: dev
dn: ou=people,ou=dev,dc=avaya,dc=com
objectClass: top
objectClass: OrganizationalUnit
ou: people
- Load initial data into the directory. You can do this using an LDIF file and then run the ldapadd command.
STEP RESULT: ldapadd -x -D "cn=Manager,dc=avaya,dc=com" -W -f ldap_init.ldif
- Test that you can connect to the LDAP server.
STEP RESULT: ldapsearch -h localhost -D "cn=Manager,dc=avaya,dc=com" -w <openldap_root_password> -b "dc=avaya,dc=com" -s sub "objectclass=*"
<openldap_root_password> is the Open LDAP root password which was configured in Step 5.
- Create an SSL certificate for LDAPs.
STEP RESULT: cd /etc/pki/tls/certs
rm slapd.pem
make slapd.pem
chmod 640 slapd.pem
chown :ldap slapd.pem
mkdir /etc/openldap/cacerts/
ln -s /etc/pki/tls/certs/slapd.pem /etc/openldap/cacerts/slapd.pem
- Start the LDAP servers.
STEP RESULT: vi /etc/sysconfig/ldap
SLAPD_LDAPS=yes
- Add or update the following lines to the global section of the /etc/openldap/slapd.conf file.
STEP RESULT: vi /etc/openldap/slapd.conf
TLSCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
TLSCertificateFile /etc/pki/tls/certs/slapd.pem
TLSCertificateKeyFile /etc/pki/tls/certs/slapd.pem
- Add the following lines to the configuration file for the LDAP server, /etc/openldap/ldap.conf.
STEP RESULT: vi /etc/openldap/ldap.conf
TLS_CACERTDIR /etc/openldap/cacerts
- Restart the service again after setting up.
STEP RESULT: rm -rf /etc/openldap/slapd.d/*
slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
chown -R ldap:ldap /etc/openldap/slapd.d
service slapd restart