How to Install OpenLDAP server

In this blog post, I would like to share how OpenLDAP can be installed.

Step 1. Download latest openldap version from here

You can use wget.


Step 2. Extract and Run configure

>tar -zxvf db-4.8.30.NC.tar.gz
> ./configure --enable-ppolicy –with-tls=openssl

You can also just run the ./configure command. But in above, It is asked to enable password policy overlay and install with TLS. Therefore other options are available and you can see them by ./configure -help.
Step 3. (Optional). If you see following error when running the configuration. It means that you have not install the Berkeley DB.

configure: error: BDB/HDB: BerkeleyDB not available

Therefore you need to install it first. In the installation doc of openldap and README file, It is said that Berkeley DB is required for slapd.

In ubunutu, you can install using following command

>sudo apt-get install libdb4.8-dev

Step 4. After you run the configuration, you need to build using following command

>make depend
>make test
>make install

“make test” is optional but it is better to run it.

Step 5. Configure slapd.conf   (In ubuntu file can be found in  /usr/local/etc/openldap/slapd.conf)

I just change the root DN in the slapd.conf as i wanted.

suffix "dc=soasecurity,dc=org"
rootdn "cn=asela,dc=soasecurity,dc=org"

Default password of the rootdn is set to “secret“, you can change it as well.

Step 6. Start and Stop Server.
Start using following command


To stop, you can find the pid and kill it.

>cat /usr/local/var/run/
>sudo kill -9 {pid}

Step 7. Create root DN entry and some entries.

Create my initial LDIF file as following which is soasecurity.ldif

dn: dc=soasecurity,dc=org
objectclass: dcObject
objectclass: organization
dc: soasecurity

dn: ou=Users,dc=soasecurity,dc=org
objectClass: organizationalUnit
ou: Users

dn: ou=Groups,dc=soasecurity,dc=org
objectClass: organizationalUnit
ou: Groups

Then it is added in to the openldap using  ldapadd command.

>ldapadd -x -D "cn=asela,dc=soasecurity,dc=org" -W -f soasecurity.ldif

Also, you can create some user and add it.  LDIF file is following.

dn: cn=john,ou=Users,dc=soasecurity,dc=org
objectClass: person
sn: doe
cn: john
userPassword: johnldap


Step 8. Query and Search

>ldapsearch -H ldap://localhost:389 -x -D "cn=asela,dc=soasecurity,dc=org" -W -b "dc=soasecurity,dc=org"

Thanks for reading..

Discuss this article on Stack Overflow


  1. If you need to add additional schema in to OpenLDAP server. You need to define those schema in /usr/local/etc/openldap/slapd.conf file. As an example, if you need add the inetorgperson schema. Following two schema must be defined in order in the slapd.conf file.

    include /usr/local/etc/openldap/schema/cosine.schema
    include /usr/local/etc/openldap/schema/inetorgperson.schema


Leave a Reply

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