[Previous] [Next] [TOC] [Index]

Chapter 2
Using the Directory SDK

his chapter describes the Lightweight Directory Access Protocol (LDAP) Application Programming Interface (API) and the Netscape Directory Server Software Development Kit (SDK).

The chapter contains the following sections:

LDAP Application Programming Interface

The LDAP API consists of a set of functions that you can use to build LDAP clients. The LDAP API includes functions that allow you to connect to LDAP servers and perform LDAP operations. Using the API functions, you can:

For example, if you are writing an email application, you can use LDAP API functions to retrieve email addresses from an LDAP server.

The API functions also allow you to perform LDAP operations synchronously or asynchronously.

Directory SDK

The Directory Software Developer's Kit (SDK) includes libraries implementing the LDAP API functions. You can link to these libraries to enable your application to use LDAP.

For a list of the names and locations of the library and header files, see the release notes.

Including the LDAP Header File

When writing your LDAP client, make sure to include the ldap.h header file.

#include <ldap.h>
The ldap.h header file declares the LDAP API functions.

If your client calls any of the LDAP SSL functions, make sure to include the ldap_ssl.h header file:

#include <ldap_ssl.h>

Compiling Clients

This section provides general tips for compiling on different platforms, including:

Compiling Clients on UNIX

When compiling clients on UNIX platforms, you need to link to the LDAP API shared library (libldap10.so on Solaris and IRIX, libldap10.sl on HP-UX, and libldap10_shr.a on AIX)

For example, if the libldap10.so shared library is in the /usr/ldap/lib directory, add the following link flags:

-L/usr/ldap/lib -lldap10 
If you linked to the shared library, you need to make sure that the LDAP client can find the library. Do one of the following:

Here are some additional tips for compiling on UNIX platforms:

Compiling Clients on Windows

When compiling clients on Windows platforms, make sure to define _CONSOLE (if you are writing a console application) or _WINDOWS (if you are writing a standard Windows application).

You need to link to one of the following files:

Make sure that the LDAP client can find the library. Do one of the following:

During run-time, LDAP clients search for the dynamic link library in the following locations:

  1. The directory from which the application loaded.

  2. The current directory.

  3. The 32-bit Windows system directory. (In Windows 95, this directory is typically windows\system. In Windows NT, this directory is typically winnt\system32.)

  4. (Windows NT only) The 16-bit Windows system directory. (This directory is typically winnt\system.)

  5. The Windows directory.

  6. The directories listed in the PATH environment variable.

Compiling Clients on Mac OS

When compiling clients on Mac OS, you need to link to the NSLDAPLib shared library. You need to make sure that the LDAP client can find the shared library. Do one of the following:

Getting Version Information

You can get version information about the particular version of the Directory SDK that you are using. To get this version information, call the ldap_version() function. This function fills an LDAPVersion structure that contains the version information.

The following example illustrates the kinds of version information you can retrieve from this structure.


#include <ldap.h>
#include <stdio.h>
LDAPVersion ver;
double SDKVersion;
/* Print version information */
SDKVersion = ldap_version( &ver );
printf( "SDK Version: %f\n", SDKVersion/100.0 );
printf( "Highest LDAP Protocol Supported: %f\n", 
         ver.protocol_version/100.0 );
printf( "SSL Level Supported: %f\n", ver.SSL_version/100.0 );
if ( ver.security_level != LDAP_SECURITY_NONE ) {
   printf( "Level of encryption: %d bits\n", ver.security_level );
} else {
   printf( "SSL not enabled.\n" );
}


[Previous] [Next] [TOC] [Index]

Last modified: March 31, 1997
Copyright © 1997 Netscape Communications Corporation