ldap_open()--Perform an LDAP Open Operation




Syntax

#include <ldap.h>

LDAP *ldap_open(
		char 	*host,
                int 	port)



Threadsafe: Yes

The ldap_open() function opens a connection to an LDAP server and allocates an LDAP structure, which is used to identify the connection and to maintain per-connection information.

The ldap_open() 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_open() 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.

As a rule of thumb, the LDAP application is typically running as LDAP V2 when it uses ldap_open() to create the LDAP connection. The LDAP application is typically running as LDAP V3 when it uses ldap_init() to create the LDAP connection. However, it was possible with the LDAP V2 API to call ldap_init() so that there may be cases where this rule of thumb is not true.

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_open() 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_open API.

Related Information

    ldap_init() -- Initializes a session with an LDAP server.
    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]