Mozilla LDAP SDK Programmer's Guide/LDAP C SDK Data Type Reference

From MozillaWiki
Jump to: navigation, search

This section contains reference material for the public data types and structures of LDAP C SDK. The first subsections detail the data types of the grouped into task categories. The last subsection is an alphabetical listing of the same information.

Contents

Conventions

The following sections detail certain conventions and concepts used in LDAP C SDK.

Typographical Conventions

The following table lists the typographical conventions used in the names of data types and structures.

Typographical Conventions in Data Types and Structures
Convention Description of Use
LeadingCaps Data structures needed to pass values to and from functions of LDAP C SDK. For consistency, use this typedef name for these structures, not their literal struct name.
ALL_CAPS Names of callback function prototypes which you can implement for extended functionality in your client application.
fns suffix Structures which hold the function pointers for callback functions, grouped by task.

Deprecated Structures

A deprecated API is one you should no longer use for new development, and should begin to phase out for applications you maintain. Deprecated interfaces may disappear in the major version following their deprecation.

Structure Summary by Task

In the following sections the structures defined by LDAP C SDK are grouped into task categories.

BER Structures

The structures listed in the following table represent data encoded using the Basic Encoding Rules (BER). The lber.h header file contains many other type definitions; the ones listed here are those likely to be handled directly. All others are used internally by the various functions of LDAP C SDK.

BER Structures
Structure Description
berval berval represents binary data encoded using BER.
BerElement BerElement indicates the current position during a traversal of an attribute list.

Structures for the Core API

The structures listed in the following table are used by the core functions of LDAP C SDK. These structures are used directly as argument or return types by functions that provide the core functionality.

Core API Structures
Structure Description
LDAP LDAP represents a connection handle to the LDAP server.
LDAPMessage LDAPMessage represents the results of an LDAP operation, a chain of search results, an entry in the search results, or a search reference in the search results.
LDAPMod LDAPMod specifies changes to an attribute in an directory entry.
LDAPControl LDAPControl represents a client or server control associated with an LDAP operation.
LDAPAPIInfo LDAPAPIInfo represents information about the version of LDAP C SDK being implemented
LDAPAPIFeatureInfo LDAPAPIFeatureInfo represents information about the extended features.

Structures for API Extensions

The structures listed in the following table are needed for extensions to the standard API within LDAP C SDK. These structures are used directly as arguments or return types by the functions that provide the extended functionality.

API Extension Structures
Structure Description
LDAPsortkey LDAPsortkey represents a server control used to specify that the server should sort the search results before sending them back to the client.
LDAPVirtualList LDAPVirtualList specifies the information that can be used to create a virtual list view control.
LDAPURLDesc LDAPURLDesc represents the components of an LDAP URL.
LDAPFiltInfo LDAPFiltInfo represents information about a filter in a filter configuration file.
LDAPFiltDesc LDAPFiltDesc is a type of structure returned when you call ldap_init_getfilter to load a filter configuration file.
FriendlyMap FriendlyMap represents the mapping between a list of standard attribute names and their user friendly counterparts.
LDAPMemCache LDAPMemCache represents an in-memory, client-side cache.
LDAPpwdpolicy LDAPpwdpolicy represents password policy information concerning an entry.
LDAPuserstatus LDAPuserstatus represents account availability information.

Note: This prototype for a callback function retrieves authentication information when automatically following referrals to other servers.

Referral Binding Data Type
Data Type Description
LDAP_REBINDPROC_CALLBACK Retrieves authentication information when following referrals to other servers.

Client-Side Sorting Callbacks

The prototype structures listed in the following table are extensions to LDAP C SDK that implement client side sorting of entries.

Client-side Sorting Structures
Data Type Description
LDAP_KEYGEN_CALLBACK Function prototype that generates the sorting key for each entry to be sorted, usually by extracting a value out of an entry.
LDAP_KEYCMP_CALLBACK Function prototype to compare 2 keys (for ordering).
LDAP_KEYFREE_CALLBACK Function prototype that frees the memory allocated during the KEYGEN callback.
LDAP_CMP_CALLBACK Function prototype to sort a specified set of entries.
LDAP_VALCMP_CALLBACK Function prototype to sort a specified set of values.

Extended I/O Control

The following table lists the prototypes and structures used in the extended I/O control, an extension to the standard API.

Structures and Prototypes for Extended I/O Functionality
Data Type Description
ldap_x_ext_io_fns This structure holds extended I/O function pointers.
LDAP_X_PollFD An LDAP file descriptor similar to that of poll().
LDAP_X_EXTIOF_CONNECT_CALLBACK Function prototype for a callback that opens a socket connection.
LDAP_X_EXTIOF_CLOSE_CALLBACK Function prototype for a callback that closes a socket connection.
LDAP_X_EXTIOF_POLL_CALLBACK Function prototype for a callback that surveys a server about a particular event.
LDAP_X_EXTIOF_NEWHANDLE_CALLBACK Function prototype for a callback that defines a new session handle.
LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK Function prototype for a callback that disposes of a session handle.
ldap_x_hostlist_status This structure holds utility functions for parsing space-separated host lists.

Memory Management Control

The prototypes and structures listed in theh following table are used in memory management control, an extension to the standard API. They allow you to specify your own memory allocation mechanisms and functions.

Memory Management Data Types
Data Type Description
ldap_memalloc_fns This structure holds the memory allocation callback functions.
LDAP_MALLOC_CALLBACK LDAP_CALLOC_CALLBACKLDAP_REALLOC_CALLBACK LDAP_FREE_CALLBACK These callbacks allow developers to specify their own memory allocation mechanisms.

Thread Signaling Controls

The prototypes and structures listed in the following table are used in the thread signaling control, an extension to the standard API.

Thread Signaling Control Data Types
Data Type Description
ldap_thread_fns Structure that contains a set of pointers to functions you want to use when writing a multithreaded client.
LDAP_TF_MUTEX_ALLOC_CALLBACK Function prototype for allocating a mutex.
LDAP_TF_MUTEX_FREE_CALLBACK Function prototype freeing a mutex.
LDAP_TF_MUTEX_LOCK_CALLBACK Function prototype for locking critical sections of code.
LDAP_TF_MUTEX_UNLOCK_CALLBACK Function prototype for unlocking critical sections of code.
LDAP_TF_GET_ERRNO_CALLBACK Function prototype for getting the value of the errno variable.
LDAP_TF_SET_ERRNO_CALLBACK Function prototype for setting the value of the errno variable.
LDAP_TF_GET_LDERRNO_CALLBACK Function prototype for getting error values from calls to functions in the libldap library.
LDAP_TF_SET_LDERRNO_CALLBACK Function prototype for setting error values from calls to functions in the libldap library.
ldap_extra_thread_fns Structure that contains a set of pointers to additional functions you want to use when writing a multithreaded client.
LDAP_TF_MUTEX_TRYLOCK_CALLBACK Function prototype for attempting to lock a mutex.
LDAP_TF_SEMA_ALLOC_CALLBACK Function prototype for allocating a semaphore.
LDAP_TF_SEMA_FREE_CALLBACK Function prototype for freeing a semaphore.
LDAP_TF_SEMA_WAIT_CALLBACK Function prototype for waiting for the value of a semaphore to be greater than 0.
LDAP_TF_SEMA_POST_CALLBACK Function prototype for incrementing the value of a semaphore.
LDAP_TF_THREADID_CALLBACK Function prototype to return an identifier that is unique to the calling thread.

Deprecated and Outdated Types

Deprecated types are those being dropped from the standard or from the extensions to LDAP C SDK. They are not guaranteed to be defined in future versions of the API. However, all of these types are still defined in this version for backwards compatibility. The following table lists the deprecated prototypes.

