ldap_app_ssl_init_np--Initialize an SSL Connection


  Syntax
 #include <ldap.h>
 #include <ldapssl.h>
 
 LDAP *ldap_app_ssl_init_np(
        char       *host,
        int        port)

  Library Name/Service Program: QSYS/QGLDCLNT

  Default Public Authority: *USE

  Threadsafe: Yes

The ldap_app_ssl_init_np() routine is used to initialize a secure SSL session with a server. Note that the server is not actually contacted until an operation is performed that requires it, allowing various options to be set after initialization. Once the secure connection is established, all subsequent LDAP messages that flow over the secure connection are encrypted, including the ldap_simple_bind() parameters, until ldap_unbind() is called.

Note that when connecting to an LDAP V2 server, one of the ldap_simple_bind() or ldap_bind() calls must be completed before other operations can be performed on the session (with the exception of ldap_set/get_option()). The LDAP V3 protocol does not require a bind operation before performing other operations.

The ciphers for the encryption of the connection are based on the current Crypto Access Provider licensed program loaded. See ldap_get or set_option() for more information on setting the ciphers to be used.


Authorities and Locks

*R authority is needed to the selected Certificate Store and *X to the associated directories.


Parameters

host
(Input) Several methods are supported for specifying one or more target LDAP servers, including the following:


port
(Input) The port number to which to connect. If the default IANA-assigned SSL port of 636 is desired, LDAPS_PORT should be specified. The value specified for this parameter is ignored in some situations; see the description for the host parameter.

Return Value

Session Handle
if the request was successful. The Session Handle returned by ldap_app_ssl_init_np() is a pointer to an opaque data type representing an LDAP session. The ldap_get_option() and ldap_set_option() APIs are used to access and set a variety of session-wide parameters; see these APIs for more information.

NULL
if the request was not successful.

Error Conditions

ldap_app_ssl_init_np() will return NULL if not successful.


Error Messages

The following message may be sent from this function.



Related Information


Example

The following scenario depicts the recommended calling sequence where the entire set of LDAP transactions are protected by using a secure SSL connection.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

 rc = ldap_app_ssl_client_init_np (dcm_identifier, &reasoncode);
 ld = ldap_app_ssl_init_np(ldaphost, ldapport );
 rc = ldap_set_option( ld, LDAP_OPT_SSL_CIPHER, &ciphers);
        rc = ldap_sasl_bind_s( ld, NULL, LDAP_MECHANISM_EXTERNAL, NULL, NULL, NULL );

 ...additional LDAP API calls

 rc = ldap_unbind( ld );


API introduced: V5R1

[ Back to top | LDAP APIs | APIs by category ]