}
if ( op->o_ctrls ) {
- ldap_set_option( lc->ld, LDAP_OPT_SERVER_CONTROLS, op->o_ctrls );
+ if ( ldap_set_option( lc->ld, LDAP_OPT_SERVER_CONTROLS,
+ op->o_ctrls ) != LDAP_SUCCESS ) {
+ ldap_back_op_result( lc, op );
+ return( -1 );
+ }
}
/*
*/
int
ldap_back_dobind( struct ldapconn *lc, Operation *op )
-{
+{
+ if ( op->o_ctrls ) {
+ if ( ldap_set_option( lc->ld, LDAP_OPT_SERVER_CONTROLS,
+ op->o_ctrls ) != LDAP_SUCCESS ) {
+ ldap_back_op_result( lc, op );
+ return( 0 );
+ }
+ }
+
if ( lc->bound ) {
return( lc->bound );
}
- if ( op->o_ctrls ) {
- ldap_set_option( lc->ld, LDAP_OPT_SERVER_CONTROLS,
- op->o_ctrls );
- }
-
if ( ldap_bind_s( lc->ld, lc->bound_dn.bv_val, lc->cred.bv_val,
LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
ldap_back_op_result( lc, op );
}
if ( op->o_ctrls ) {
- ldap_set_option( lc->conns[ candidate ].ld,
+ rc = ldap_set_option( lc->conns[ candidate ].ld,
LDAP_OPT_SERVER_CONTROLS, op->o_ctrls );
+ if ( rc != LDAP_SUCCESS ) {
+ rc = ldap_back_map_result( rc );
+ goto return_results;
+ }
}
rc = ldap_bind_s( lc->conns[ candidate ].ld, mdn.bv_val, cred->bv_val, method );
ndn, candidate );
}
}
+
+return_results:;
if ( mdn.bv_val != dn->bv_val ) {
free( mdn.bv_val );
continue;
}
+ /*
+ * If required, set controls
+ */
+ if ( op->o_ctrls ) {
+ if ( ldap_set_option( lsc->ld, LDAP_OPT_SERVER_CONTROLS,
+ op->o_ctrls ) != LDAP_SUCCESS ) {
+ ( void )meta_clear_one_candidate( lsc, 1 );
+ continue;
+ }
+ }
+
/*
* If the target is already bound it is skipped
*/
lsc->bound_dn.bv_len = 0;
}
- if ( op->o_ctrls ) {
- ldap_set_option( lsc->ld, LDAP_OPT_SERVER_CONTROLS,
- op->o_ctrls );
- }
-
+
rc = ldap_bind_s( lsc->ld, 0, NULL, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) {