Spring 2000
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:
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.
emaillookup that might work like this:
> emaillookup monte "Dave Hollinger" hollingd@cs.rpi.eduIn this case monte is the host running the LDAP server on the default LDAP port (389). It is possible that there is more than one email address in the database, so it could also look like this:
> emaillookup monte "Dave Hollinger" hollingd@cs.rpi.edu hollid2@rpi.edu
emailchange that might work like
this:
> emailchange monte "Joe Student" joe@rpi.edu joe@hotmail.com Old address: joe@rpi.edu New address: joe@hotmail.com > emaillookup monte "Joe Student" joe@hotmail.comIn this case monte is the host running the LDAP server, and the
emailchange program changed the email address
associated with the person "Joe Student". Note that you need to
specify which email address should be changed since there may be
many.
emailadd that might work like this:
> emailadd monte "Dave Hollinger" holl@yahoo.com New address: holl@yahoo.com > emaillookup monte "Dave Hollinger" hollingd@cs.rpi.edu hollid2@rpi.edu holl@yahoo.com
emailremove that might work like this:
> emailremove monte "Dave Hollinger" holl@yahoo.com Remiving: holl@yahoo.com > emaillookup monte "Dave Hollinger" hollingd@cs.rpi.edu hollid2@rpi.edu
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-6722The 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.eduIn 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: