* any valid error send as error result
*/
static BackendDB *
-relay_back_select_backend( Operation *op, SlapReply *rs, int err )
+relay_back_select_backend( Operation *op, SlapReply *rs, int err, int dosend )
{
relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
BackendDB *bd = ri->ri_bd;
if ( bd == NULL && !BER_BVISNULL( &op->o_req_ndn ) ) {
bd = select_backend( &op->o_req_ndn, 0, 1 );
if ( bd == op->o_bd ) {
- if ( err > LDAP_SUCCESS ) {
+ if ( err > LDAP_SUCCESS && dosend ) {
send_ldap_error( op, rs,
LDAP_UNWILLING_TO_PERFORM,
"back-relay would call self" );
if ( bd == NULL && err > -1 ) {
if ( default_referral ) {
- rs->sr_ref = referral_rewrite( default_referral,
- NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
- if ( !rs->sr_ref ) {
- rs->sr_ref = default_referral;
- }
-
rs->sr_err = LDAP_REFERRAL;
- send_ldap_result( op, rs );
-
- if ( rs->sr_ref != default_referral ) {
- ber_bvarray_free( rs->sr_ref );
+ if ( dosend ) {
+ rs->sr_ref = referral_rewrite(
+ default_referral,
+ NULL, &op->o_req_dn,
+ LDAP_SCOPE_DEFAULT );
+ if ( !rs->sr_ref ) {
+ rs->sr_ref = default_referral;
+ }
+
+ send_ldap_result( op, rs );
+
+ if ( rs->sr_ref != default_referral ) {
+ ber_bvarray_free( rs->sr_ref );
+ }
}
} else {
* LDAP_NO_SUCH_OBJECT for other operations.
* noSuchObject cannot be returned by bind */
rs->sr_err = err;
- send_ldap_result( op, rs );
+ if ( dosend ) {
+ send_ldap_result( op, rs );
+ }
}
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, LDAP_INVALID_CREDENTIALS );
+ bd = relay_back_select_backend( op, rs, LDAP_INVALID_CREDENTIALS, 1 );
if ( bd == NULL ) {
return rc;
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, LDAP_SUCCESS );
+ bd = relay_back_select_backend( op, rs, LDAP_SUCCESS, 0 );
if ( bd == NULL ) {
return 1;
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
+ bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT, 1 );
if ( bd == NULL ) {
return 1;
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
+ bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT, 1 );
if ( bd == NULL ) {
return 1;
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
+ bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT, 1 );
if ( bd == NULL ) {
return 1;
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
+ bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT, 1 );
if ( bd == NULL ) {
return 1;
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
+ bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT, 1 );
if ( bd == NULL ) {
return 1;
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
+ bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT, 1 );
if ( bd == NULL ) {
return 1;
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, -1 );
+ bd = relay_back_select_backend( op, rs, LDAP_SUCCESS, 0 );
if ( bd == NULL ) {
return 1;
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
+ bd = relay_back_select_backend( op, rs, LDAP_CANNOT_CANCEL, 0 );
if ( bd == NULL ) {
return 1;
}
BackendDB *bd;
int rc = 1;
- bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
+ bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT, 0 );
if ( bd == NULL ) {
return 1;
}
BackendDB *bd;
int rc = 0;
- bd = relay_back_select_backend( op, rs, LDAP_SUCCESS );
+ bd = relay_back_select_backend( op, rs, LDAP_SUCCESS, 1 );
/* FIXME: this test only works if there are no overlays, so
* it is nearly useless; if made stricter, no nested back-relays
* can be instantiated... too bad. */