Deprecated Data Types and Their Replacements
Data Type Replacement
LDAP_CANCELPROC_CALLBACK Provides a way to be cancel a process, for example, by a user or because some other condition occurs.
ldap_cache_fns
LDAP_CF_BIND_CALLBACK
LDAP_CF_UNBIND_CALLBACK
LDAP_CF_SEARCH_CALLBACK
LDAP_CF_COMPARE_CALLBACK
LDAP_CF_ADD_CALLBACK
LDAP_CF_DELETE_CALLBACK
LDAP_CF_MODIFY_CALLBACK
LDAP_CF_MODRDN_CALLBACK
LDAP_CF_RESULT_CALLBACK
LDAP_CF_FLUSH_CALLBACK
ldap_cache_fns is a deprecated structure and the typedef declarations associated with it have also been deprecated.
LDAPVersion Replaced by the LDAPAPIInfo type which is returned by the ldap_get_option function using the LDAP_OPT_API_INFO option.

While not officially deprecated, other data types are outdated because they have superseded by new types. Outdated types may become deprecated in future releases of LDAP C SDK. The following table lists the outdated types and the newer types which implement the same functionality.

Outdated Types and Their New Equivalents
Old Data Type New, Equivalent Data Type
LDAPHostEnt
LDAP_DNSFN_GETHOSTBYNAME
LDAP_DNSFN_GETHOSTBYADDR
ldap_dns_fns
The DNS resolver callbacks are an outdated extension to the API. The new way of specifying host information is through the LDAP_X_EXTIOF_CONNECT_CALLBACK prototype.
LDAP_IOF_CLOSE_CALLBACK
LDAP_IOF_CONNECT_CALLBACK
LDAP_IOF_IOCTL_CALLBACK
LDAP_IOF_READ_CALLBACK
LDAP_IOF_SELECT_CALLBACK
LDAP_IOF_SOCKET_CALLBACK
LDAP_IOF_SSL_ENABLE_CALLBACK
LDAP_IOF_WRITE_CALLBACK
ldap_io_fns
Replaced by the types for extended I/O functionality detailed in the section on Extended I/O Control.

Structures Alphabetically

The following sections detail the structures and controls of LDAP C SDK in alphabetical order.

berval

berval is a structure that represents binary data encoded using simplified Basic Encoding Rules (BER).


Description


Use a berval structure when working with attributes that contain binary data (such as a graphic or audio file). The data and the size of the data are both included in a berval structure.

typedef struct berval {
  unsigned long bv_len;
  char *bv_val;
};
berval Field Descriptions
Field What It Contains
bv_len The length of the data in bytes.
bv_val A pointer to the binary data itself.

BerElement

The BerElement structure represents data encoded using the Basic Encoding Rules (BER).


Description


You use this opaque data type to keep track of the current attribute during the traversal of an attribute list. Calling the ldap_first_attribute() function allocates memory for a BerElement structure and initializes it to select the values of the first attribute in the entry.

Subsequently, ldap_next_attribute() is called to obtain the name of each remaining attribute and set BerElement to select their values. Once BerElement has been set to select an attribute's values, ldap_get_values() can be used to obtain all of them from the buffer.

When you are done reading the attributes, you need to free the BerElement structure from memory by calling the ldap_ber_free() function. (A BerElement structure can also be allocated by calling the ber_alloc_t or the ber_init function. In these cases, free the memory allocated to the BerElement structure by using the ber_free() function.)

Note: The BerElement definition is not completely exposed in lber.h because the fields within the structure are not intended to be accessible to clients.

FriendlyMap

FriendlyMap represents the mapping between a list of standard attribute names and their user-friendly counterparts. For example, you can represent the list of two-letter state codes (CA, IA) with their corresponding state names (California, Iowa), or map Country ISO codes to the full country names, in a FriendlyMap structure.

Note:

  • ldap_friendly_name allocates() a FriendlyMap structure and reads a list of standard attribute names and their user friendly counterparts from a file.
  • ldap_free_friendlymap() frees the memory allocated for a FriendlyMap structure.

LDAP

LDAP is an opaque data type representing a connection with the LDAP server. It is initialized through a call to either the ldap_init() or ldapssl_init() function.

LDAP maintains the state of an LDAP session for the duration of the connection. When you call functions that perform LDAP operations on an LDAP server (for example, ldap_search_ext() to search the directory or ldap_modify_ext() to update an entry), you need to pass a pointer to this connection handle.

With the LDAP structure, you can also:

  • Call the ldap_get_option() and ldap_set_option() functions to view or modify the properties of the connection.
  • Call the ldap_unbind() or ldap_unbind_s() function to close the connection and free the LDAP structure.

Note: LDAP is not completely defined in ldap-standard.h because the fields within the structure are not intended to be accessible to clients.

LDAPAPIFeatureInfo

LDAPAPIFeatureInfo is a structure that represents information about the extended features of LDAP C SDK. <title>LDAPAPIFeatureInfo Definition

#define LDAP_FEATURE_INFO_VERSION
typedef struct ldap_apifeature_info {
  int   ldapaif_info_version;       /* version of this struct (1) */
  char  *ldapaif_name;              /* name of supported feature */
  int   ldapaif_version;            /* revision of supported feature */
} LDAPAPIFeatureInfo;

The LDAPAPIFeatureInfo structure can be retrieved by using a sequence like the one displayed below.

LDAPAPIFeatureInfo ldfi;
ldfi.ldapaif_info_version = LDAP_FEATURE_INFO_VERSION;
ldfi.ldapaif_name = "VIRTUAL_LIST_VIEW";
if ( ldap_get_option( NULL, LDAP_OPT_API_FEATURE_INFO, &ldfi ) == 0 )

Parameters


LDAPAPIFeatureInfo Structure Parameters
Parameter Description
ldapaif_info_version Specifies the version number of the LDAPAPIFeatureInfo structure. This must be set to LDAP_FEATURE_INFO_VERSION before call to ldap_get_option() is performed.
ldapaif_name Pointer to NULL terminated string that specifies the name of the supported feature.
ldapaif_version Specifies the version number of the supported feature.

LDAPAPIInfo

LDAPAPIInfo is a structure that represents information about the API and supported extensions.

#define LDAP_API_INFO_VERSION
typedef struct ldapapiinfo {
  int  ldapai_info_version;     /* version of LDAPAPIInfo (1) */
  int  ldapai_api_version;      /* revision of API supported */
  int  ldapai_protocol_version; /* highest LDAP version supported */
  char **ldapai_extensions;     /* names of API extensions */
  char *ldapi_vendor_name;      /* name of supplier */
  int  ldapai_vendor_version;   /* supplier-specific version x 100 */
} LDAPAPIInfo;

The LDAPAPIInfo structure can be retrieved by using a sequence like the one displayed in the following example.

LDAPAPIInfo ldai;
ldai.ldapai_info_version = LDAP_API_INFO_VERSION;
if ( ldap_get_option( NULL, LDAP_OPT_API_INFO, &ldia ) == 0 ) ...

Parameters


LDAPAPIInfo Structure Parameters
Parameter Description
ldapai_info_version Specifies the version number of the LDAPAPIInfo structure. This must be set to LDAP_API_INFO_VERSION before a call to ldap_get_option is performed.
ldapai_api_version Specifies the version number of the API that is supported.
ldapai_protocol_version Specifies the latest LDAP version supported by the LDAP library.
ldapai_extensions Points to a NULL terminated array of character strings that names the supported LDAP extensions. If none are supported, this field is set to NULL. The application is responsible for freeing this memory by calling the ldap_value_free function.
ldapai_vendor_name Pointer to a NULL-terminated string that contains the vendor's name. Call the ldap_memfree function to free the memory.
ldapai_vendor_version Specifies the vendor’s version of the LDAP libraries.

ldap_cache_fns

ldap_cache_fns is a deprecated structure. The following are also deprecated:

  • LDAP_CF_ADD_CALLBACK
  • LDAP_CF_BIND_CALLBACK
  • LDAP_CF_COMPARE_CALLBACK
  • LDAP_CF_DELETE_CALLBACK
  • LDAP_CF_FLUSH_CALLBACK
  • LDAP_CF_MODIFY_CALLBACK
  • LDAP_CF_MODRDN_CALLBACK
  • LDAP_CF_RESULT_CALLBACK
  • LDAP_CF_SEARCH_CALLBACK
  • LDAP_CF_UNBIND_CALLBACK


See Also


See the ldap_memcache_*() functions for current usage.

LDAP_CALLOC_CALLBACK

This callback function prototype of ldap_memalloc_fns() represents memory allocation.


See Also


ldap_memalloc_fns

