Table of Contents | Previous | Next | Index

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

ldap_get_option()

ldap_get_option() gets session preferences from an LDAP structure. For more information on the options you can retrieve, see "Setting Preferences" on page 53.

Syntax

#include <ldap.h>
int ldap_get_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.

option

Option that you want to retrieve.

optdata

Pointer to the buffer in which the value of the option will be put.

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_DESC

Socket descriptor underlying the main LDAP connection.

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

The LBER_SOCKET data type depends on the platform that you are using:

LDAP_OPT_DEREF

Determines how aliases work 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 the LDAP server.

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

LDAP_OPT_ERROR_NUMBER

Result code for the most recent LDAP error that occurred for this session.

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

LDAP_OPT_ERROR_STRING

Error message returned with the result code for the most recent LDAP error that occurred for this session.

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

LDAP_OPT_EXTRA_THREAD_FN_PTRS

Lets you specify the locking and semaphore functions that you want 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 following 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_RESTART

Determines whether or not LDAP I/O operations should be restarted automatically if they are prematurely aborted.

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

optdata can be one of the following values:

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.

Typically, since controls are specific to the type of request, you may want to pass the controls using operation-specific functions (such as ldap_add_ext()) instead.

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 *).

Note that the LDAP server may impose a smaller size limit than the limit you specify. (The server administrator has the ability to set this limit.)

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 *).

Note that the LDAP server may impose a shorter time limit than the limit you specify. (The server administrator has the ability to set this limit.)

Returns

One of the following values:

Example

The following example gets the session preference for the maximum number of entries to be returned from search operations.

#include <ldap.h>
...
LDAP *ld;
int max_ret;
...
/* Get the maximum number of entries returned */
if (ldap_get_option, LDAP_OPT_SIZELIMIT, &max_ret) != LDAP_SUCCESS) {
   ldap_perror( ld, "ldap_get_option" );
   return( 1 );
}

See Also

ldap_init(), ldap_set_option().


Table of Contents | Previous | Next | Index

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