/*
- * Copyright 1998-2001 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*
* Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
}
}
- lc->bound_target = -1;
+ lc->bound_target = META_BOUND_NONE;
return lc;
}
* Attempts to initialize the connection to the target ds
*/
err = ldap_initialize( &lsc->ld, lt->uri );
-
- /*
- * In case of failure, the error is mapped back from client
- * to server error code
- */
if ( err != LDAP_SUCCESS ) {
return ldap_back_map_result( err );
}
/*
* If the connection dn is not null, an attempt to rewrite it is made
*/
- if ( conn->c_cdn != NULL && conn->c_cdn[ 0 ] != '\0' ) {
+ if ( conn->c_dn.bv_len != 0 ) {
+
/*
* Rewrite the bind dn if needed
*/
- lsc->bound_dn = NULL;
+ lsc->bound_dn.bv_val = NULL;
switch ( rewrite_session( lt->rwinfo, "bindDn",
- conn->c_cdn, conn,
- &lsc->bound_dn ) ) {
+ conn->c_dn.bv_val, conn,
+ &lsc->bound_dn.bv_val ) ) {
case REWRITE_REGEXEC_OK:
- if ( lsc->bound_dn == NULL ) {
- lsc->bound_dn = ch_strdup( conn->c_cdn );
+ if ( lsc->bound_dn.bv_val == NULL ) {
+ ber_dupbv( &lsc->bound_dn, &conn->c_dn );
}
#ifdef NEW_LOGGING
- LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
- "[rw] bindDn: \"%s\" -> \"%s\"\n",
- conn->c_cdn, lsc->bound_dn ));
+ LDAP_LOG( BACK_META, DETAIL1,
+ "[rw] bindDn: \"%s\" -> \"%s\"\n",
+ conn->c_dn.bv_val, lsc->bound_dn.bv_val, 0 );
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
- "rw> bindDn: \"%s\" -> \"%s\"\n%s",
- conn->c_cdn, lsc->bound_dn, "" );
+ "rw> bindDn: \"%s\" -> \"%s\"\n",
+ conn->c_dn.bv_val, lsc->bound_dn.bv_val, 0 );
#endif /* !NEW_LOGGING */
break;
LDAP_UNWILLING_TO_PERFORM,
NULL, "Unwilling to perform",
NULL, NULL );
- /* continues to the next case */
+ return LDAP_UNWILLING_TO_PERFORM;
case REWRITE_REGEXEC_ERR:
+ send_ldap_result( conn, op,
+ LDAP_OPERATIONS_ERROR,
+ NULL, "Operations error",
+ NULL, NULL );
return LDAP_OPERATIONS_ERROR;
}
+
+ assert( lsc->bound_dn.bv_val );
+
} else {
- lsc->bound_dn = NULL;
+ ber_str2bv( "", 0, 1, &lsc->bound_dn );
}
lsc->bound = META_UNBOUND;
struct metaconn *
meta_back_getconn(
struct metainfo *li,
- Connection *conn,
- Operation *op,
- int op_type,
- const char *ndn,
- int *candidate
- )
+ Connection *conn,
+ Operation *op,
+ int op_type,
+ struct berval *ndn,
+ int *candidate )
{
struct metaconn *lc, lc_curr;
int vers, cached = -1, i = -1, err = LDAP_SUCCESS;
}
#ifdef NEW_LOGGING
- LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
- "meta_back_getconn: got target %d"
- " for ndn=\"%s\" from cache\n", i, ndn ));
+ LDAP_LOG( BACK_META, INFO,
+ "meta_back_getconn: got target %d for ndn=\"%s\" from cache\n",
+ i, ndn->bv_val, 0 );
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_CACHE,
"==>meta_back_getconn: got target %d for ndn=\"%s\" from cache\n%s",
- i, ndn, "" );
+ i, ndn->bv_val, "" );
#endif /* !NEW_LOGGING */
/*
/*
* The target is activated; if needed, it is
- * also init'd
+ * also init'd. In case of error, init_one_conn
+ * sends the appropriate result.
*/
err = init_one_conn( conn, op, li->targets[ i ],
vers, lc->conns[ i ] );
if ( new_conn ) {
metaconn_free( lc );
}
-
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, "internal server error", NULL, NULL );
-
return NULL;
}
*candidate = i;
}
+ /*
+ * require all connections ...
+ */
+ } else if (op_type == META_OP_REQUIRE_ALL) {
+ for ( i = 0; i < li->ntargets; i++ ) {
+
+ /*
+ * The target is activated; if needed, it is
+ * also init'd
+ */
+ int lerr = init_one_conn( conn, op, li->targets[ i ],
+ vers, lc->conns[ i ] );
+ if ( lerr != LDAP_SUCCESS ) {
+
+ /*
+ * FIXME: in case one target cannot
+ * be init'd, should the other ones
+ * be tried?
+ */
+ ( void )meta_clear_one_candidate( lc->conns[ i ], 1 );
+ err = lerr;
+ continue;
+ }
+ }
+
/*
* if no unique candidate ...
*/
} else {
- int ndnlen = strlen( ndn );
for ( i = 0; i < li->ntargets; i++ ) {
if ( i == cached
- || meta_back_is_candidate( li->targets[ i ]->suffix,
- ndn, ndnlen ) ) {
+ || meta_back_is_candidate( &li->targets[ i ]->suffix, ndn ) ) {
/*
* The target is activated; if needed, it is
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
#ifdef NEW_LOGGING
- LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
- "meta_back_getconn: conn %ld inserted\n",
- lc->conn->c_connid ));
+ LDAP_LOG( BACK_META, INFO,
+ "meta_back_getconn: conn %ld inserted\n", lc->conn->c_connid, 0, 0);
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_getconn: conn %ld inserted\n%s%s",
*/
if ( err != 0 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
- NULL, "internal server error", NULL, NULL );
+ NULL, "Internal server error", NULL, NULL );
metaconn_free( lc );
return NULL;
}
} else {
#ifdef NEW_LOGGING
- LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
- "meta_back_getconn: conn %ld fetched\n",
- lc->conn->c_connid ));
+ LDAP_LOG( BACK_META, INFO,
+ "meta_back_getconn: conn %ld fetched\n", lc->conn->c_connid, 0, 0 );
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
"=>meta_back_getconn: conn %ld fetched\n%s%s",