ITS#7532 - Add new function ldap_connect().

This function is used to manually establish a connection after
a call to ldap_initialize(). This is primarily so that a file
descriptor can be obtained before any requests are sent for the
purposes of polling for writability.
This commit is contained in:
Nathaniel McCallum 2013-02-27 13:44:57 -05:00 committed by Quanah Gibson-Mount
parent 9bef357403
commit 29f6260364
3 changed files with 37 additions and 0 deletions

View file

@ -30,6 +30,11 @@ LDAP **ldp;
char *uri;
.LP
.ft B
int ldap_connect(ldp)
.ft
LDAP *ldp;
.LP
.ft B
int ldap_set_urllist_proc(ld, proc, params)
.ft
LDAP *ld;
@ -141,6 +146,12 @@ are deprecated in favor of
essentially because the latter allows to specify a schema in the URI
and it explicitly returns an error code.
.LP
.B ldap_connect()
causes a handle created by
.B ldap_initialize()
to connect to the server. This is useful in situations where a file
descriptor is required before a request is performed.
.LP
.B ldap_init_fd()
allows an LDAP structure to be initialized using an already-opened
connection. The

View file

@ -1548,6 +1548,9 @@ LDAP_F( LDAP * )
ldap_dup LDAP_P((
LDAP *old ));
LDAP_F( int )
ldap_connect( LDAP *ld );
/*
* in tls.c
*/

View file

@ -50,6 +50,29 @@ int ldap_open_defconn( LDAP *ld )
return 0;
}
/*
* ldap_connect - Connect to an ldap server.
*
* Example:
* LDAP *ld;
* ldap_initialize( &ld, url );
* ldap_connect( ld );
*/
int
ldap_connect( LDAP *ld )
{
ber_socket_t sd = AC_SOCKET_INVALID;
int rc = LDAP_SUCCESS;
LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
if ( ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, &sd ) == -1 ) {
rc = ldap_open_defconn( ld );
}
LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
return rc;
}
/*
* ldap_open - initialize and connect to an ldap server. A magic cookie to
* be used for future communication is returned on success, NULL on failure.