2004-03-17 09:03:21 +08:00
|
|
|
/* op.c - relay backend operations */
|
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
|
|
|
* Copyright 2003-2004 The OpenLDAP Foundation.
|
|
|
|
* Portions Copyright 2004 Pierangelo Masarati.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
|
|
|
*/
|
|
|
|
/* ACKNOWLEDGEMENTS:
|
|
|
|
* This work was initially developed by Pierangelo Masarati for inclusion
|
|
|
|
* in OpenLDAP Software.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <ac/string.h>
|
|
|
|
#include <ac/socket.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "back-relay.h"
|
|
|
|
|
2004-03-17 18:05:38 +08:00
|
|
|
static int
|
|
|
|
relay_back_swap_bd( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
|
|
|
slap_callback *cb = op->o_callback;
|
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
|
|
|
op->o_bd = cb->sc_private;
|
|
|
|
cb->sc_private = be;
|
|
|
|
|
|
|
|
return SLAP_CB_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
static BackendDB *
|
|
|
|
relay_back_select_backend( struct slap_op *op, struct slap_rep *rs, int err )
|
|
|
|
{
|
|
|
|
relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
|
|
|
|
BackendDB *bd = ri->ri_bd;
|
|
|
|
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
bd = select_backend( &op->o_req_ndn, 0, 1 );
|
2004-03-17 17:25:59 +08:00
|
|
|
if ( bd == op->o_bd ) {
|
|
|
|
if ( err != LDAP_SUCCESS ) {
|
|
|
|
send_ldap_error( op, rs,
|
|
|
|
LDAP_UNWILLING_TO_PERFORM,
|
|
|
|
"would call self" );
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-03-17 15:56:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
if ( default_referral ) {
|
|
|
|
rs->sr_ref = referral_rewrite( default_referral,
|
|
|
|
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
|
2004-03-17 17:25:59 +08:00
|
|
|
if ( !rs->sr_ref ) {
|
2004-03-17 15:56:19 +08:00
|
|
|
rs->sr_ref = default_referral;
|
|
|
|
}
|
|
|
|
|
|
|
|
rs->sr_err = LDAP_REFERRAL;
|
|
|
|
send_ldap_result( op, rs );
|
|
|
|
|
2004-03-17 17:25:59 +08:00
|
|
|
if ( rs->sr_ref != default_referral ) {
|
2004-03-17 15:56:19 +08:00
|
|
|
ber_bvarray_free( rs->sr_ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* NOTE: err is LDAP_INVALID_CREDENTIALS for bind,
|
|
|
|
* LDAP_NO_SUCH_OBJECT for other operations.
|
|
|
|
* noSuchObject is not allowed to be returned by bind */
|
|
|
|
rs->sr_err = err;
|
|
|
|
send_ldap_result( op, rs );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bd;
|
|
|
|
}
|
|
|
|
|
2004-03-17 09:03:21 +08:00
|
|
|
int
|
|
|
|
relay_back_op_bind( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_INVALID_CREDENTIALS );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_bind ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_bind )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
2004-03-17 15:56:19 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
|
|
|
|
"operation not supported "
|
|
|
|
"within naming context" );
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_op_unbind( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 18:05:38 +08:00
|
|
|
relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 18:05:38 +08:00
|
|
|
bd = ri->ri_bd;
|
2004-03-17 15:56:19 +08:00
|
|
|
if ( bd == NULL ) {
|
2004-03-17 18:05:38 +08:00
|
|
|
bd = select_backend( &op->o_req_ndn, 0, 1 );
|
2004-03-17 15:56:19 +08:00
|
|
|
}
|
|
|
|
|
2004-03-17 18:05:38 +08:00
|
|
|
if ( bd && bd->be_unbind ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_unbind )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
|
|
|
}
|
|
|
|
|
2004-03-17 18:05:38 +08:00
|
|
|
return 0;
|
2004-03-17 09:03:21 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_op_search( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_search ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
2004-03-17 18:05:38 +08:00
|
|
|
slap_callback cb;
|
|
|
|
|
|
|
|
cb.sc_next = op->o_callback;
|
|
|
|
cb.sc_response = relay_back_swap_bd;
|
|
|
|
cb.sc_cleanup = relay_back_swap_bd;
|
|
|
|
cb.sc_private = op->o_bd;
|
|
|
|
op->o_callback = &cb;
|
2004-03-17 09:03:21 +08:00
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_search )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
2004-03-17 15:56:19 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
|
|
|
|
"operation not supported "
|
|
|
|
"within naming context" );
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_op_compare( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_compare ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_compare )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
2004-03-17 15:56:19 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
|
|
|
|
"operation not supported "
|
|
|
|
"within naming context" );
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_op_modify( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_modify ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_modify )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
2004-03-17 15:56:19 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
|
|
|
|
"operation not supported "
|
|
|
|
"within naming context" );
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_op_modrdn( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_modrdn ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_modrdn )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
2004-03-17 15:56:19 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
|
|
|
|
"operation not supported "
|
|
|
|
"within naming context" );
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_op_add( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_add ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_add )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
2004-03-17 15:56:19 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
|
|
|
|
"operation not supported "
|
|
|
|
"within naming context" );
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_op_delete( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_delete ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_delete )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_op_abandon( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_abandon ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_abandon )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
2004-03-17 15:56:19 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
|
|
|
|
"operation not supported "
|
|
|
|
"within naming context" );
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_op_cancel( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_cancel ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_cancel )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
2004-03-17 15:56:19 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
|
|
|
|
"operation not supported "
|
|
|
|
"within naming context" );
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_op_extended( struct slap_op *op, struct slap_rep *rs )
|
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_NO_SUCH_OBJECT );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_extended ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_extended )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
2004-03-17 15:56:19 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
|
|
|
|
"operation not supported "
|
|
|
|
"within naming context" );
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_entry_release_rw( struct slap_op *op, Entry *e, int rw )
|
|
|
|
{
|
|
|
|
relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = ri->ri_bd;
|
|
|
|
if ( bd == NULL) {
|
|
|
|
bd = select_backend( &op->o_req_ndn, 0, 1 );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_release ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_release )( op, e, rw );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_entry_get_rw( struct slap_op *op, struct berval *ndn,
|
|
|
|
ObjectClass *oc, AttributeDescription *at, int rw, Entry **e )
|
|
|
|
{
|
|
|
|
relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = ri->ri_bd;
|
|
|
|
if ( bd == NULL) {
|
|
|
|
bd = select_backend( &op->o_req_ndn, 0, 1 );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_fetch ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_fetch )( op, ndn, oc, at, rw, e );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
int
|
|
|
|
relay_back_chk_referrals( struct slap_op *op, struct slap_rep *rs )
|
2004-03-17 09:03:21 +08:00
|
|
|
{
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 17:25:59 +08:00
|
|
|
int rc = 0;
|
2004-03-17 09:03:21 +08:00
|
|
|
|
2004-03-17 17:25:59 +08:00
|
|
|
bd = relay_back_select_backend( op, rs, LDAP_SUCCESS );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 0;
|
2004-03-17 15:56:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_chk_referrals ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_chk_referrals )( op, rs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
int
|
|
|
|
relay_back_operational( struct slap_op *op, struct slap_rep *rs,
|
|
|
|
int opattrs, Attribute **ap )
|
2004-03-17 09:03:21 +08:00
|
|
|
{
|
|
|
|
relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = ri->ri_bd;
|
|
|
|
if ( bd == NULL) {
|
|
|
|
bd = select_backend( &op->o_req_ndn, 0, 1 );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_operational ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_operational )( op, rs, opattrs, ap );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
int
|
|
|
|
relay_back_has_subordinates( struct slap_op *op, Entry *e, int *hasSubs )
|
2004-03-17 09:03:21 +08:00
|
|
|
{
|
|
|
|
relay_back_info *ri = (relay_back_info *)op->o_bd->be_private;
|
2004-03-17 15:56:19 +08:00
|
|
|
BackendDB *bd;
|
2004-03-17 09:03:21 +08:00
|
|
|
int rc = 1;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
bd = ri->ri_bd;
|
|
|
|
if ( bd == NULL) {
|
|
|
|
bd = select_backend( &op->o_req_ndn, 0, 1 );
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_has_subordinates ) {
|
2004-03-17 09:03:21 +08:00
|
|
|
BackendDB *be = op->o_bd;
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
op->o_bd = bd;
|
|
|
|
rc = ( bd->be_has_subordinates )( op, e, hasSubs );
|
2004-03-17 09:03:21 +08:00
|
|
|
op->o_bd = be;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_connection_init( BackendDB *bd, struct slap_conn *c )
|
|
|
|
{
|
|
|
|
relay_back_info *ri = (relay_back_info *)bd->be_private;
|
|
|
|
|
2004-03-17 17:25:59 +08:00
|
|
|
bd = ri->ri_bd;
|
|
|
|
if ( bd == NULL ) {
|
|
|
|
return 0;
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
2004-03-17 17:25:59 +08:00
|
|
|
if ( bd->be_connection_init ) {
|
|
|
|
return ( bd->be_connection_init )( bd, c );
|
|
|
|
}
|
2004-03-17 09:03:21 +08:00
|
|
|
|
2004-03-17 17:25:59 +08:00
|
|
|
return 0;
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
relay_back_connection_destroy( BackendDB *bd, struct slap_conn *c )
|
|
|
|
{
|
|
|
|
relay_back_info *ri = (relay_back_info *)bd->be_private;
|
|
|
|
|
2004-03-17 17:25:59 +08:00
|
|
|
bd = ri->ri_bd;
|
|
|
|
if ( bd == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bd->be_connection_destroy ) {
|
|
|
|
return ( bd->be_connection_destroy )( bd, c );
|
2004-03-17 09:03:21 +08:00
|
|
|
}
|
|
|
|
|
2004-03-17 17:25:59 +08:00
|
|
|
return 0;
|
2004-03-17 09:03:21 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-17 15:56:19 +08:00
|
|
|
/*
|
|
|
|
* FIXME: must implement tools as well
|
|
|
|
*/
|