X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fsearch.c;h=b6eb2832f4c952b9401a359d40a242cc609656d1;hb=c92571680d87dc87cfe533bc3378d00ae3683141;hp=9478b19c3eea53e2c76b32ac9734f196cf57d929;hpb=31578ca4310437364895dd040203191bda02cf79;p=openldap diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 9478b19c3e..b6eb2832f4 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -340,7 +340,6 @@ fe_op_search( Operation *op, SlapReply *rs ) /* check restrictions */ if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) { - op->o_bd = bd; send_ldap_result( op, rs ); goto return_results; } @@ -350,15 +349,33 @@ fe_op_search( Operation *op, SlapReply *rs ) goto return_results; } - /* actually do the search and send the result(s) */ - if ( op->o_bd->be_search ) { + if ( SLAP_SHADOW(op->o_bd) && get_dontUseCopy(op) ) { + /* don't use shadow copy */ + 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, op->ors_scope ); + if( !rs->sr_ref) rs->sr_ref = defref; + rs->sr_err = LDAP_REFERRAL; + send_ldap_result( op, rs ); + + if (rs->sr_ref != defref) ber_bvarray_free( rs->sr_ref ); + + } else { + send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, + "copy not used; no referral information available" ); + } + + } else if ( op->o_bd->be_search ) { if ( limits_check( op, rs ) == 0 ) { + /* actually do the search and send the result(s) */ (op->o_bd->be_search)( op, rs ); } /* else limits_check() sends error */ } else { - op->o_bd = bd; send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "operation not supported within namingContext" ); }