Table of Contents | Previous | Next | Index

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

ldap_set_option()

ldap_set_option() sets session preferences in the LDAP structure. For more information on the options you can set, see "Setting Preferences" on page 53.

Syntax

#include <ldap.h>
int ldap_set_option( LDAP *ld, int option, void *optdata );

Parameters

This function has the following parameters:

ld

Connection handle, which is a pointer to an LDAP structure containing information about the connection to the LDAP server.

If NULL, you are setting the default options that will apply to any new LDAP connection handles that are subsequently created.

option

Option that you want to set.

optdata

Pointer to the value of the option that you want to set.

The option parameter can have one of the following values:

LDAP_OPT_CLIENT_CONTROLS

Pointer to an array of LDAPControl structures representing the LDAP v3 client controls you want sent with every request by default.

The data type for the optdata parameter is (LDAPControl ***).

LDAP_OPT_DEREF

Determines how aliases are handled during a search.

The data type for the optdata parameter is (int *).

optdata can be one of the following values:

LDAP_OPT_DNS_FN_PTRS

Lets you use alternate DNS functions for getting the host entry of an LDAP server.

The data type for the optdata parameter is (struct ldap_dns_fns *).

LDAP_OPT_EXTRA_THREAD_FN_PTRS

Lets you specify the locking and semaphore functions called when getting results from the server. (See Appendix , "Writing Multithreaded Clients" for details.)

The data type for the optdata parameter is (struct ldap_extra_thread_fns *).

LDAP_OPT_IO_FN_PTRS

Lets you use alternate communication stacks.

The data type for the optdata parameter is (struct ldap_io_fns *).

LDAP_OPT_PROTOCOL_VERSION

Version of the protocol supported by your client.

The data type for the optdata parameter is (int *).

You can specify either LDAP_VERSION2 or LDAP_VERSION3. If no version is set, the default is LDAP_VERSION2.

In order to use LDAP v3 features, you need to set the protocol version to LDAP_VERSION3.

LDAP_OPT_REBIND_ARG

Lets you set the last argument passed to the routine specified by LDAP_OPT_REBIND_FN.

You can also set this option by calling the ldap_set_rebind_proc() function.

The data type for the optdata parameter is (void *).

LDAP_OPT_REBIND_FN

Lets you set the routine to be called when you need to authenticate a connection with another LDAP server (for example, during the course of a referral).

You can also set this option by calling the ldap_set_rebind_proc() function.

The data type for the optdata parameter is (LDAP_REBINDPROC_CALLBACK *).

LDAP_OPT_RECONNECT

If the connection to the server is lost, determines whether or not the same connection handle should be used to reconnect to the server.

The data type for the optdata parameter is (int *).

optdata can be one of the following values:

By default, this option is off.

For details, see "Handling Failover" on page 102.

LDAP_OPT_REFERRALS

Determines whether or not the client should follow referrals.

The data type for the optdata parameter is (int *).

optdata can be one of the following values:

By default, the client follows referrals.

LDAP_OPT_REFERRAL_HOP_LIMIT

Maximum number of referrals the client should follow in a sequence (in other words, the client can only be referred this number of times before it gives up).

The data type for the optdata parameter is (int *).

By default, the maximum number of referrals that the client can follow in a sequence is 5 for the initial connection.

Note that this limit does not apply to individual requests that generate multiple referrals in parallel.

LDAP_OPT_SERVER_CONTROLS

Pointer to an array of LDAPControl structures representing the LDAP v3 server controls you want sent with every request by default.

The data type for the optdata parameter is (LDAPControl ***).

LDAP_OPT_SIZELIMIT

Maximum number of entries that should be returned by the server in search results.

The data type for the optdata parameter is (int *).

LDAP_OPT_SSL

Determines whether or not SSL is enabled.

The data type for the optdata parameter is (int *).

optdata can be one of the following values:

LDAP_OPT_THREAD_FN_PTRS

Lets you specify the thread function pointers. (See Appendix , "Writing Multithreaded Clients" for details.)

The data type for the optdata parameter is (struct ldap_thread_fns *).

LDAP_OPT_TIMELIMIT

Maximum number of seconds that should be spent by the server when answering a search request.

The data type for the optdata parameter is (int *).

Returns

One of the following values:

Example

The following section of code sets the maximum number of entries returned in a search.

#include <stdio.h>
#include <ldap.h>
...
LDAP *ld;
int max_ret = 100, max_tim = 30;
char *host = "ldap.netscape.com";
...
/* Initialize a session with the LDAP server ldap.netscape.com:389 */
if ( ( ld = ldap_init( host, LDAP_PORT ) ) == NULL ) { 
   perror( "ldap_init" );
   return( 1 );
}
/* Set the maximum number of entries returned */
if (ldap_set_option( ld, LDAP_OPT_SIZELIMIT, &max_ret) != LDAP_SUCCESS) {
   ldap_perror( ld, "ldap_set_option" );
   return( 1 );
}
...

See Also

ldap_init(), ldap_get_option().


Table of Contents | Previous | Next | Index

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