ldap_init()--Perform an LDAP Initialization Operation




Syntax

#include <ldap.h>

LDAP *ldap_init(
		char 	*host,
                int 	port)



Threadsafe: Yes

The ldap_init() function is used to allocate an LDAP structure, which is used to identify the connection and to maintain per-connection information.

The ldap_init() function returns a pointer to an LDAP structure, which should be passed to subsequent calls to other LDAP functions such as ldap_bind() and ldap_search().

ldap_init() initializes a session with an LDAP server. The server is not actually contacted until an operation is performed that requires it, allowing various options to be set after initialization, but before actually contacting the host. It allocates an LDAP structure which is used to identify the connection and maintain per-connection information. Although still supported, the use of ldap_open() is deprecated. The ldap_open() API allocates an LDAP structure and opens a connection to the LDAP server. Use of ldap_init() instead of ldap_open() is recommended.

Authorities and Locks

No OS/400 authority is required. All authority checking is done by the LDAP server.

Parameters

host
(Input) Specifies the name of the host on which the LDAP server is running. The host parameter may contain a blank-separated list of hosts to try to connect to, and each host may optionally be of the form host:port. If present, the :port overrides the port parameter supplied on ldap_init(), ldap_ssl_init() or ldap_open(). If the host parameter is null, the LDAP server will be assumed to be running on the local host. If the host parameter is prefixed with "/", the host parameter is assumed to be the name of a Unix socket (i.e. socket family is AF_UNIX) and port is ignored. Use of a Unix socket requires the LDAP server to be running on the local host. In addition, the local operating system must support Unix sockets and the LDAP server must be listening on the specified Unix socket.
port
(Input) Specifies the port number to which to connect. If the default IANA-assigned port of 389 is desired, LDAP_PORT should be specified. To use the default SSL port 636 for SSL connections, use LDAPS_PORT.

Return Value

Pointer to an LDAP structure
if the request was successful.
NULL
if the request was not successful.

Error Conditions

ldap_init() will return NULL and set the ld_errno error code, if not successful. See LDAP Client API Error Conditions for possible LDAP error codes values.

Error Messages

    The following message may be set from this function.
    CPF3CF2 E  Error(s) occurred during running of ldap_init API.

Related Information

    ldap_open() -- Open a connection to an LDAP server (deprecated).
    ldap_set_option() -- Set an option associated with an LDAP descriptor.
    ldap_get_option() -- Get an option associated with an LDAP descriptor.
    ldap_version() -- Obtain LDAP version and SSL cipher information.


Top | LDAP APIs List
APIs by category

[Information Center Home Page | Feedback ] [Legal | AS/400 Glossary]