X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fsearch.c;h=f53584a9e88003fc62232b36f96f3b7a40b2fc80;hb=e48f72c1b5a7ce571c7ced749aed473d20b32526;hp=8604281df6c2a83a080d2775b8d064f07aaaf9ae;hpb=acbb5cf689a4336af05c9f259d909d8141055bac;p=openldap diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 8604281df6..f53584a9e8 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2006 The OpenLDAP Foundation. + * Copyright 1998-2007 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -241,6 +241,7 @@ fe_op_search( Operation *op, SlapReply *rs ) { int manageDSAit; int be_manageDSAit; + BackendDB *bd = op->o_bd; manageDSAit = get_manageDSAit( op ); @@ -328,9 +329,8 @@ fe_op_search( Operation *op, SlapReply *rs ) if (!rs->sr_ref) rs->sr_ref = default_referral; rs->sr_err = LDAP_REFERRAL; - op->o_bd = frontendDB; + op->o_bd = bd; send_ldap_result( op, rs ); - op->o_bd = NULL; if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); @@ -349,9 +349,28 @@ 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 */ @@ -362,6 +381,7 @@ fe_op_search( Operation *op, SlapReply *rs ) } return_results:; + op->o_bd = bd; return rs->sr_err; }