Typical API usage

The typical API usage provides an understanding about the LDAP connection.

The basic interaction is as follows:
  1. A connection is made to an LDAP server by calling either ldap_init or ldap_ssl_init. This call is used to establish a secure connection over Secure Sockets Layer (SSL).
  2. An LDAP bind operation is run by calling ldap_simple_bind. The bind operation is used to authenticate to the directory server. The LDAP V3 API and protocol provides the bind to be skipped, in which case the access rights associated with anonymous access are obtained.
  3. Other operations are run by calling one of the synchronous or asynchronous routines. For example, ldap_search_s or ldap_search followed by ldap_result.
  4. Results that are returned from these routines are interpreted by calling the LDAP parsing routines, which include operations such as:
    • ldap_first_entry, ldap_next_entry
    • ldap_get_dn
    • ldap_first_attribute, ldap_next_attribute
    • ldap_get_values
    • ldap_parse_result (new for LDAP V3)
  5. The LDAP connection is terminated by calling ldap_unbind.

When you handle a client referral to another server, the ldap_set_rebind_proc routine defines the entry point of a routine that is called when an LDAP bind operation is needed.