Set up your LDAP server on Ubuntu 10.04
So lately I've been covering some pretty sweet LDAP tools. You've seen "Manage your LDAP data with phpLDAPAdmin", "Access and manage your LDAP data with Luma", and "Set up an LDAP server on Fedora". Although the last entry showed you how to get a server up and running with the 389 Directory Server GUI, none of these articles have touched on the tried and true text-based installation and setup of the slapd LDAP server. And that is exactly what we are going to do here.
But here's the thing - the slapd server can be a real pain to set up. It didn't used to be. The old fashion way was to install slapd and then edit the /etc/ldap/slapd.conf file to suite your needs. Thing is, the slapd.conf configuration file has beenÂ deprecated and now, trying to figure out how to configure slapd is like finding the proverbial needle in the proverbial haystack. Fortunately, in my desperate scouring to work out an easy method of doing this, I have found some tools to make the job easier. And that's what this article is all about, getting slapd up and running on a Ubuntu machine so you too can have LDAP running.
Of course there is a bit of installation to take care of before you do anything. But the installation isn't challenging and there isn't too much to install. Here are the steps you need to follow:
- Open up a terminal window.
- Issue the command
sudo apt-get install slapd ldap-utils php5-ldap.
- Type your sudo password and hit Enter.
- Accept any dependencies necessary.
And that's it. You are now ready for the configuration of slapd. But what to do? This article isn't about a fancy GUI tool. Instead I have found a script floating around the web (who's author I can not name because I have seen this script on a number of sites) which actually makes this process amazingly easy. I have posted the script here on pastebin for you to either download or copy and paste.
No matter if you download or copy and paste the script, name it something like ldap_script.sh and save it in your home directory. Once you have it saved give it executable permissions with the command:
chmod u+x ldap_script
Now the script is almost ready. You do have to make a few simple changes. Near the top of the script you will see:
Obviously you need to change each pleaseeditme entry to suit your needs. For my LDAP server that section lookes like:
You will also notice, near the end of the script, it adds a user. The section #Adding user can be edited to suit your needs, or it can be left alone so that at least one correct user is added at first.
When you have the script ready, it's time to execute. Issue the command sudo ./ldap_script and watch the magic fly by. When all is said and done you should then be able to check out your LDAP server with one of the means mentioned in previous articles, or you can issue the command:
ldapsearch -x -h localhost -b "dc=EXAMPLE,dc=COM" "(objectClass=*)"
Where EXAMPLE and COM match your dc entires.
You should now have your LDAP server up and running. You can start adding entries and managing it with whatever tool (or command line) you want. NOTE: We'll take a look at the management of LDAP via the command line in later articles. Enjoy your LDAP server!Advertisement