Functions for Thread-Safe LDAP Connections
Chapter
15
Function Reference
371
If you specify a non-zero value for the
shared
argument, this function installs the
server’s threading functions and allows multiple threads to share this session (the
returned
LDAP
structure). Note that the Directory Server processes each request in
a separate thread. When handling multiple requests, it is possible for the server to
call your plug-in function concurrently for different threads.
If you initialize a session by calling this function, make sure to call the
slapi_ldap_unbind()
function (not the
ldap_unbind()
or
ldap_unbind_s()
functions provided with the Directory Server SDK) when you are done with the
session.
As the
slapi_ldap_init()
function returns a regular
LDAP *
, you can use the
LDAP C SDK connect timeout feature for plug-ins. That is, when connecting to an
external LDAP server from a plug-in, you can specify a time limit for establishing
the connection. To specify the timeout, after calling
slapi_ldap_init()
, call
ldap_set_option()
with the
LDAP_X_OPT_CONNECT_TIMEOUT
option as illustrated
in the sample code below:
void
my_ldap_function( void )
{
LDAP *ld;
int to = 5000; /* 5000 milliseconds == 5 second timeout */
if (( ld = slapi_ldap_init( host, port, 0, 1 )) == NULL ) {
/* error trying to create an LDAP session */
return -1;
}
if ( ldap_set_option( ld, LDAP_X_OPT_CONNECT_TIMEOUT, &to ) != 0 ) {
/* error setting timeout */
slapi_ldap_unbind( ld );
return -1;
}
/* use the handle, e.g., call ldap_search_ext() */
slapi_ldap_unbind( ld );
return 0;
}
slapi_ldap_unbind()
Unbinds from another LDAP server and frees the resources contained in the LDAP
structure.
Содержание NETSCAPE DIRECTORY SERVER 6.2 - GATEWAY CUSTOMIZATION
Страница 1: ...Plug In Programmer s Guide Netscape Directory Server Version6 2 December 2003...
Страница 18: ...18 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 26: ...Types of Directory Server Plug Ins 26 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 38: ...Compiling a Directory Server Plug In 38 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 54: ...An Example Pre Operation Plug In 54 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 56: ...56 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 90: ...Processing an LDAP Abandon Operation 90 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 110: ...Using SASL with an LDAP Client 110 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 112: ...112 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 122: ...Specifying Start and Close Functions 122 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 168: ...Plug In API Reference 168 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 170: ...170 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 214: ...Summary of Data Types and Structures 214 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 554: ...Functions for Registering Additional Plug Ins 554 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 596: ...Parameters for the Virtual Attribute Service 596 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 600: ...600 Netscape Directory Server Plug In Programmer s Guide December 2003...
Страница 612: ...612 Netscape Directory Server Plug In Programmer s Guide December 2003...