Table of Contents | Previous | Next | Index

Netscape Directory SDK 3.0 for C Programmer’s Guide
     Chapter 18 Functions

ldapssl_init()

Initializes the LDAP library for SSL and installs the I/O routines for SSL. ldapssl_init() allocates an LDAP structure but does not open an initial connection.

Calling this function is equivalent to calling ldap_init() followed by ldapssl_install_routines() and ldap_set_option() to set the LDAP_OPT_SSL option to LDAP_OPT_ON.

Before calling this function, you should call the ldapssl_client_init() function to initialize your client for SSL. For details, see Chapter 12, "Connecting Over SSL".

Syntax

#include <ldap_ssl.h>
LDAP *ldapssl_init( const char *defhost, int defport, int defsecure );

Parameters

This function has the following parameters:

defhost

Connect to this LDAP server, if no other server is specified.

defport

Connect to this server port, if no other port is specified. To specify the default port 389, use LDAP_PORT as the value for this parameter.

defsecure

Determines whether or not to establish the default connection over SSL. Set this to a non-zero value to establish the default connection over SSL.

Returns

One of the following values:

Example

The following example connects your client with a secure LDAP server.

#include <ldap.h>
#include <ldap_ssl.h>
#include <stdio.h>
...
/* Initialize client, using mozilla's certificate database */
if ( ldapssl_client_init( "/u/mozilla/.netscape/cert5.db", NULL ) < 0) { 
   printf( "Failed to initialize SSL client...\n" ); 
   return( 1 ); 
} 
/* get a handle to an LDAP connection */ 
if ( (ld = ldapssl_init( "cert.netscape.com", LDAPS_PORT, 1 )) == NULL { 
   perror( "ldapssl_init" ); 
   return( 1 ); 
} 
...
/* Client can now perform LDAP operations on the secure LDAP server */
...

See Also

ldap_init(), ldapssl_client_init(), ldapssl_install_routines().


Table of Contents | Previous | Next | Index

Last Updated: 10/01/98 17:06:23