Add timeout / network timeout to bindconf

This commit is contained in:
Howard Chu 2007-02-05 11:03:59 +00:00
parent 2432378de8
commit b5d8341569
2 changed files with 17 additions and 0 deletions

View File

@ -1033,6 +1033,8 @@ static slap_cf_aux_table bindkey[] = {
{ BER_BVC("uri="), offsetof(slap_bindconf, sb_uri), 'b', 1, NULL }, { BER_BVC("uri="), offsetof(slap_bindconf, sb_uri), 'b', 1, NULL },
{ BER_BVC("version="), offsetof(slap_bindconf, sb_version), 'i', 0, versionkey }, { BER_BVC("version="), offsetof(slap_bindconf, sb_version), 'i', 0, versionkey },
{ BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 'i', 0, methkey }, { BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 'i', 0, methkey },
{ BER_BVC("timeout="), offsetof(slap_bindconf, sb_timeout_api), 'i', 0, NULL },
{ BER_BVC("network-timeout="), offsetof(slap_bindconf, sb_timeout_net), 'i', 0, NULL },
{ BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 'b', 1, (slap_verbmasks *)dnNormalize }, { BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 'b', 1, (slap_verbmasks *)dnNormalize },
{ BER_BVC("credentials="), offsetof(slap_bindconf, sb_cred), 'b', 1, NULL }, { BER_BVC("credentials="), offsetof(slap_bindconf, sb_cred), 'b', 1, NULL },
{ BER_BVC("saslmech="), offsetof(slap_bindconf, sb_saslmech), 'b', 0, NULL }, { BER_BVC("saslmech="), offsetof(slap_bindconf, sb_saslmech), 'b', 0, NULL },
@ -1503,6 +1505,7 @@ slap_client_connect( LDAP **ldp, slap_bindconf *sb )
{ {
LDAP *ld = NULL; LDAP *ld = NULL;
int rc; int rc;
struct timeval tv;
/* Init connection to master */ /* Init connection to master */
rc = ldap_initialize( &ld, sb->sb_uri.bv_val ); rc = ldap_initialize( &ld, sb->sb_uri.bv_val );
@ -1519,6 +1522,18 @@ slap_client_connect( LDAP **ldp, slap_bindconf *sb )
(const void *)&sb->sb_version ); (const void *)&sb->sb_version );
} }
if ( sb->sb_timeout_api ) {
tv.tv_sec = sb->sb_timeout_api;
tv.tv_usec = 0;
ldap_set_option( ld, LDAP_OPT_TIMEOUT, &tv );
}
if ( sb->sb_timeout_net ) {
tv.tv_sec = sb->sb_timeout_net;
tv.tv_usec = 0;
ldap_set_option( ld, LDAP_OPT_NETWORK_TIMEOUT, &tv );
}
#ifdef HAVE_TLS #ifdef HAVE_TLS
if ( sb->sb_tls_do_init ) { if ( sb->sb_tls_do_init ) {
rc = bindconf_tls_set( sb, ld ); rc = bindconf_tls_set( sb, ld );

View File

@ -1538,6 +1538,8 @@ typedef struct slap_bindconf {
int sb_version; int sb_version;
int sb_tls; int sb_tls;
int sb_method; int sb_method;
int sb_timeout_api;
int sb_timeout_net;
struct berval sb_binddn; struct berval sb_binddn;
struct berval sb_cred; struct berval sb_cred;
struct berval sb_saslmech; struct berval sb_saslmech;