LDAP_CANCELPROC_CALLBACK

This callback function prototype is deprecated.


See Also


ldap_ufn_search_c, ldap_ufn_search_ct

LDAP_CF_ADD_CALLBACK

This callback function prototype of ldap_cache_fns is deprecated.

LDAP_CF_BIND_CALLBACK

This callback function prototype of ldap_cache_fns is deprecated.

LDAP_CF_COMPARE_CALLBACK

This callback function prototype of ldap_cache_fns is deprecated.

LDAP_CF_DELETE_CALLBACK

This callback function prototype of ldap_cache_fns is deprecated.

LDAP_CF_FLUSH_CALLBACK

This callback function prototype of ldap_cache_fns is deprecated.

LDAP_CF_MODIFY_CALLBACK

This callback function prototype of ldap_cache_fns is deprecated.

LDAP_CF_MODRDN_CALLBACK

This callback function prototype of ldap_cache_fns is deprecated.

LDAP_CF_RESULT_CALLBACK

This callback function prototype of ldap_cache_fns is deprecated.

LDAP_CF_SEARCH_CALLBACK

This callback function prototype of ldap_cache_fns is deprecated.

LDAP_CF_UNBIND_CALLBACK

This callback function prototype of ldap_cache_fns is deprecated.

LDAP_CMP_CALLBACK

LDAP_CMP_CALLBACK specifies the prototype for a comparison callback function used when sorting values. If you define a function with this prototype and specify it when calling ldap_sort_entries() or ldap_multisort_entries(), it will be called by your LDAP client to sort a specified set of entries.

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_CMP_CALLBACK)(const char*, const char*);

See Also


ldap_sort_entries(), ldap_multisort_entries()

LDAPControl

LDAPControl represents a client or server control associated with an LDAP operation. If set as a server control, it is sent to the server along with operation requests; if set as a client control, it is interpreted locally by the client.

Controls are part of the LDAP v3. You can use a control to extend the functionality of an LDAP operation. There are two basic types of controls described in the LDAP v3:

  • Server controls are controls that are sent from the client to the server along with an LDAP request. (In some cases, a server can include a control in the response it sends back to the client.) For example, you can include a server control in a search request to specify that you want the server to sort the search results before sending them back.
  • Client controls are controls that can extend the client but are never sent to the server. As a general example, you might be able to pass a client control to an LDAP API function, which might parse the control and use the data that you‚Äö√Ñ√¥ve specified in the control.

LDAP C SDK does not currently support any client controls.

typedef struct ldapcontrol {
  char *ldctl_oid;
  struct berval ldctl_value;
  char ldctl_iscritical;
} LDAPControl;
LDAPControl Field Descriptions
Field What It Contains
ldctl_oid Object identifier (OID) of the control.
ldctl_value berval structure containing data associated with the control. If you want to specify a zero-length value, set ldctl_value.bv_len to 0 and ldctl_value.bv_val to a zero-length string. To indicate that no data is associated with the control, set ldctl_value.bv_val to NULL.
ldctl_iscritical Specifies whether or not the control is critical to the operation. This field can have one of the following values:
  • A non-zero value specifies that the control is critical to the operation.
  • 0 specifies that the control is not critical to the operation.

LDAP_DNSFN_GETHOSTBYADDR

LDAP_DNSFN_GETHOSTBYADDR specifies the prototype for a callback function equivalent to the gethostbyaddr_r() function available on some UNIX platforms.

Note: If you define a function with this prototype and set it in the ldap_dns_fns structure, your function will be called by the SDK on behalf of your LDAP client if it needs to get the host name of the LDAP server to which it is connected.

In this version of LDAP C SDK, the functions of the API never call this function, and your implementation will never be executed. Therefore, its implementation is optional.

typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK
  LDAP_DNSFN_GETHOSTBYADDR)( const char *addr, int length, int type,
  LDAPHostEnt *result, char *buffer, int buflen, int *statusp,
  void *extradata );

LDAP_DNSFN_GETHOSTBYNAME

LDAP_DNSFN_GETHOSTBYNAME specifies the prototype for a callback function equivalent to the gethostbyname_r() function available on some UNIX platforms.

Note: If you define a function with this prototype and set it in the ldap_dns_fns structure, your function will be called by LDAP C SDK on behalf of your LDAP client to get the host entry for the LDAP server when connecting to the server.

typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK
  LDAP_DNSFN_GETHOSTBYADDR)( const char *addr, int length, int type,
  LDAPHostEnt *result, char *buffer, int buflen, int *statusp,
  void *extradata );

ldap_dns_fns

ldap_dns_fns contains a set of pointers to DNS functions and is equivalent to the gethostbyname_r() and gethostbyaddr_r() functions available on some UNIX platforms.

Note: While not officially deprecated, the functionality of this structure is superseded by the extended I/O functions. The new way of specifying host information is through the LDAP_X_EXTIOF_CONNECT_CALLBACK prototype.


Description


You can use this structure if you want LDAP C SDK to call these functions when looking up the host name or IP address for the LDAP server. For example, you could use this to call versions of the DNS functions that are safe for use in a multithreaded application. The function must have the prototype specified by LDAP_DNSFN_GETHOSTBYADDR.

If NULL, the standard built-in OS routine is used. After you set the fields in this structure, you can register the functions for use by calling the ldap_set_option function and setting the LDAP_OPT_DNS_FN_PTRS option to this structure.

struct ldap_dns_fns {
  void *lddnsfn_extradata;
  int lddnsfn_bufsize;
  LDAP_DNSFN_GETHOSTBYNAME *lddnsfn_gethostbyname;
  LDAP_DNSFN_GETHOSTBYADDR *lddnsfn_gethostbyaddr;
};
ldap_dns_fns Field Descriptions
Field What It Contains
lddnsfn_extradata Value passed in the extradata argument of the LDAP_DNSFN_GETHOSTBYADDR and LDAP_DNSFN_GETHOSTBYNAME function calls.
lddnsfn_bufsize Specifies the size of the buffer that you want passed to your DNS callback function. Your LDAP client passes this value as the buflen argument of the LDAP_DNSFN_GETHOSTBYADDR and LDAP_DNSFN_GETHOSTBYNAME function calls.
lddnsfn_gethostbyname Function pointer for getting the host entry for the LDAP server. This function is called by the client when connecting to the server if the function pointer is not NULL. The function must have the prototype specified by LDAP_DNSFN_GETHOSTBYNAME. If NULL, the standard built-in OS routine is used.
lddnsfn_gethostbyaddr Function pointer for getting the host name of the LDAP server. This function is called by the client when needed if the function pointer is not NULL.

ldap_extra_thread_fns

The ldap_extra_thread_fns structure contains a set of pointers to additional functions that you can use when writing a multithreaded client. Your client calls these functions when getting results from the LDAP structure.

struct ldap_extra_thread_fns {
  LDAP_TF_MUTEX_TRYLOCK_CALLBACK  *ltf_mutex_trylock;
  LDAP_TF_SEMA_ALLOC_CALLBACK     *ltf_sema_alloc;
  LDAP_TF_SEMA_FREE_CALLBACK      *ltf_sema_free;
  LDAP_TF_SEMA_WAIT_CALLBACK      *ltf_sema_wait;
  LDAP_TF_SEMA_POST_CALLBACK      *ltf_sema_post;
  LDAP_TF_THREADID_CALLBACK       *ltf_threadid_fn;
};
ldap_extra_thread_fns Field Descriptions
Field What It Contains
ltf_mutex_trylock Function pointer for attempting to lock a mutex. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_MUTEX_TRYLOCK_CALLBACK.
ltf_sema_alloc Function pointer for allocating a semaphore. This finction is called by the client if needed when the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_SEMA_ALLOC_CALLBACK.
ltf_sema_free Function pointer for freeing a semaphore. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_SEMA_FREE_CALLBACK.
ltf_sema_wait Function pointer for waiting for the value of a semaphore to be greater than 0. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_SEMA_WAIT_CALLBACK.
ltf_sema_post Function pointer for incrementing the value of a semaphore. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_SEMA_POST_CALLBACK.
ltf_threadid_fn Function pointer that is called to retrieve the unique identifier for the calling thread. If this is NULL, it is not used. An example of a similar function in the POSIX threads standard is pthread_self(). The function must have the prototype specified by LDAP_TF_THREADID_CALLBACK.

