How-To OpenLDAP, Quick n’ Dirty Edition

Posted: October 20th, 2009 | Author: | Filed under: LDAP | No Comments »

Install Ubuntu Server Edition 8.10, boot it up and install OpenLDAP.

sudo apt-get install slapd ldap-utils

You can probably just accept the defaults if this is just for testing, therefore your domain will be dc=example,dc=com. In the install wizard it should ask you to setup your ldap admin user this user’s dn should be cn=admin,dc=example,dc=com

Then you’ll need to add two organizational units, one for People, one for Groups. Create the file myldap.ldif and place into it this:

dn: ou=people,dc=example,dc=com
objectClass: organizationalUnit
ou: people

dn: ou=groups,dc=example,dc=com
objectClass: organizationalUnit
ou: groups

If LDAP is running, shut it down with /etc/init.d/slapd stop

Use ldapadd to add the ldif file to our LDAP database: ldapadd -x -D cn=admin,dc=example,dc=com -W -f myldap.ldif It will ask you for your password that you set during the install.

Fire LDAP back up /etc/init.d/slapd start and then install webmin:

sudo aptitude install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl
sudo dpkg -i webmin_1.441_all.deb

You can now navigate to your LDAP server’s IP at port 10000 https://your-server-ip:10000/. Note you will be required to enter the root password for the computer at this login screen.

From here we need to configure webmin to interact with our LDAP environment. Expand “System” and then select “LDAP Users and Groups.” Click “Module Config” at the top of the page and find the following option and enter this custom data:

Base for users ou=People,dc=example,dc=com
Base for groups ou=Groups,dc=example,dc=com

Click save at the bottom. You will be returned to the previous screen where you can now add LDAP users and groups. This is now a functioning LDAP server. You can query it from the command using ldapsearch

Whole database: ldapsearch -x -h -b "dc=example,dc=com"
User search: ldapsearch -x -h -b "dc=example,dc=com" '(uid=blah)'

Leave a Reply