Previous Contents Index DocHome Next |
Netscape LDAP SDK for C LDAP SDK for C |
Chapter 3 A Short Example
This chapter provides a simple example of an LDAP client written with the Netscape LDAP SDK for C.The chapter contains the following sections:
Understanding the Sample Client
Understanding the Sample Client
The following is the source code for a command-line program (a console application) that retrieves the full name, last name, email address, and telephone number of Barbara Jensen.
Compiling the Sample Client
How you compile the example program depends on the operating system on which you compile. Below are examples of compiling on Solaris and Windows NT systems.
Compiling on Solaris
The examples directory contains a sample UNIX makefile. You can modify the makefile to compile the example in this section by adjusting the flags specified in this file as needed. The makefile assumes that the LDAP API header files are located in the ../include directory.For example, you can use the following Solaris makefile for this example:
Compiling on Windows NT
If you are compiling this on Windows NT, set up a makefile for this application. Make sure to do the following:
If you are using Microsoft Visual C++, create a new project workspace for a console application. Add the source file to the project.
Set your options to include lib as one of the directories containing library files and include as one of the directories containing include files.
Link to nsldap32v41.lib, the LDAP API import library for Windows.
Running the Sample Client
First, make sure your LDAP server is set up with the entry that the example attempts to find. For example, if you are running the Netscape Directory Server 4.x, make sure the Arius.ldif file is imported in the database.
Running on UNIX
If you have compiled and linked the client on a UNIX platform, make sure to set your LD_LIBRARY_PATH variable to the location of the libldap41.so, plc3, plds3, and nspr3 library files. (As an alternative, when linking the file, specify the flag that identifies the library directories that the run-time linker should search. For example, on Solaris, use the -R flag to specify the location of the libldap41.so file.)
Running on Windows NT
If you have linked the client with the nsldap32v41.lib import library on Windows NT, make sure to copy the nsldap32v41.dll dynamic link library file to one of the following directories:
The directory from which the application loaded.
The 32-bit Windows system directory (in Windows NT, this directory is typically winnt\system32).
Previous Contents Index DocHome Next
Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.
Last Updated November 16, 2000