-#ifdef LDAP_SLAPI
- attrs = anlist2charray( op, op->ors_attrs );
- initSearchPlugin( op, attrs, manageDSAit );
- rs->sr_err = doPreSearchPluginFNs( op );
- if ( rs->sr_err != LDAP_SUCCESS ) {
- goto return_results;
- }
-
- doSearchRewriteFNs( op );
-#endif /* LDAP_SLAPI */
-
- /* actually do the search and send the result(s) */
- if ( op->o_bd->be_search ) {
- (op->o_bd->be_search)( op, rs );
- } else {
- send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
- "operation not supported within namingContext" );
- }
-
-#ifdef LDAP_SLAPI
- doPostSearchPluginFNs( op );
-#endif /* LDAP_SLAPI */
-
-return_results:;
-
-#ifdef LDAP_CLIENT_UPDATE
- if ( ( op->o_clientupdate_type & SLAP_LCUP_PERSIST ) )
- return rs->sr_err;
-#endif
-#if defined(LDAP_CLIENT_UPDATE) && defined(LDAP_SYNC)
- else
-#endif
-#ifdef LDAP_SYNC
- if ( ( op->o_sync_mode & SLAP_SYNC_PERSIST ) )
- return rs->sr_err;
-#endif
-
- if( op->o_req_dn.bv_val != NULL) sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx );
- if( op->o_req_ndn.bv_val != NULL) sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
-
- if( op->ors_filterstr.bv_val != NULL) op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
-#ifdef LDAP_SLAPI
- if( op->ors_filter != NULL) filter_free( op->ors_filter );
-#else
- if( op->ors_filter != NULL) filter_free_x( op, op->ors_filter );
-#endif
- if( op->ors_attrs != NULL ) op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
-#ifdef LDAP_SLAPI
- if( attrs != NULL) op->o_tmpfree( attrs, op->o_tmpmemctx );
-#endif /* LDAP_SLAPI */
+ 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;