Build OpenLDAP 2.3.x from sources on Ubuntu

It happened so that I needed to build a particular version of OpenLDAP on Ubuntu and use that instead of the one in Ubuntu’s repository. Here is a quick guide as to how it worked for me:

1. Get BDB 4.3 sources from Oracle’s site(link)

2. Compile BDB and install it:

tar –xvzf db-4.3.29.tar.gz
cd db-4.3.29/build_unix
./configure --prefix=/usr/local/bdb43
make 
sudo make install

3. Get OpenLDAP source(ftp link)
4. Compile and install it:

tar xzvf openldap-2.3.35.tgz
cd openldap
export CPPFLAGS="-I/usr/local/bdb43/include -D_GNU_SOURCE" 
export LDFLAGS="-L/usr/local/lib -L/usr/local/bdb43/lib -R/usr/local/bdb43lib" 
export LD_LIBRARY_PATH="/usr/local/bdb43/lib"
./configure --prefix=/usr/local/openldap

If you’re installing version 2.3.x or anything before 2.4.15 you will need to manually patch OpenLDAP otherwise you’ll get this error:
../../include/ldap_pvt_thread.h:64: error: missing binary operator before token “(“
Patch file is available in this bug report
Or already patched file for OpenLDAP version 2.3.35 you can download here

If you’re installing anything >= 2.4.15, you can skip the patch.

Once patch is applied just run:

make depend
make
make test  #this will take a while to run 
make install

Common Errors:
configure: error: Berkeley DB version mismatch
Solution: Most likely you didn’t LDFLAGS and LD_LIBRARY_PATH as noted above

getpeereid.c:52: error: storage size of ‘peercred’ isn’t known
You need to include -D_GNU_SOURCE flag, to avoid incompatibility with glibc

../../include/ldap_pvt_thread.h:64: error: missing binary operator before token “(“
Solution: Apply patch as noted above

error while loading shared libraries: libdb-4.3.so: cannot open shared object file: No such file or directory
Solution: Add libdb-4.3 to shared libs cache:

sudo echo "/usr/local/bdb43/lib" > /etc/ld.so.conf.d/slapd.conf
lddconfig -v

9 thoughts on “Build OpenLDAP 2.3.x from sources on Ubuntu

  1. Estos pasos no va a generar el archivo slapd.conf. Tendrá que utilizar un ejemplo proporcionado en el código fuente de OpenLDAP y escribir su propio.

  2. Quisiera saber como configurar en el archivo slapd.conf la parte BDB database definitions para la base de datos que se utilizo en este documento la BDB 4.3, debido a que obtengo el siguiente error al ejecutar el comando slaptest -f slapd.conf -F slapd.d:

    Unrecognized database type (bdb)
    slapd.conf: line 55: failed init (bdb)
    slaptest: bad configuration directory!

    Definición del BDB database definitions en mi archivo slapd.conf:
    database bdb

    # suffix “dc=my-domain,dc=com”

    suffix “dc=rgnoccidente,dc=com”

    # rootdn “cn=Manager,dc=my-domain,dc=com”

    rootdn “cn=admin,dc=rgnoccidente,dc=com”

    # Cleartext passwords, especially for the rootdn, should
    # be avoid. See slappasswd(8) and slapd.conf(5) for details.
    # Use of strong authentication encouraged.

    # rootpw secret

    rootpw {CRYPT}9qbsPUBF/1fWY #clave que le puse

    # lineas extraidas de guia
    access to attribute=userPassword
    by dn=”cn=admin,dc=rgnoccidente,dc=com” write
    by anonymous auth
    by self write
    by * none
    access to *
    by dn=”cn=admin,dc=rgnoccidente,dc=com” write
    by * read
    # final de lineas

    # The database directory MUST exist prior to running slapd AND
    # should only be accessible by the slapd and slap tools.
    # Mode 700 recommended.
    directory /usr/local/openldap/var/openldap-data
    # Indices to maintain
    index objectClass eq

    • database bdb # esta es la linea 55

      # suffix “dc=my-domain,dc=com”

      suffix “dc=rgnoccidente,dc=com”

      # rootdn “cn=Manager,dc=my-domain,dc=com”

      rootdn “cn=admin,dc=rgnoccidente,dc=com”

      # Cleartext passwords, especially for the rootdn, should
      # be avoid. See slappasswd(8) and slapd.conf(5) for details.
      # Use of strong authentication encouraged.

      # rootpw secret

      rootpw {CRYPT}9qbsPUBF/1fWY #clave que le puse

      # lineas extraidas de guia
      access to attribute=userPassword
      by dn=”cn=admin,dc=rgnoccidente,dc=com” write
      by anonymous auth
      by self write
      by * none
      access to *
      by dn=”cn=admin,dc=rgnoccidente,dc=com” write
      by * read
      # final de lineas

      # The database directory MUST exist prior to running slapd AND
      # should only be accessible by the slapd and slap tools.
      # Mode 700 recommended.
      directory /usr/local/openldap/var/openldap-data
      # Indices to maintain
      index objectClass eq

  3. Parece que el módulo de BDB, o bien no está vinculada o no cargado en slapd.conf
    Puede ejecutar este comando, por favor:

    ldd / PATH / TO SLAPTEST /
    (reemplace / PATH / TO / SLAPTEST con la ubicación de slaptest el ejecutable)

    Puede también enviar un contenido completo en su slapd.conf?

    Podría ser más fácil si usted acaba de ponerse en contacto conmigo por correo electrónico – [hidden]

  4. hello man,

    when I am in the step of make depend , it show me tons of bellow error ;
    any advise ?
    In file included from slurp.h:53,
    from admin.c:42:
    ../../include/ldap_pvt_thread.h:64:7: error: missing binary operator before token “(”
    In file included from slurp.h:53,
    from args.c:46:
    ../../include/ldap_pvt_thread.h:64:7: error: missing binary operator before token “(”
    In file included from ../slapd/slap.h:56,
    from ch_malloc.c:43:
    ../../include/ldap_pvt_thread.h:64:7: error: missing binary operator before token “(”
    In file included from slurp.h:53,
    from config.c:52:
    ../../include/ldap_pvt_thread.h:64:7: error: missing binary operator before token “(”
    In file included from slurp.h:53,
    from fm.c:44:
    ../../include/ldap_pvt_thread.h:64:7: error: missing binary operator before token “(”
    In file included from slurp.h:53,
    from globals.c:41:
    ../../include/ldap_pvt_thread.h:64:7: error: missing binary operator before token “(”
    In file included from slurp.h:53,
    from ldap_op.c:52:

  5. I met a new issue in this step “make test” , any advise ?
    >>>>> Starting test001-slapadd …
    running defines.sh
    Running slapadd to build slapd database…
    Starting slapd on TCP/IP port 9011…
    Using ldapsearch to retrieve all the entries…
    Waiting 5 seconds for slapd to start…
    ./scripts/test001-slapadd: line 43: 20037 Segmentation fault $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1
    Waiting 5 seconds for slapd to start…
    Waiting 5 seconds for slapd to start…
    Waiting 5 seconds for slapd to start…
    Waiting 5 seconds for slapd to start…
    Waiting 5 seconds for slapd to start…
    ./scripts/test001-slapadd: line 53: kill: (20037) – No such process
    ldapsearch failed (1)!
    >>>>> ./scripts/test001-slapadd failed (exit 1)
    make[2]: *** [bdb-yes] Error 1
    make[2]: Leaving directory `/home/alex/temp/openldap-2.3.37/tests’
    make[1]: *** [test] Error 2
    make[1]: Leaving directory `/home/alex/temp/openldap-2.3.37/tests’
    make: *** [test] Error 2

Leave a Reply to admin Cancel reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>