CSCI-4220 Network Programming

Spring 2000

Project 6 - LDAP Based email database
Due Date: April 28th
Tape Delay Due Date: May 5th

Submission Instructions


LDAP based email address database

This project involves learning about LDAP, specifically about the structure of the information provided by an LDAP server and about the LDAP Application Programming Interface. You need to write a client that can extract some information from an LDAP database and make changes to the database.

A LDAP server with an existing database is running on monte.cs.rpi.edu, you should use this server to test your client code. Your client code can be written to work specifically with this server and the hierarchy (namespace) of the database on this server.

The database provided contains records for each student in the course. The hierarchy looks like this:

school=RPI
    course=Network Programming
        cn=Joe Student
            cn: Joe Student
            email: joe@rpi.edu

The distinguished name for the above record would be: cn=Joe Student, course=Network Programming, school=RPI.This record has two attributes, the cn (common name) attribute and the email attribute. In the example shown each attribute has a single value, but remember that in an LDAP database each attribute can have many values (for example, a student could have many email addresses).

Assignment: For this project you need to write an LDAP client (or clients) that provide the following functionality. Note that I'm showing this functionality being provided by a number of individual client programns - feel free to put this all in a single program if you want.

LDAP Clients: There are a number of sample LDAP clients that come with the OpenLDAP distribution - they are all in /usr/local/bin on monica.cs.rpi.edu (which is probably already in your PATH). Man pages for each are available, and some samples are shown below. These generic clients are just for playing with the LDAP server, you don't need them to do this project.

ldapsearch: used to search an LDAP database. The following command line will print out all the records in the database that have a cn attribute that contains the string "dave":

>  ldapsearch -h monte "cn=*dave*"
cn=Dave Hollinger, course=Network Programming, school=RPI
objectclass=instructor
cn=Dave Hollinger
cn=David Hollinger
email=hollingd@cs.rpi.edu
email=hollid2@rpi.edu
phone=(518) 276-6722
The only record found is mine, and all the attributes are listed. The -h option to ldapsearch specifies the hostname of the machine running the server.

ldapadd: used to add a new record to an LDAP database. The following command line will add the record for Joe Student:

> ldapadd -h monte
dn: cn=Joe Student, course=Network Programming, school=RPI
cn: Joe Student
email: joe@yahoo.com
email: jow@rpi.edu
In the above example the actual record for joe is typed in to STDIN.

Other Clients: Other clients you might want to play with include ldapdelete and ldapmodify.

Sample Code: There are a few sample LDAP clients available at http://www.cs.rpi.edu/~hollingd/netprog/code/ldap/. These are based on the code found in RFC 1823 - LDAP API and will access the database on monte. Fell free to use any parts of this code you find helpful (including the Makefile!).

Building Executables You will need to read the LDAP API RFC (RFC 1823) to understand the LDAP library. This library is installed on monica and on the CS sun workstations. If you can't use any of these machines you will need to get the openldap distribution from www.openldap.org, and build the libraries. Send Dave email if you have problem with this (it's pretty complete and should be easy to build). Installing a server requires a bit more effort, although I can give you copies of the server config files and the sample database (creating these is the only time consuming process involved in getting a server running).

On the CS machines including monica you need to add an include path to your compile command, and some libraries to your link command. Here is an example:

gcc -c -Wall -I/usr/local/include/ client.c
gcc -o client client.o -L/usr/local/lib -lldap -llber  -lkrb -ldes

Hints, Suggestions: