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 );
51 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
52 "ldbm_back_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
53 op->o_tag, dn, matched_dn ));
55 Debug( LDAP_DEBUG_TRACE,
56 "ldbm_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
57 op->o_tag, dn, matched_dn );
61 refs = is_entry_referral( matched )
62 ? get_entry_referrals( be, conn, op, matched )
65 cache_return_entry_r( &li->li_cache, matched );
70 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
71 matched_dn, NULL, refs, NULL );
74 if( matched != NULL ) {
82 if ( is_entry_referral( e ) ) {
83 /* entry is a referral */
84 struct berval **refs = get_entry_referrals( be,
88 LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
89 "ldbm_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
90 op->o_tag, dn, e->e_dn ));
92 Debug( LDAP_DEBUG_TRACE,
93 "ldbm_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
94 op->o_tag, dn, e->e_dn );
99 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
100 e->e_dn, NULL, refs, NULL );
103 ber_bvecfree( refs );
106 cache_return_entry_r( &li->li_cache, e );