struct berval mdn = { 0, NULL };
ber_int_t msgid;
dncookie dc;
+ struct metasingleconn *lsc = &lc->conns[ candidate ];
/*
* Rewrite the bind dn if needed
}
if ( op->o_ctrls ) {
- rs->sr_err = ldap_set_option( lc->conns[ candidate ].ld,
+ rs->sr_err = ldap_set_option( lsc->ld,
LDAP_OPT_SERVER_CONTROLS, op->o_ctrls );
if ( rs->sr_err != LDAP_SUCCESS ) {
rs->sr_err = ldap_back_map_result( rs );
}
}
- rs->sr_err = ldap_sasl_bind(lc->conns[ candidate ].ld, mdn.bv_val,
+ rs->sr_err = ldap_sasl_bind(lsc->ld, mdn.bv_val,
LDAP_SASL_SIMPLE, &op->oq_bind.rb_cred,
op->o_ctrls, NULL, &msgid);
if ( rs->sr_err != LDAP_SUCCESS ) {
/*
* FIXME: handle response!!!
*/
- ber_dupbv( &lc->conns[ candidate ].bound_dn, &op->o_req_dn );
- lc->conns[ candidate ].bound = META_BOUND;
+ if ( lsc->bound_dn.bv_val != NULL ) {
+ ber_memfree( lsc->bound_dn.bv_val );
+ }
+ ber_dupbv( &lsc->bound_dn, &op->o_req_dn );
+ lsc->bound = META_BOUND;
lc->bound_target = candidate;
if ( li->savecred ) {
- if ( lc->conns[ candidate ].cred.bv_val )
- ch_free( lc->conns[ candidate ].cred.bv_val );
- ber_dupbv( &lc->conns[ candidate ].cred,
- &op->oq_bind.rb_cred );
- ldap_set_rebind_proc( lc->conns[ candidate ].ld,
- meta_back_rebind,
- &lc->conns[ candidate ] );
+ if ( lsc->cred.bv_val ) {
+ memset( lsc->cred.bv_val, 0, lsc->cred.bv_len );
+ ber_memfree( lsc->cred.bv_val );
+ }
+ ber_dupbv( &lsc->cred, &op->oq_bind.rb_cred );
+ ldap_set_rebind_proc( lsc->ld, meta_back_rebind, lsc );
}
if ( li->cache.ttl != META_DNCACHE_DISABLED
* bind clears the previous bind).
*/
if ( lsc->bound_dn.bv_val ) {
- ch_free( lsc->bound_dn.bv_val );
+ ber_memfree( lsc->bound_dn.bv_val );
lsc->bound_dn.bv_val = NULL;
lsc->bound_dn.bv_len = 0;
}
+ if ( /* FIXME: need li ... li->savecred && */
+ lsc->cred.bv_val ) {
+ memset( lsc->cred.bv_val, 0, lsc->cred.bv_len );
+ ber_memfree( lsc->cred.bv_val );
+ lsc->cred.bv_val = NULL;
+ lsc->cred.bv_len = 0;
+ }
rc = ldap_bind_s( lsc->ld, 0, NULL, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) {
}
lc->conns[ ntargets ].candidate = META_LAST_CONN;
+ for ( ; ntargets-- > 0; ) {
+ lc->conns[ ntargets ].ld = NULL;
+ lc->conns[ ntargets ].bound_dn.bv_val = NULL;
+ lc->conns[ ntargets ].bound_dn.bv_len = 0;
+ lc->conns[ ntargets ].cred.bv_val = NULL;
+ lc->conns[ ntargets ].cred.bv_len = 0;
+ lc->conns[ ntargets ].bound = META_UNBOUND;
+ }
+
lc->bound_target = META_BOUND_NONE;
return lc;
/*
* Rewrite the bind dn if needed
*/
- if ( ldap_back_dn_massage( &dc, &op->o_conn->c_dn, &lsc->bound_dn) ) {
+ if ( ldap_back_dn_massage( &dc, &op->o_conn->c_dn,
+ &lsc->bound_dn) ) {
send_ldap_result( op, rs );
return rs->sr_err;
}