LDAPFiltDesc

LDAPFiltDesc is a structure that is returned when you call ldap_init_getfilter() to load a filter configuration file.

Note: The LDAPFiltDesc definition is not completely exposed in ldap-extension.h because the fields within the structure are not intended to be accessible to clients.


Description


After calling the ldap_init_getfilter() function, use the pointer to the returned LDAPFiltDesc structure in subsequent calls to get information about filters in the filter configuration file.

LDAPFiltInfo

LDAPFiltInfo represents information about a filter in the filter configuration file.


Description


When you call the ldap_getfirstfilter() or ldap_getnextfilter() functions to get a filter from the filter configuration file, they return a pointer to an LDAPFiltInfo structure containing the information about the filter.

typedef struct ldap_filt_info {
  char *lfi_filter;
  char *lfi_desc;
  int lfi_scope;
  int lfi_isexact;
  struct ldap_filt_info *lfi_next;
} LDAPFiltInfo;
LDAPFilterInfo Field Descriptions
Field What It Contains
lfi_filter The filter, for example (cn=d*).
lfi_desc Description of the filter, also the fifth field in the filter configuration file.
lfi_scope The scope of the filter, also the sixth field in the filter configuration file, which can be one of the following values:
  • LDAP_SCOPE_BASE specifies that the search will be restricted to the current DN.
  • LDAP_SCOPE_ONELEVEL specifies that the search will be restricted to the entries at the level beneath the current DN.
  • LDAP_SCOPE_SUBTREE specifies that the search will encompass entries at all levels beneath the current DN. If the scope of the filter is not specified in the filter configuration file, the scope is LDAP_SCOPE_SUBTREE by default.
lfi_isexact Specifies whether or not the filter is an exact filter, where an exact filter contains no wildcard characters and does not match words that sound alike:
  • 0 specifies that the filter is not an exact filter.
  • 1 specifies that the filter is an exact filter.
lfi_next Pointer to the LDAPFiltInfo structure representing the next filter in the filter list.

The following example prints out information about a filter.

LDAPFiltInfo *lfip;
/* Print out the filter */
printf( "Filter:\t%s\n", lfdp->lfd_filter );
printf( "Description:\t%s\n", lfdp->lfd_desc );

For example, in the filter configuration file, if the first filter that applies to the value @ is:

"@" " " "(mail=%v)" "email address is" "onelevel"

The code prints out:

Filter: (mail=@)
Description: email address is

LDAP_FREE_CALLBACK

This callback function prototype of ldap_memalloc_fns is used to free allocated memory.


See Also


ldap_memalloc_fns

LDAPHostEnt

The LDAPHostEnt structure represents an entry for a host found by a domain name server.

Note: This type is similar to the hostent structure returned by functions such as gethostbyname_r() on UNIX systems.

If you are writing your own DNS functions for use by the client, they should return the host entry in this type of structure.

The fields in this structure should point to addresses within the buffer that is passed to the DNS callback (referenced in the LDAP callback function). This buffer contains the host data. The pointers in the hostent structure returned by the function point to the data in this buffer.

typedef struct LDAPHostEnt {
  char *ldaphe_name;
  char **ldaphe_aliases;
  int ldaphe_addrtype;
  int ldaphe_length;
  char **ldaphe_addr_list;
} LDAPHostEnt;
LDAPHostEnt Field Descriptions
Field What It Contains
ldaphe_name Canonical name of the host
ldaphe_aliases List of aliases for this host
ldaphe_addrtype Address type of the host
ldaphe_length Length of the address
ldaphe_addr_list List of addresses for this host as returned by the name server


See Also


LDAP_DNSFN_GETHOSTBYADDR, LDAP_DNSFN_GETHOSTBYNAME

LDAP_IOF_CLOSE_CALLBACK

LDAP_IOF_CLOSE_CONNECT_CALLBACK specifies the prototype for a callback function equivalent to the standard close() system call.


Description


If you define a function with this prototype and set it in the ldap_io_fns structure, the function will be called by your LDAP client.

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_IOF_CLOSE_CALLBACK )( LBER_SOCKET );

LDAP_IOF_CONNECT_CALLBACK

LDAP_IOF_CONNECT_CALLBACK specifies the prototype for a callback function equivalent to the standard connect() network I/O function.


Description


If you define a function with this prototype and set it in the ldap_io_fns structure, the function will be called by your LDAP client.

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_IOF_CONNECT_CALLBACK )( LBER_SOCKET,
  struct sockaddr *, int );

LDAP_IOF_IOCTL_CALLBACK

LDAP_IOF_IOCTL_CALLBACK specifies the prototype for a callback function equivalent to the standard ioctl() system call.


Description


If you define a function with this prototype and set it in the ldap_io_fns structure, the function will be called by your LDAP client.

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_IOF_IOCTL_CALLBACK)( LBER_SOCKET, int, ... );

LDAP_IOF_READ_CALLBACK

LDAP_IOF_READ_CALLBACK specifies the prototype for a callback function equivalent to the standard read() I/O function.


Description


If you define a function with this prototype and set it in the ldap_io_fns structure, the function will be called by your LDAP client.

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_IOF_READ_CALLBACK)( LBER_SOCKET, void *, int );

LDAP_IOF_SELECT_CALLBACK

LDAP_IOF_SELECT_CALLBACK specifies the prototype for a callback function equivalent to the standard select() I/O function.


Description


If you define a function with this prototype and set it in the ldap_io_fns structure, the function will be called by your LDAP client.

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_IOF_SELECT_CALLBACK)( int, fd_set *, fd_set *,
  fd_set *, struct timeval * );

LDAP_IOF_SOCKET_CALLBACK

LDAP_IOF_SOCKET_CALLBACK specifies the prototype for a callback function equivalent to the standard socket() network I/O function.


Description


If you define a function with this prototype and set it in the ldap_io_fns structure, the function will be called by your LDAP client.

typedef LBER_SOCKET (LDAP_C LDAP_CALLBACK
  LDAP_IOF_SOCKET_CALLBACK)( int, int, int );

LDAP_IOF_SSL_ENABLE_CALLBACK

LDAP_IOF_SSL_ENABLE_CALLBACK specifies the prototype for a callback function equivalent to the ssl_enable() function.


Description


If you define a function with this prototype and set it in the ldap_io_fns structure, the function will be called by your LDAP client.

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_IOF_SSL_ENABLE_CALLBACK )( LBER_SOCKET );

LDAP_IOF_WRITE_CALLBACK

LDAP_IOF_WRITE_CALLBACK specifies the prototype for a callback function equivalent to the standard write() I/O function.


Description


If you define a function with this prototype and set it in the ldap_io_fns structure, the function will be called by your LDAP client.

typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_WRITE_CALLBACK)
  ( LBER_SOCKET, const void *, int );

ldap_io_fns

The ldap_io_fns structure contains a set of pointers to input/output functions that you want used with SDK. You need to set up this structure if you want to connect to the LDAP server using a Secure Sockets Layer (SSL).

struct ldap_io_fns {
  LDAP_IOF_READ_CALLBACK *liof_read;
  LDAP_IOF_WRITE_CALLBACK *liof_write;
  LDAP_IOF_SELECT_CALLBACK *liof_select;
  LDAP_IOF_SOCKET_CALLBACK *liof_socket;
  LDAP_IOF_IOCTL_CALLBACK *liof_ioctl;
  LDAP_IOF_CONNECT_CALLBACK *liof_connect;
  LDAP_IOF_CLOSE_CALLBACK *liof_close;
  LDAP_IOF_SSL_ENABLE_CALLBACK *liof_ssl_enable;
};
ldap_io_fns Field Descriptions
Field What It Contains
liof_read Function pointer to the equivalent of the standard read() I/O function. The function must have the prototype specified by LDAP_IOF_READ_CALLBACK.
liof_write Function pointer to the equivalent of the standard write() I/O function. The function must have the prototype specified by LDAP_IOF_WRITE_CALLBACK.
liof_select Function pointer to the equivalent of the standard select() I/O function. The function must have the prototype specified by LDAP_IOF_SELECT_CALLBACK.
liof_socket Function pointer to the equivalent of the standard socket() network I/O function. The function must have the prototype specified by LDAP_IOF_SOCKET_CALLBACK.
liof_ioctl Function pointer to the equivalent of the standard ioctl() system call. The function must have the prototype specified by LDAP_IOF_IOCTL_CALLBACK.
liof_connect Function pointer to the equivalent of the standard connect() network I/O function. The function must have the prototype specified by LDAP_IOF_CONNECT_CALLBACK.
liof_close Function pointer to the equivalent of the standard close() system call. The function must have the prototype specified by LDAP_IOF_CLOSE_CALLBACK.
liof_ssl_enable Function pointer to the equivalent of the ssl_enable() function. The function must have the prototype specified by LDAP_IOF_SSL_ENABLE_CALLBACK.

