Setup LDAP on Ubuntu 10.04

I attempted to set up and LDAP server on Ubuntu, but apparently I skipped a step or missed part of the instructions because I could not get it to work. After researching many websites, I was finally able to come up with a solution that got it to work. All of the instructions are based upon the use of a Linux command prompt (or terminal)

The Steps

  • Connect to your server
  • Enter sudo apt-get purge slapd This will clear your existing slapd configuration if you have one.
  • Enter sudo apt-get install slapd ldap-utils php5-ldap This will re-install slapd with the initial configuration and install ldap-utils and php5-ldap packages if you do not already have them
  • Accept any dependencies necessary.
  • Copy the script located at to your server. When saving the file, name it and save it in a directory that you have access. ( I don't know who initially created it, so I don't know who give credit to)
  • Give the script executable permissions by running the command chmod u+x
  • Edit the file look for and edit the following lines:

In my instance, I changed the lines to

  • If you wish, you may change the lines towards the end of the script so that the first user that is added, has all the necessary fields of your choosing. I chose to not modify the fields so that at least one user is added correctly.
  • After you have finished making all of the changes, run the command sudo ./ldap_script You will see the script run and it may prompt you for your password.
  • Enter the command ldapsearch -x -h localhost -b "dc=EXAMPLE,dc=COM" "(objectClass=*)" where EXAMPLE and COM match the entries that you included in the file. You should see the results of your LDAP server.

Information Sources:

Updated: 2020-07-15 | Posted: 2012-02-09