- /* 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 );
- if( op->ors_filter != NULL) filter_free_x( op, op->ors_filter );
- 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 */
-
- return rs->sr_err;
-}
-
-#ifdef LDAP_SLAPI
-
-static char **anlist2charray( Operation *op, AttributeName *an )
-{
- char **attrs;
- int i;
-
- if ( an != NULL ) {
- for ( i = 0; an[i].an_name.bv_val != NULL; i++ )
- ;
- attrs = (char **)op->o_tmpalloc( (i + 1) * sizeof(char *), op->o_tmpmemctx );
- for ( i = 0; an[i].an_name.bv_val != NULL; i++ ) {
- attrs[i] = an[i].an_name.bv_val;
- }
- attrs[i] = NULL;
- } else {
- attrs = NULL;
- }
-
- return attrs;
-}
+ 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 );