LDAP_KEYCMP_CALLBACK

LDAP_KEYCMP_CALLBACK specifies the prototype for a callback function to sort a specified set of entries.


Definition


If you define a function with this prototype and specify it when calling ldap_keysort_entries(), the function will be called by your LDAP client to sort a specified set of entries.


See Also


ldap_keysort_entries

LDAP_KEYFREE_CALLBACK

LDAP_KEYFREE_CALLBACK specifies the prototype for a callback function that frees a sorting key.


Description


ldap_keysort_entries() requires a function pointer that matches the signature defined by this type.

LDAP_KEYGEN_CALLBACK

LDAP_KEYGEN_CALLBACK specifies the prototype for a callback function that generates a key for sorting.


Description


ldap_keysort_entries() requires a function pointer that matches the signature defined by this type.

LDAP_MALLOC_CALLBACK

This callback function prototype of ldap_memalloc_fns represents memory allocation.


See Also


ldap_memalloc_fns

ldap_memalloc_fns

ldap_memalloc_fns is a structure representing callback functions for memory allocation. These are global and can not be set on a per-LDAP session handle basis. Install your own functions by making a call similar to the one detailed in the following example.

ldap_set_option(NULL, LDAP_OPT_MEMALLOC_FN_PTRS, &memalloc_fns);

See Also


  • LDAP_MALLOC_CALLBACK
  • LDAP_CALLOC_CALLBACK
  • LDAP_REALLOC_CALLBACK
  • LDAP_FREE_CALLBACK

LDAPMemCache

LDAPMemCache is a type of structure representing an in-memory, client-side cache. You can create a cache and specify the following information:

  • The maximum size of the cache.
  • The maximum amount of time to keep an item in the cache.
  • A set of base DNs for the search requests that you want to cache (optional).
  • A set of functions to ensure the thread-safety of the cache.

To use a cache, you need to associate it with a connection handle (and LDAP structure). Before a search request is sent to the server, the cache is checked to determine if the same request was made before. If an earlier request was cached, the search results are retrieved from the cache.

Note: The cache uses the search criteria as the key to cached items. Search requests with different criteria are cached as separate items. For example, suppose you send a search request specifying that you just want to retrieve the uid attribute. Your client caches the result of that search. If you send a similar search request specifying that you want to retrieve all attributes instead of just the uid, the result cached from the previous search are not used.

The cache uses a combination of the following information as the key to a cached item:

  • The host name and port number of the LDAP server that you are searching.
  • The DN to which you are currently authenticated.

From the search criteria, the base DN, scope, filter, attributes to be returned, and an indication of whether to return attribute types only or attribute types and values.


Related Functions


The following table lists functions related to the LDAPMemCache structure.

Functions for LDAPMemCache Structure
Function Description
ldap_memcache_init() Creates an LDAPMemCache structure and initialize the caching mechanism.
ldap_memcache_set() Associates an LDAPMemCache structure with a connection handle (an LDAP structure).
ldap_memcache_get() Returns the LDAPMemCache structure that is associated with a connection handle (an LDAP structure).
ldap_memcache_update() Forces the cache to remove expired items.
ldap_memcache_flush() Removes entries from the cache.
ldap_memcache_destroy() Frees the memory used by the cache and frees the LDAPMemCache structure.

LDAPMessage

LDAPMessage is a structure representing the results of an LDAP operation such as a chain of search results, an entry in the search results, or a search reference in the search results.

Note: Calling the ldap_search_ext_s() or ldap_search_ext() followed by the ldap_result function creates an LDAPMessage structure to represent the chain of results from the search. Calling the ldap_first_entry() or ldap_next_entry() function creates an LDAPMessage structure to represent an entry in the search results. Calling ldap_first_reference() or ldap_next_reference() creates an LDAPMessage structure to represent a search reference in the search results. To free the LDAPMessage structure, call the ldap_msgfree() routine.

LDAPMod

LDAPMod is a structure that you use to specify changes to an attribute in a directory entry.


Description


Before you call the ldap_add_ext(), ldap_add_ext_s(), ldap_modify_ext(), or ldap_modify_ext_s() functions to add or modify an entry in the directory, you need to fill LDAPMod structures with the attribute values that you intend to add or change.

typedef struct ldapmod {
  int mod_op;
  char *mod_type;
  union {
  char **modv_strvals;
  struct berval **modv_bvals;
  } mod_vals;
  #define mod_values mod_vals.modv_strvals
  #define mod_bvalues mod_vals.modv_bvals
} LDAPMod;
LDAPMod Field Descriptions
Field What It Contains
mod_op The operation to be performed on the attribute and the type of data specified as the attribute values. This field can have one of the following values:
  • LDAP_MOD_ADD adds a value to the attribute.
  • LDAP_MOD_DELETE removes the value from the attribute.
  • LDAP_MOD_REPLACE replaces all existing values of the attribute.

In addition, if you are specifying binary values in the mod_bvalues field, you should use the bitwise OR operator ( | ) to combine LDAP_MOD_BVALUES with the operation type. For example: mod->mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES Note the following caveats when defining:

  • If you specify LDAP_MOD_DELETE and remove all values in an attribute, the attribute is removed from the entry.
  • If you specify LDAP_MOD_DELETE and NULL in the mod_values field, the attribute is removed from the entry.
  • If you specify LDAP_MOD_REPLACE and NULL in the mod_values field, the attribute is removed from the entry.
  • If you specify LDAP_MOD_REPLACE and the attribute does not exist in the entry, the attribute is added to the entry.
  • If you specify LDAP_MOD_ADD and the attribute does not exist in the entry, the attribute is added to the entry. Also, if you are using the structure to add a new entry, you can specify 0 for the mod_op field, unless you are adding binary values and need to specify LDAP_MOD_BVALUES.
mod_type The attribute type that you want to add, delete, or replace the values of such as sn or telephoneNumber.
mod_values A pointer to a NULL terminated array of string values for the attribute.
mod_bvalues A pointer to a NULL terminated array of berval structures for the attribute.

If you have allocated memory for the structures yourself, you should free them when finished by calling the ldap_mods_free() function.


Example


The following example sets up an LDAPMod structure to change the email address of a user’s entry to bjensen@example.com.

LDAP *ld;
LDAPMod attribute1;
LDAPMod *list_of_attrs[2];
char *mail_values[] = { "bjensen@example.com", NULL };
char *dn;
...
/* Identify the entry that you want changed */
char *dn = "uid=bjensen,ou=People,dc=example,dc=com";
/* Specify that you want to replace the value of an attribute */
attribute1.mod_op = LDAP_MOD_REPLACE;
/* Specify that you want to change the value of the mail attribute */
attribute1.mod_type = "mail";
/* Specify the new value of the mail attribute */
attribute1.mod_values = mail_values;
/* Add the change to the list of attributes that you want changed */
list_of_attrs[0] = &attribute_change;
list_of_attrs[1] = NULL;
/* Update the entry with the change */
if ( ldap_modify_s( ld, dn, list_of_attrs ) != LDAP_SUCCESS ) {
  ldap_perror( ld, "ldap_modify_s" );
  return( 1 );
}
...

LDAPPasswordPolicyError

An LDAPPasswordPolicyError enumeration holds values concerning the state of the password value given the password policy governing a user account.

