Friday, September 23, 2011

Install and config OpenLDAP server on Ubuntu/Debian


  1. Open up a terminal window.
  2. Issue the command sudo apt-get install slapd ldap-utils php5-ldap.
  3. Type your sudo password and hit Enter.
  4. 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  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:
passwd=pleaseeditme
dc1=pleaseeditme
dc2=pleaseeditme
Obviously you need to change each pleaseeditme entry to suit your needs. For my LDAP server that section lookes like:
passwd=mypassword
dc1=wallen
cd2=local
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.
Final thoughts
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!

No comments:

Post a Comment