Install and Configure OpenLdap



Install and Configure OpenLdap



1. Install Berkley DB [BerkeleyDB.5.3]

                a.  Download Berkley DB
                b.  Unzip the file. : tar -xzf db-5.3.21.tar.gz
                c.  Change to the build_unix which is in extracted directory.
               
                   Run the following commands.
               
                                [root@host3 ~]#  ../dist/configure
                                [root@host3 ~]#  make

                   To build
                                [root@host3 ~]#  make install

2. Run the following.

                [root@host3 ~]# LD_LIBRARY_PATH="/usr/lib:/usr/local/lib:/usr/local/BerkeleyDB.5.3/lib:/usr/local/ssl/lib" LDFLAGS="-L/usr/local/lib -L/usr/local/BerkeleyDB.5.3/lib -L/usr/local/ssl/lib" CPPFLAGS="-I/usr/local/include -I/usr/local/BerkeleyDB.5.3/include -I/usr/local/ssl/include" ../dist/configure --enable-bdb --enable-crypt --with-tls

3. Set the env variables.

[root@host3 ~]#  PATH="$PATH:/usr/local/BerkeleyDB.5.3/lib/"
[root@host3 ~]# echo $PATH
[root@host3 ~]# CPPFLAGS="-I/usr/local/BerkeleyDB.5.3/include/"
[root@host3 ~]# export CPPFLAGS
[root@host3 ~]# LDFLAGS="-L/usr/local/lib -L/usr/local/BerkeleyDB.5.3/lib/ -R/usr/local/BerkeleyDB.5.3/lib/"
[root@host3 ~]# export LDFLAGS
[root@host3 ~]# LD_LIBRARY_PATH="/usr/local/BerkeleyDB.5.3/lib/"
[root@host3 ~]# export LD_LIBRARY_PATH
[root@host3 ~]#CFLAGS="-I/usr/local/BerkeleyDB.5.3/include/ -I/usr/local/include -I/usr/include"
[root@host3 ~]# export CFLAGS
[root@host3 ~]# LIBS="-ldb -lgcc_s"
[root@host3 ~]# export LIBS

            Test: Give echo $LIBS from the shell where you are going run the configure command for   openLdap.

4. Download OpenLdap.

a. Download and unzip the OpenLdap file. eg: tar -xzf openldap-2.4.33
b. Run the commands
                [root@host3 ~]#  ./configure
                [root@host3 ~]# make depend
                [root@host3 ~]# make
                [root@host3 ~]#  make test
                [root@host3 ~]# make install

5. Configre LDAP.

                Add the entries in the file > /usr/local/etc/openldap/ldap.conf
                HOST     host3.matrix.com
                BASE      dc=host3,dc=matrix,dc=com

                Modify the entries in the file > /usr/local/etc/openldap/sldap.conf
                suffix                     "dc=host3,dc=matrix,dc=com"
                rootdn                  "uid=root,dc=host3,dc=matrix,dc=com"

6. Create LDIF file <user.ldif> under root home directory.

                Add below entries to the ldif file.
                dn: dc=host3,dc=matrix,dc=com
                objectclass: dcobject
                objectclass: organization
                o: matrix
                dc:host3

7. Start ldap > /usr/local/libexec/slapd

8. Run the following command.

                [root@host3 ~]# /usr/local/bin/ldapadd -x -D 'uid=root,dc=host3,dc=matrix,dc=com' -W -f /root/user.ldif

9. Check if ldap is running fine.

                netstat -anp | grep 389


Troubleshoot:

      1. If you are getting error :  ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)

                   Check if ldap is running fine.
                   Check /etc/hosts file
                   Check /etc/sysconfig/network file

      2. If you are getting error : openldap configure: error: BDB/HDB: BerkeleyDB not available

                    Set the env variables properly as mentioned above (Step 3) before running ./configure


______________________________________________________



5 comments:

  1. This is great post to install/configure openldap on linux environment. It really worked for me . It also has trouble shooting steps to understand common mistake.

    ReplyDelete
  2. Thanks for this amazing clear instruction. One additional comment to step 7. It only works for me by running the daemon as follows:
    /usr/local/libexec/slapd -f //slapd.conf -d -1, whereby "-d -1" is debug all.
    BR, Vinh Ly

    ReplyDelete
  3. Thanks Vinh.. This will help to others...

    ReplyDelete