+ } else {
+ scopeok = 1;
+ }
+
+ if( scopeok ) {
+ BerVarray erefs = get_entry_referrals(
+ be, conn, op, e );
+ BerVarray refs = referral_rewrite( erefs,
+ &e->e_name, NULL,
+ scope == LDAP_SCOPE_SUBTREE
+ ? LDAP_SCOPE_SUBTREE
+ : LDAP_SCOPE_BASE );
+
+ send_search_reference( be, conn, op,
+ e, refs, NULL, &v2refs );
+
+ ber_bvarray_free( refs );
+
+ } else {
+#ifdef NEW_LOGGING
+ LDAP_LOG(OPERATION, DETAIL2,
+ "bdb_search: candidate referral %ld scope not okay\n",
+ id, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_TRACE,
+ "bdb_search: candidate referral %ld scope not okay\n",
+ id, 0, 0 );
+#endif
+ }