You fill this enumeration by passing it to the ldap_parse_passwordpolicy_control() function. You then extract textual information from the enumeration by passing it to the ldap_passwordpolicy_err2txt() function.


Description


An LDAPPasswordPolicyError enumeration has the following definition:

typedef enum passpolicyerror_enum {
       PP_passwordExpired = 0,
       PP_accountLocked = 1,
       PP_changeAfterReset = 2,
       PP_passwordModNotAllowed = 3,
       PP_mustSupplyOldPassword = 4,
       PP_insufficientPasswordQuality = 5,
       PP_passwordTooShort = 6,
       PP_passwordTooYoung = 7,
       PP_passwordInHistory = 8,
       PP_noError = 65535
} LDAPPasswordPolicyError;

ldap_passwordpolicy_err2txt() associates the following explanations:

  • Password expired
  • Account locked
  • Password must be changed
  • Policy prevents password modification
  • Policy requires old password in order to change password
  • Password fails quality checks
  • Password is too short for policy
  • Password has been changed too recently
  • New password is in list of old passwords
  • No error
  • Unknown error code


See Also

ldap_create_passwordpolicy_control(), ldap_parse_passwordpolicy_control(), ldap_passwordpolicy_err2txt()

LDAP_REALLOC_CALLBACK

This callback function prototype of ldap_memalloc_fns represents memory allocation.


See Also


ldap_memalloc_fns

LDAP_REBINDPROC_CALLBACK

LDAP_REBINDPROC_CALLBACK specifies the prototype for a callback function that retrieves authentication information when automatically following referrals to other servers.


Description


If you define a function with this prototype and specify it when calling the ldap_set_rebind_proc() function, the function will be called by your LDAP client.

typedef int (LDAP_CALL LDAP_CALLBACK
  LDAP_REBINDPROC_CALLBACK)( LDAP *ld, char **dnp, char **passwdp,
  int *authmethodp, int freeit, void *arg);

See Also


ldap_set_rebind_proc

LDAPsortkey

LDAPsortkey represents the criteria to be used by a server control to sort search results before sending the results back to the client.

Note: Controls are part of the LDAP v3 and are used to extend the functionality of an LDAP operation. The two types of controls described in the LDAP v3 are:

  • Server controls are controls that are sent from the client to the server along with an LDAP request. (In some cases, a server can include a control in the response it sends back to the client.) For example, you can include a server control in a search request to specify that you want the server to sort the search results before sending them back.
  • Client controls are controls that can extend the client but that are never sent to the server. As a general example, you might be able to pass a client control to an LDAP API function, which might parse the control and use the data that you have specified in the control. LDAP C SDK does not currently support any client controls.


Description

typedef struct LDAPsortkey {
  char *sk_attrtype;
  char *sk_matchruleoid;
  int sk_reverseorder;
} LDAPsortkey;
LDAPsortkey Field Descriptions
Field What It Contains
sk_attrtype Pointer to a NULL terminated string that specifies the name of the attribute that you want to use for sorting.
sk_matchruleoid Pointer to a NULL terminated string that specifies the object identifier (OID) of the matching rule that you want to use for sorting.
sk_reverseorder Specifies whether or not the results are sorted in reverse order. This field can have one of the following values:
  • A non-zero value specifies that the results should be sorted in reverse order.
  • 0 specifies that the results should be sorted in normal (forward) order.

As an example, you can use LDAPsortkey to specify that you want the server to sort search results by the roomNumber attribute.

To create an array of LDAPsortkey structures, you can call the ldap_create_sort_keylist() function. To free an array of LDAPsortkey structures, you can call the ldap_free_sort_keylist() function.

LDAP_TF_GET_ERRNO_CALLBACK

LDAP_TF_GET_ERRNO_CALLBACK specifies the prototype for a callback function to get the value of the errno variable for a thread.

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_TF_GET_ERRNO_CALLBACK) ( void );

LDAP_TF_GET_LDERRNO_CALLBACK

LDAP_TF_GET_LDERRNO_CALLBACK specifies the prototype for a callback function to retrieve the LDAP result code for an operation.


Description


If you define a function with this prototype and set it in the ldap_thread_fns structure, your callback function is called when the ldap_get_lderrno() function is called. The arguments of ldap_get_lderrno() are passed to your function, and the value returned by your function is returned by ldap_get_lderrno().

Note: For more details on the arguments and return values that your function must use, see ldap_get_lderrno().

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_TF_GET_LDERRNO_CALLBACK)( char **, char **, void * );

LDAP_TF_SET_ERRNO_CALLBACK

LDAP_TF_SET_ERRNO_CALLBACK specifies the prototype for a callback function to set the value of the errno variable for a thread.

typedef void (LDAP_C LDAP_CALLBACK
  LDAP_TF_SET_ERRNO_CALLBACK)( int );

LDAP_TF_SET_LDERRNO_CALLBACK

LDAP_TF_SET_LDERRNO_CALLBACK specifies the prototype for a callback function to set the LDAP result code for an operation.

Note: For more details on the arguments that your function must use, see ldap_set_lderrno().


Description


If you define a function with this prototype and set it in the ldap_thread_fns structure, your callback function is called when the ldap_set_lderrno() function is called. The arguments of ldap_set_lderrno() are passed to your function.

typedef void (LDAP_C LDAP_CALLBACK
  LDAP_TF_SET_LDERRNO_CALLBACK)( int, char *, char *, void * );

LDAP_TF_MUTEX_ALLOC_CALLBACK

LDAP_TF_MUTEX_ALLOC_CALLBACK specifies the prototype for a callback function to allocate a mutex.


Description

typedef void *(LDAP_C LDAP_CALLBACK
  LDAP_TF_MUTEX_ALLOC_CALLBACK)( void );

See Also


ldap_thread_fns

LDAP_TF_MUTEX_FREE_CALLBACK

LDAP_TF_MUTEX_FREE_CALLBACK specifies the prototype for a callback function to free a mutex.


Description

typedef void (LDAP_C LDAP_CALLBACK
  LDAP_TF_MUTEX_FREE_CALLBACK)( void * );

See Also


ldap_thread_fns

LDAP_TF_MUTEX_LOCK_CALLBACK

LDAP_TF_MUTEX_LOCK_CALLBACK specifies the prototype for a callback function to lock a mutex.


Description

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_TF_MUTEX_LOCK_CALLBACK)( void * );

See Also


ldap_thread_fns

LDAP_TF_MUTEX_TRYLOCK_CALLBACK

This function prototype is not supported in this release of LDAP C SDK.

LDAP_TF_MUTEX_UNLOCK_CALLBACK

LDAP_TF_MUTEX_UNLOCK_CALLBACK specifies the prototype for a callback function to unlock a mutex.


Description

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_TF_MUTEX_UNLOCK_CALLBACK)( void * );

See Also


ldap_thread_fns

LDAP_TF_SEMA_ALLOC_CALLBACK

This function prototype is not supported in this release of LDAP C SDK.

LDAP_TF_SEMA_FREE_CALLBACK

This function prototype is not supported in this release of LDAP C SDK.

LDAP_TF_SEMA_POST_CALLBACK

This function prototype is not supported in this release of LDAP C SDK.

LDAP_TF_SEMA_WAIT_CALLBACK

This function prototype is not supported in this release of LDAP C SDK.

LDAP_TF_THREADID_CALLBACK

LDAP_TF_THREADID_CALLBACK specifies the prototype for a callback function to return an identifier that is unique to the calling thread, much like the POSIX pthread_self() function does.


Description

typedef void *(LDAP_C LDAP_CALLBACK
  LDAP_TF_THREADID_CALLBACK)( void );

See Also


ldap_thread_fns

ldap_thread_fns

The ldap_thread_fns structure contains a set of pointers to functions that you want to use when write a multithreaded client.


Description

