/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include <ac/string.h>
#include "back-bdb.h"
-#include "external.h"
int
bdb_referrals( Operation *op, SlapReply *rs )
/* get entry */
rc = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1, locker, &lock );
- e = ei->bei_e;
+ /* bdb_dn2entry() may legally leave ei == NULL
+ * if rc != 0 and rc != DB_NOTFOUND
+ */
+ if ( ei ) {
+ e = ei->bei_e;
+ }
+
switch(rc) {
case DB_NOTFOUND:
case 0:
case DB_LOCK_NOTGRANTED:
goto dn2entry_retry;
default:
-#ifdef NEW_LOGGING
- LDAP_LOG ( OPERATION, ERR,
- "bdb_referrals: dn2entry failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
-#else
Debug( LDAP_DEBUG_TRACE,
- "bdb_referrals: dn2entry failed: %s (%d)\n",
+ LDAP_XSTRING(bdb_referrals)
+ ": dn2entry failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
-#endif
send_ldap_error( op, rs, LDAP_OTHER, "internal error" );
LOCK_ID_FREE ( bdb->bi_dbenv, locker );
return rs->sr_err;
rc = 0;
rs->sr_matched = NULL;
if ( e != NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG ( OPERATION, DETAIL1,
- "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
- (long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val );
-#else
Debug( LDAP_DEBUG_TRACE,
- "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
+ LDAP_XSTRING(bdb_referrals)
+ ": op=%ld target=\"%s\" matched=\"%s\"\n",
(long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val );
-#endif
if( is_entry_referral( e ) ) {
rc = LDAP_OTHER;
if( rs->sr_ref != NULL ) {
/* send referrals */
- rs->sr_err = LDAP_REFERRAL;
+ rc = rs->sr_err = LDAP_REFERRAL;
send_ldap_result( op, rs );
ber_bvarray_free( rs->sr_ref );
rs->sr_ref = NULL;
rs->sr_ref = referral_rewrite(
refs, &e->e_name, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
-#ifdef NEW_LOGGING
- LDAP_LOG ( OPERATION, DETAIL1,
- "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
- (long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val );
-#else
Debug( LDAP_DEBUG_TRACE,
- "bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
+ LDAP_XSTRING(bdb_referrals)
+ ": op=%ld target=\"%s\" matched=\"%s\"\n",
(long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val );
-#endif
rs->sr_matched = e->e_name.bv_val;
if( rs->sr_ref != NULL ) {