1 /* referral.c - LDBM backend referral handler */
4 * Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
13 #include <ac/socket.h>
16 #include "back-ldbm.h"
27 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
28 int rc = LDAP_SUCCESS;
31 if( op->o_tag == LDAP_REQ_SEARCH ) {
32 /* let search take care of itself */
36 if( get_manageDSAit( op ) ) {
37 /* let op take care of DSA management */
41 /* get entry with reader lock */
42 e = dn2entry_r( be, ndn, &matched );
44 char *matched_dn = NULL;
45 struct berval **refs = default_referral;
47 if ( matched != NULL ) {
48 matched_dn = ch_strdup( matched->e_dn );
50 Debug( LDAP_DEBUG_TRACE,
51 "ldbm_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
52 op->o_tag, dn, matched_dn );
54 refs = is_entry_referral( matched )
55 ? get_entry_referrals( be, conn, op, matched )
58 cache_return_entry_r( &li->li_cache, matched );
63 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
64 matched_dn, NULL, refs, NULL );
67 if( matched != NULL ) {
75 if ( is_entry_referral( e ) ) {
76 /* entry is a referral */
77 struct berval **refs = get_entry_referrals( be,
80 Debug( LDAP_DEBUG_TRACE,
81 "ldbm_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
82 op->o_tag, dn, e->e_dn );
85 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
86 e->e_dn, NULL, refs, NULL );
92 cache_return_entry_r( &li->li_cache, e );