struct ldap_thread_fns {
  LDAP_TF_MUTEX_ALLOC_CALLBACK *ltf_mutex_alloc;
  LDAP_TF_MUTEX_FREE_CALLBACK *ltf_mutex_free;
  LDAP_TF_MUTEX_LOCK_CALLBACK *ltf_mutex_lock;
  LDAP_TF_MUTEX_UNLOCK_CALLBACK *ltf_mutex_unlock;
  LDAP_TF_GET_ERRNO_CALLBACK *ltf_get_errno;
  LDAP_TF_SET_ERRNO_CALLBACK *ltf_set_errno;
  LDAP_TF_GET_LDERRNO_CALLBACK *ltf_get_lderrno;
  LDAP_TF_SET_LDERRNO_CALLBACK *ltf_set_lderrno;
  void *ltf_lderrno_arg;
};
ldap_thread_fns Field Descriptions
Field What It Contains
ltf_mutex_alloc Function pointer for allocating a mutex. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_MUTEX_ALLOC_CALLBACK.
ltf_mutex_free Function pointer for freeing a mutex. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_MUTEX_FREE_CALLBACK.
ltf_mutex_lock Function pointer for locking critical sections of code. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_MUTEX_LOCK_CALLBACK.
ltf_mutex_unlock Function pointer for unlocking critical sections of code. This function is called by the client when needed if the function pointer is not NULL. The function must have the prototype specified by LDAP_TF_MUTEX_UNLOCK_CALLBACK.
ltf_get_errno Function pointer for getting the value of the <symbol>errno</symbol> variable. This function is called by the client when needed if the function pointer is not NULL. In a threaded environment, errno is typically redefined at compile time so that it has a value for each thread, rather than a global value for the entire process. Because the libldap library does not know what method your code and threading environment will use to get the value of errno for each thread, it calls this function to obtain the value. The function must have the prototype specified by LDAP_TF_GET_ERRNO_CALLBACK.
ltf_set_errno Function pointer for setting the value of the <symbol>errno</symbol> variable. This function is called by the client when needed if the function pointer is not NULL. In a threaded environment, errno is typically redefined at compile time so that it has a value for each thread, rather than a global value for the entire process. Because the libldap library does not know what method your code and threading environment will use to get the value of errno for each thread, it calls this function to obtain the value. The function must have the prototype specified by LDAP_TF_SET_ERRNO_CALLBACK.
ltf_get_lderrno Function pointer for getting error values from calls to functions in the libldap library. This function is called by the client as needed if the function pointer isn’t NULL. If this function pointer is not set, the libldap library records these errors in fields in the LDAP structure. The function must have the prototype specified by LDAP_TF_GET_LDERRNO_CALLBACK.
ltf_set_lderrno Function pointer for setting error values from calls to functions in the libldap library. This function is called by the client as needed if the function pointer is not NULL. If this function pointer is not set, the libldap library records these errors in fields in the LDAP structure. The function must have the prototype specified by LDAP_TF_SET_LDERRNO_CALLBACK.
ltf_lderrno_arg Additional parameter passed to the functions for getting and setting error values from calls to functions in the libldap library. (*ltf_get_lderrno) and (*ltf_set_lderrno) identify these functions.

LDAPURLDesc

LDAPURLDesc is a structure that represents the components of an LDAP URL.


Description


LDAP URLs have the following syntax:

ldap://''host'':''port''/''dn''?''attributes''?''scope''?(''filter'')

Where, for example:

ldap://ldap.example.com/c=US?o,description?one?(o=Sales)

Calling the ldap_url_parse() function creates an LDAPURLDesc structure with the components of the URL.

typedef struct ldap_url_desc {
  char *lud_host;
  int lud_port;
  char *lud_dn;
  char **lud_attrs;
  int lud_scope;
  char *lud_filter;
  unsigned long lud_options;
} LDAPURLDesc
LDAPURLDesc Field Descriptions
Field What It Contains
lud_host Name of the host in the URL.
lud_port Number of the port in the URL.
lud_dn Distinguished name in the URL. This base entry DN identifies the starting point of the search.
lud_attrs Pointer to a NULL terminated list of the attributes specified in the URL.
lud_scope Integer representing the scope of the search specified in the URL:
  • LDAP_SCOPE_BASE specifies a search of the base entry.
  • LDAP_SCOPE_ONELEVEL specifies a search of all entries one level under the base entry (not including the base entry).
  • LDAP_SCOPE_SUBTREE specified a search of all entries at all levels under the base entry (including the base entry).
lud_filter Search filter included in the URL.
lud_options Options; if LDAP_URL_OPT_SECURE, indicates that the protocol is ldaps:// instead of ldap://.

For example, suppose you pass the following URL to the ldap_url_parse() function:

ldap://ldap.example.com:5000/dc=example,dc=com?cn,mail, \
telephoneNumber?sub?(sn=Jensen)

The resulting LDAPURLDesc structure - ludpp, in this example -- will contain the values in the following table .

LDAPURLDesc Parsed URL Values
Component Value
ludpp->lud_host ldap.example.com
ludpp->lud_port 5000
ludpp->lud_dn dc=example,dc=com
ludpp->lud_attrs[0] cn
ludpp->lud_attrs[1] mail
ludpp->lud_attrs[2] telephoneNumber
ludpp->lud_attrs[3] NULL
ludpp->lud_scope LDAP_SCOPE_SUBTREE
ludpp->lud_filter (sn=Jensen)

To free the LDAPURLDesc structure, call the ldap_free_urldesc() routine.

LDAPuserstatus

An LDAPuserstatus structure holds the values concerning the status of a user account. You fill this structure by passing it to the ldap_parse_userstatus_control() function.


Description


An LDAPuserstatus structure has the following definition:

typedef struct LDAPuserstatus {     /* user account availability   */
  unsigned int us_available;  /* availability status         */
#define LDAP_US_ACCOUNT_USABLE      0
#define LDAP_US_ACCOUNT_NOT_USABLE  1
  int          us_expire;     /* will expire in seconds      */
  int          us_inactive;   /* boolean inactivation status */
#define LDAP_US_ACCOUNT_ACTIVE      0
#define LDAP_US_ACCOUNT_INACTIVE    1
  int          us_reset;      /* boolean password reset      */
#define LDAP_US_ACCOUNT_NOT_RESET   0
#define LDAP_US_ACCOUNT_RESET       1
  int          us_expired;    /* boolean password expired    */
#define LDAP_US_ACCOUNT_NOT_EXPIRED 0
#define LDAP_US_ACCOUNT_EXPIRED     1
  int          us_remaining;  /* remaining logins            */
  int          us_seconds;    /* will unlock in seconds      */
} LDAPuserstatus;
LDAPuserstatus Field Descriptions
Field What It Contains
us_available Whether the account is currently usable
us_expire Number of seconds before the password expires -1 means the password is not set to expire at all.
us_inactive Whether the account is locked
us_reset Whether the password has been reset
us_expired Whether the password has expired
us_remaining Number of remaining grace logins
us_seconds Number of seconds before the server unlocks the account


Memory Concerns


You allocate and free space for the LDAPuserstatus structure.

LDAP_VALCMP_CALLBACK

LDAP_VALCMP_CALLBACK specifies the prototype for a callback function to sort a specified set of values.


Description


If you define a function with this prototype and specify it when calling the ldap_sort_strcasecmp() function, the function will be called by your LDAP client.

typedef int (LDAP_C LDAP_CALLBACK
  LDAP_VALCMP_CALLBACK)(const char**, const char**);

ldap_sort_values() requires a function pointer that matches the signature defined by this type.

ldap_sort_strcasecmp() is a value comparison function defined using this type which can therefore be passed to ldap_sort_values().


See Also


ldap_sort_values(), ldap_sort_strcasecmp()

LDAPVersion

The LDAPVersion structure contains version information about LDAP C SDK.

Call the ldap_version() function to return a pointer to an LDAPVersion structure containing version information.

typedef struct _LDAPVersion {
  int sdk_version;
  int protocol_version;
  int SSL_version;
  int security_level;
} LDAPVersion;
LDAPVersion Field Definitions
Field What It Contains
sdk_version Version number of LDAP C SDK multiplied by 100. For example, the value 600 in this field represents version 6.0.
protocol_version Highest supported LDAP protocol version multiplied by 100. For example, the value 300 in this field represents LDAP v3.
SSL_version Supported SSL version multiplied by 100. For example, the value 300 in this field represents SSL 3.0).
security_level Level of encryption supported in bits. For example, 128 for US domestic or 40 for export. If SSL is not enabled, the value of this field is LDAP_SECURITY_NONE .

