#define        META_BACK_TGT_ISSET(mt,f)               ( ( (mt)->mt_flags & (f) ) == (f) )
 #define        META_BACK_TGT_ISMASK(mt,m,f)            ( ( (mt)->mt_flags & (m) ) == (f) )
 
+#define META_BACK_TGT_SAVECRED(mt)             META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_SAVECRED )
+
+#define META_BACK_TGT_USE_TLS(mt)              META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_USE_TLS )
+#define META_BACK_TGT_PROPAGATE_TLS(mt)                META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_PROPAGATE_TLS )
+#define META_BACK_TGT_TLS_CRITICAL(mt)         META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_TLS_CRITICAL )
+
+#define META_BACK_TGT_CHASE_REFERRALS(mt)      META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_CHASE_REFERRALS )
+
 #define        META_BACK_TGT_T_F(mt)                   META_BACK_TGT_ISMASK( (mt), LDAP_BACK_F_T_F_MASK, LDAP_BACK_F_T_F )
 #define        META_BACK_TGT_T_F_DISCOVER(mt)          META_BACK_TGT_ISMASK( (mt), LDAP_BACK_F_T_F_MASK2, LDAP_BACK_F_T_F_DISCOVER )
 
 
        LDAP_BACK_CONN_ISBOUND_SET( msc );
        mc->mc_authz_target = candidate;
 
-       if ( LDAP_BACK_SAVECRED( mi ) ) {
+       if ( META_BACK_TGT_SAVECRED( mt ) ) {
                if ( !BER_BVISNULL( &msc->msc_cred ) ) {
                        memset( msc->msc_cred.bv_val, 0,
                                msc->msc_cred.bv_len );
                                LDAP_BACK_CONN_ISBOUND_SET( msc );
                                ber_bvreplace( &msc->msc_bound_ndn, &binddn );
 
-                               if ( LDAP_BACK_SAVECRED( mi ) ) {
+                               if ( META_BACK_TGT_SAVECRED( mt ) ) {
                                        if ( !BER_BVISNULL( &msc->msc_cred ) ) {
                                                memset( msc->msc_cred.bv_val, 0,
                                                        msc->msc_cred.bv_len );
 
                
        /* save bind creds for referral rebinds? */
        } else if ( strcasecmp( argv[ 0 ], "rebind-as-user" ) == 0 ) {
+               unsigned        *flagsp = mi->mi_ntargets ?
+                               &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_flags
+                               : &mi->mi_flags;
+
                if ( argc > 2 ) {
                        Debug( LDAP_DEBUG_ANY,
        "%s: line %d: \"rebind-as-user {NO|yes}\" takes 1 argument.\n",
                        Debug( LDAP_DEBUG_ANY,
        "%s: line %d: deprecated use of \"rebind-as-user {FALSE|true}\" with no arguments.\n",
                            fname, lineno, 0 );
-                       mi->mi_flags |= LDAP_BACK_F_SAVECRED;
+                       *flagsp |= LDAP_BACK_F_SAVECRED;
 
                } else {
                        switch ( check_true_false( argv[ 1 ] ) ) {
                        case 0:
-                               mi->mi_flags &= ~LDAP_BACK_F_SAVECRED;
+                               *flagsp &= ~LDAP_BACK_F_SAVECRED;
                                break;
 
                        case 1:
-                               mi->mi_flags |= LDAP_BACK_F_SAVECRED;
+                               *flagsp |= LDAP_BACK_F_SAVECRED;
                                break;
 
                        default:
 
 
        /* automatically chase referrals ("chase-referrals [{yes|no}]" statement) */
        ldap_set_option( msc->msc_ld, LDAP_OPT_REFERRALS,
-               LDAP_BACK_CHASE_REFERRALS( mi ) ? LDAP_OPT_ON : LDAP_OPT_OFF );
+               META_BACK_TGT_CHASE_REFERRALS( mt ) ? LDAP_OPT_ON : LDAP_OPT_OFF );
 
 #ifdef HAVE_TLS
        /* start TLS ("tls [try-]{start|propagate}" statement) */
-       if ( ( LDAP_BACK_USE_TLS( mi )
+       if ( ( META_BACK_TGT_USE_TLS( mt )
                || ( op->o_conn->c_is_tls
-                       && LDAP_BACK_PROPAGATE_TLS( mi ) ) )
+                       && META_BACK_TGT_PROPAGATE_TLS( mt ) ) )
                && !is_ldaps )
        {
 #ifdef SLAP_STARTTLS_ASYNCHRONOUS
                 * overlay, where the "uri" can be parsed out of a referral */
                if ( rs->sr_err == LDAP_SERVER_DOWN
                        || ( rs->sr_err != LDAP_SUCCESS
-                               && LDAP_BACK_TLS_CRITICAL( mi ) ) )
+                               && META_BACK_TGT_TLS_CRITICAL( mt ) ) )
                {
 
 #ifdef DEBUG_205
 
                 * because the connection is not shared until bind is over */
                if ( !BER_BVISNULL( &binddn ) ) {
                        ber_bvreplace( &msc->msc_bound_ndn, &binddn );
-                       if ( LDAP_BACK_SAVECRED( mi ) && !BER_BVISNULL( &cred ) ) {
+                       if ( META_BACK_TGT_SAVECRED( mt ) && !BER_BVISNULL( &cred ) ) {
                                if ( !BER_BVISNULL( &msc->msc_cred ) ) {
                                        memset( msc->msc_cred.bv_val, 0,
                                                msc->msc_cred.bv_len );