Mozilla LDAP C SDK: Source Code Documentation

Last Updated: May 13, 2002

Contents

Overview

The source code for the LDAP C SDK consists of a library that implements the LDAP API and some command line utilities that provide LDAP access (e.g., the ldapsearch utility). The LDAP library defines functions that can establish sessions with LDAP servers, create and send LDAP requests to the servers, and retrieve responses from the servers.

In the LDAP protocol, requests and responses are encoded using the Basic Encoding Rules (BER). The SDK source code include functions for encoding and decoding data, according to these rules.

There is work underway in the IETF to standardize a LDAP API for C programmers, and the Mozilla LDAP C SDK closely follows the latest proposals.

Source Tree Directory Structure

The source code for the Mozilla LDAP C SDK is organized in the following directories:

mozilla/
  directory/
    c-sdk/              // Main makefile
      ldap/
        build/          // LDAP-specific build scripts
        clients/tools   // Command line utilities
        examples/       // Sample code
        include/        // Header files
        libraries/
          liblber/      // Functions for BER-encoding, decoding, and I/O
          libldap/      // Functions implementing the LDAP API
          libldif/      // Functions for manipulating LDIF data
          libprldap/    // LDAP to NSPR "glue" library
          libslldap/    // LDAP to NSS "glue" library
          macintosh/    // MacOS-specific files
          msdos/        // Windows-specific files
            winsock/    // Windows .def files
  dist/			// Contains the built SDK (created
                        //   when you build the SDK)

Internal Architecture

The following diagram illustrates the internal architecture of the library:

Roadmap of the Source Files

The different sets of functions and source code files are described below.

Header Files. The following header files define the internal structures used in this library:

LDAP Operation API Functions. These API functions are responsible for requesting LDAP operations from the server (such as ldap_search_ext_s() and ldap_add_ext()).

These functions are defined in the following files:

In addition, functions defined in the following files implement other aspects of the LDAP protocol as well as extensions to the protocol:

Parsing Functions. These API functions are responsible for getting data from structures that represent entries, attributes, and other containers (such as ldap_get_dn() and ldap_get_values()).

These functions are defined in the following files:

Utility Functions. These are utility functions in the API.

These functions are defined in the following files:

Request and Result Handling Functions. These functions are responsible for generating and sending requests to an LDAP server and for handling results returned from an LDAP server. The LDAP operation functions call these functions to send LDAP requests and retrieve results from an LDAP server.

These functions are defined in the following files:

Miscellaneous Functions. These are miscellaneous functions.

These functions are defined in the following files:

BER Encoding, Decoding, and I/O Functions. These functions encode requests and decode results, according to the Basic Encoding Rules (BER). The functions are also responsible for sending BER-encoded requests to the server and receiving BER-encoded results from the server.

These functions are defined in the following files, which are located in the liblber directory:

Unused Functions. The following source files are not compiled or used in the library. (ifdefs are used to omit the entire source code in these files.)

The following diagrams illustrate how ldap_search_ext_s() calls other library functions to generate and send an LDAP search request to the server and to get results back from the server. Figure 1 illustrates how the function generates and sends the request, while Figure 2 illustrates how the function gets results back.

Figure 2: How ldap_search_ext_s() gets search results.