LDAPVirtualList

LDAPVirtualList specifies the information that can be used to create a virtual list view control.


Description


A virtual list view control is a LDAP v3 control designed to allow the client to retrieve subsets of search results to display in a virtual list box.

A virtual list box is typically a graphical user interface that displays a long list of entries with a few entries visible.

To display the list, the client usually does not retrieve the entire list of entries from the server. Instead, the client just retrieves the subset of entries to be displayed.

After you create an LDAPVirtualList structure and specify values for its fields, you can create the virtual list view control by calling the function ldap_create_virtuallist_control(). You can pass this control and a server-side sorting control-created by calling the ldap_create_sort_keylist() function and the ldap_create_sort_control() function-to the ldap_search_ext() or ldap_search_ext_s() function.

To get the virtual list view response control sent back from the server, call the ldap_parse_result() function to get the list of controls returned by the server, then call the ldap_parse_virtuallist_control() function to retrieve information from the control. End users can display different sections of the list by scrolling up or down.

Note: The object identifier (OID) for this control is OID 2.16.840.1.113730.3.4.9, or LDAP_CONTROL_VLVREQUEST as defined in ldap.h. It is supported by Directory Server.

The virtual list view control provides the means for your client to request and retrieve certain subsets of a long, sorted list of entries. The control specifies the following information:

  • The entry in the list that is currently selected.
  • The number of entries to be displayed in the list before the selected item.
  • The number of entries to be displayed in the list after the selected entry.

The currently selected entry can be identified in one of the following ways:

  • By the index of the entry in the entire list in which case, the control specifies both the offset of the entry and the total number of entries in the list.
  • By the value of the entry in which case, the control specifies that value.

For example, a virtual list view control might specify that you want to retrieve entries 15 through 24 in a list of 100 results with entry 20 being the selected entry. The control uses the following information to specify this:

  • The selected entry is the 20th entry from the top‚Äö√Ñ√Æin other words, the index or offset of the entry is 20‚Äö√Ñ√Æof a list of 100.
  • Get 5 entries before the selected entry in the list (entries 15 - 19).
  • Get 4 entries after the selected entry in the list (entries 21 - 24).

As another example, a virtual list view control might specify that you want to retrieve a subset of entries that start with the letter c or a later letter in the alphabet. The control might specify the following information:

  • The selected entry is the first entry that starts with the letter c. The size of the list is not relevant in determining the selected entry in this case.
  • Get 5 entries before the selected entry in the list.
  • Get 4 entries after the selected entry in the list.
typedef struct ldapvirtuallist {
  unsigned long ldvlist_before_count;
  unsigned long ldvlist_after_count;
  char *ldvlist_attrvalue;
  unsigned long ldvlist_index;
  unsigned long ldvlist_size;
  void *ldvlist_extradata;
} LDAPVirtualList;
LDAPVirtualList Field Descriptions
Field What It Contains
ldvlist_before_count Number of entries before the selected entry that you want to retrieve.
ldvlist_after_count Number of entries after the selected entry that you want to retrieve.
ldvlist_attrvalue Specifies the value that you want to find in the list. The selected entry in the list is the first entry that is greater than or equal to this value. If this field is NULL, the ldvlist_index and ldvlist_size fields are used to determine the selected entry instead.
ldvlist_index If the ldvlist_attrvalue field is NULL, specifies the offset or index of the selected entry in the list. This field is used in conjunction with the ldvlist_size field to identify the selected entry.
ldvlist_size If the ldvlist_attrvalue field is NULL, specifies the total number items in the list. This field is used in conjunction with the ldvlist_index field to identify the selected entry.
ldvlist_extradata Reserved for application-specific use. This data is not used in the virtual list view control.

LDAP_X_EXTIOF_CLOSE_CALLBACK

This specifies the prototype for an extended I/O callback function to close a socket connection.


Description

typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CLOSE_CALLBACK )(
  int s, void *arg );

See Also


ldap_x_ext_io_fns

LDAP_X_EXTIOF_CONNECT_CALLBACK

This specifies the prototype for an extended I/O callback function to open a socket connection.


Description


LDAP_X_EXTIOF_CONNECT_CALLBACK takes a timeout parameter whose value in milliseconds can be set by calling ldap_set_option().

typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CONNECT_CALLBACK )(
  int s, LDAP_X_SockAddr *saddr, int saddr_len,
  int timeout /* milliseconds */, void *arg );

See Also


ldap_x_ext_io_fns

LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK

This specifies the prototype for an extended I/O callback function to dispose of a session handle.


Description


LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK is called right before the LDAP session handle and its contents are destroyed during ldap_unbind(). The value of the arg parameter passed to the callback is always the default one.

typedef void (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK)(
  LDAP *ld, void *arg );

See Also


ldap_x_ext_io_fns

LDAP_X_EXTIOF_NEWHANDLE_CALLBACK

This specifies the prototype for an extended I/O callback function to define a new session handle.


Description


LDAP_X_EXTIOF_NEWHANDLE_CALLBACK is called right after the LDAP session handle is created during ldap_init(). The value of the arg parameter passed to the callback is always the default one. If the callback returns anything other than LDAP_SUCCESS, the session handle allocation fails.

typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_NEWHANDLE_CALLBACK)(
  LDAP *ld, void *arg );

See Also


ldap_x_ext_io_fns

ldap_x_ext_io_fns

This is a structure to hold extended I/O function pointers.

struct ldap_x_ext_io_fns {
/* lextiof_size should always be set to LDAP_X_EXTIO_FNS_SIZE */
  int                                     lextiof_size;
  LDAP_X_EXTIOF_CONNECT_CALLBACK          *lextiof_connect;
  LDAP_X_EXTIOF_CLOSE_CALLBACK            *lextiof_close;
  LDAP_X_EXTIOF_READ_CALLBACK             *lextiof_read;
  LDAP_X_EXTIOF_WRITE_CALLBACK            *lextiof_write;
  LDAP_X_EXTIOF_POLL_CALLBACK             *lextiof_poll;
  LDAP_X_EXTIOF_NEWHANDLE_CALLBACK        *lextiof_newhandle;
  LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK    *lextiof_disposehandle;
  void                                    *lextiof_session_arg;
  LDAP_X_EXTIOF_WRITEV_CALLBACK           *lextiof_writev;
};
#define LDAP_X_EXTIO_FNS_SIZE   sizeof(struct ldap_x_ext_io_fns)

LDAP_X_EXTIOF_POLL_CALLBACK

This specifies the prototype for an extended I/O callback function to close a socket connection.


Description


The LDAP_X_EXTIOF_POLL_CALLBACK interface is provided instead of a standard select() interface. The time out is in milliseconds. The value of the <parameter>arg</parameter> parameter passed to the callback is always the default one.

typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_POLL_CALLBACK)(
  LDAP_X_PollFD fds[], int nfds, int timeout /* milliseconds */,
  void *arg );

See Also


ldap_x_ext_io_fns, LDAP_X_PollFD

ldap_x_hostlist_status

This structure contains utility functions for parsing space-separated host lists.


Description

struct ldap_x_hostlist_status;
LDAP_API(int) LDAP_CALL ldap_x_hostlist_first( const char *hostlist,
  int defport, char **hostp, int *portp /* host byte order */,
  struct ldap_x_hostlist_status **statusp );
  LDAP_API(int) LDAP_CALL ldap_x_hostlist_next( char **hostp,
  int *portp /* host byte order */,
  struct ldap_x_hostlist_status *status
);
LDAP_API(void) LDAP_CALL ldap_x_hostlist_statusfree(
  struct ldap_x_hostlist_status *status );

LDAP_X_PollFD

This is a structure to hold the set of file descriptors that will be surveyed for I/O by the LDAP_X_EXTIOF_POLL_CALLBACK.


Description

typedef struct ldap_x_pollfd {    /* used by LDAP_X_EXTIOF_POLL_CALLBACK */
  int  lpoll_fd; /* integer file descriptor / socket */
  void *lpoll_arg; /* pointer socket and for use by application */
  short lpoll_events; /* requested event */
  short lpoll_revents; /* returned event */
} LDAP_X_PollFD;