+ } else {
+ rc = slap_map_api2result( rs );
+ }
+
+ rs->sr_err = rc;
+ if ( rc != LDAP_SUCCESS && ( sendok & LDAP_BACK_SENDERR ) ) {
+ send_ldap_result( op, rs );
+ }
+
+ return rc;
+}
+
+/*
+ * meta_back_dobind
+ */
+int
+meta_back_dobind(
+ Operation *op,
+ SlapReply *rs,
+ metaconn_t *mc,
+ ldap_back_send_t sendok )
+{
+ metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
+
+ int bound = 0, i;
+
+ SlapReply *candidates = meta_back_candidates_get( op );
+
+ ldap_pvt_thread_mutex_lock( &mc->mc_mutex );
+
+ Debug( LDAP_DEBUG_TRACE,
+ "%s meta_back_dobind: conn=%ld\n",
+ op->o_log_prefix, mc->mc_conn->c_connid, 0 );
+
+ /*
+ * all the targets are bound as pseudoroot
+ */
+ if ( mc->mc_auth_target == META_BOUND_ALL ) {
+ bound = 1;
+ goto done;
+ }
+
+ for ( i = 0; i < mi->mi_ntargets; i++ ) {
+ metatarget_t *mt = &mi->mi_targets[ i ];
+ metasingleconn_t *msc = &mc->mc_conns[ i ];
+ int rc;
+
+ /*
+ * Not a candidate
+ */
+ if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
+ continue;
+ }
+
+ assert( msc->msc_ld != NULL );
+
+ /*
+ * If the target is already bound it is skipped
+ */
+ if ( msc->msc_bound == META_BOUND && mc->mc_auth_target == i ) {
+ ++bound;
+
+ Debug( LDAP_DEBUG_TRACE, "%s meta_back_dobind[%d]: "
+ "authcTarget\n",
+ op->o_log_prefix, i, 0 );
+ continue;
+ }
+
+ rc = meta_back_single_dobind( op, rs, mc, i,
+ LDAP_BACK_DONTSEND, mt->mt_nretries );