From: Pierangelo Masarati Date: Thu, 17 Apr 2003 22:19:14 +0000 (+0000) Subject: improve previous commit X-Git-Tag: OPENLDAP_REL_ENG_2_2_0ALPHA~327 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b5e9378d4f2532e9bfe14b7b4aa3e2a1445619da;p=openldap improve previous commit --- diff --git a/servers/slapd/add.c b/servers/slapd/add.c index b0bd5091c7..a5ade437e2 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -200,12 +200,16 @@ do_add( Operation *op, SlapReply *rs ) if ( op->o_bd == NULL ) { rs->sr_ref = referral_rewrite( default_referral, NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); - - rs->sr_err = LDAP_REFERRAL; if (!rs->sr_ref) rs->sr_ref = default_referral; - send_ldap_result( op, rs ); + if ( rs->sr_ref != NULL ) { + rs->sr_err = LDAP_REFERRAL; + send_ldap_result( op, rs ); - if ( rs->sr_ref != default_referral ) ber_bvarray_free( rs->sr_ref ); + if ( rs->sr_ref != default_referral ) ber_bvarray_free( rs->sr_ref ); + } else { + send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, + "referral missing" ); + } goto done; } @@ -316,7 +320,7 @@ do_add( Operation *op, SlapReply *rs ) if ( defref != NULL ) { rs->sr_ref = referral_rewrite( defref, NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); - + if ( rs->sr_ref == NULL ) rs->sr_ref = defref; rs->sr_err = LDAP_REFERRAL; if (!rs->sr_ref) rs->sr_ref = default_referral; send_ldap_result( op, rs ); diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index facf238f44..4ef2a53b80 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -131,11 +131,16 @@ do_delete( NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); if (!rs->sr_ref) rs->sr_ref = default_referral; - rs->sr_err = LDAP_REFERRAL; + if ( rs->sr_ref != NULL ) { + rs->sr_err = LDAP_REFERRAL; - send_ldap_result( op, rs ); + send_ldap_result( op, rs ); - if (rs->sr_ref!= default_referral) ber_bvarray_free( rs->sr_ref ); + if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); + } else { + send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, + "referral missing" ); + } goto cleanup; } @@ -202,7 +207,6 @@ do_delete( if ( defref != NULL ) { rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); - if (!rs->sr_ref) rs->sr_ref = defref; rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 1aea31a260..a04d49a61c 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -301,10 +301,15 @@ do_modify( 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 != NULL ) { + rs->sr_err = LDAP_REFERRAL; + send_ldap_result( op, rs ); - if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); + if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); + } else { + send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, + "referral missing" ); + } goto cleanup; } @@ -432,15 +437,11 @@ do_modify( } else { BerVarray defref = op->o_bd->be_update_refs ? op->o_bd->be_update_refs : default_referral; - if ( defref != NULL ) { rs->sr_ref = referral_rewrite( defref, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); - - if (!rs->sr_ref) { - rs->sr_ref = defref; - } + if (!rs->sr_ref) rs->sr_ref = defref; rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); if (rs->sr_ref != defref) { diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index cf4f9e2d31..0644a8995a 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -276,10 +276,15 @@ do_modrdn( 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 != NULL ) { + rs->sr_err = LDAP_REFERRAL; + send_ldap_result( op, rs ); - if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); + if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); + } else { + send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, + "referral missing" ); + } goto cleanup; }