meta_back_do_single_bind(
struct metaconn *lc,
Operation *op,
+ SlapReply *rs,
int candidate
);
int rc = -1, i, gotit = 0, ndnlen, isroot = 0;
int op_type = META_OP_ALLOW_MULTIPLE;
- int err = LDAP_SUCCESS;
+
+ rs->sr_err = LDAP_SUCCESS;
#ifdef NEW_LOGGING
LDAP_LOG( BACK_META, ENTRY, "meta_back_bind: dn: %s.\n",
op->oq_bind.rb_method = LDAP_AUTH_SIMPLE;
}
- lerr = meta_back_do_single_bind( lc, op, i );
+ lerr = meta_back_do_single_bind( lc, op, rs, i );
if ( lerr != LDAP_SUCCESS ) {
- err = lerr;
+ rs->sr_err = lerr;
( void )meta_clear_one_candidate( &lc->conns[ i ], 1 );
} else {
rc = LDAP_SUCCESS;
* err is the last error that occurred during a bind;
* if at least (and at most?) one bind succeedes, fine.
*/
- if ( rc != LDAP_SUCCESS /* && err != LDAP_SUCCESS */ ) {
+ if ( rc != LDAP_SUCCESS /* && rs->sr_err != LDAP_SUCCESS */ ) {
/*
* deal with bind failure ...
* no target was found within the naming context,
* so bind must fail with invalid credentials
*/
- if ( err == LDAP_SUCCESS && gotit == 0 ) {
- err = LDAP_INVALID_CREDENTIALS;
+ if ( rs->sr_err == LDAP_SUCCESS && gotit == 0 ) {
+ rs->sr_err = LDAP_INVALID_CREDENTIALS;
}
- rs->sr_err = ldap_back_map_result( err );
+ rs->sr_err = ldap_back_map_result( rs );
send_ldap_result( op, rs );
return -1;
}
meta_back_do_single_bind(
struct metaconn *lc,
Operation *op,
+ SlapReply *rs,
int candidate
)
{
struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
struct berval mdn = { 0, NULL };
- int rc;
ber_int_t msgid;
/*
}
if ( op->o_ctrls ) {
- rc = ldap_set_option( lc->conns[ candidate ].ld,
+ rs->sr_err = ldap_set_option( lc->conns[ candidate ].ld,
LDAP_OPT_SERVER_CONTROLS, op->o_ctrls );
- if ( rc != LDAP_SUCCESS ) {
- rc = ldap_back_map_result( rc );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ rs->sr_err = ldap_back_map_result( rs );
goto return_results;
}
}
- rc = ldap_sasl_bind(lc->conns[ candidate ].ld, mdn.bv_val,
+ rs->sr_err = ldap_sasl_bind(lc->conns[ candidate ].ld, mdn.bv_val,
LDAP_SASL_SIMPLE, &op->oq_bind.rb_cred,
op->o_ctrls, NULL, &msgid);
- if ( rc != LDAP_SUCCESS ) {
- rc = ldap_back_map_result( rc );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ rs->sr_err = ldap_back_map_result( rs );
} else {
/*
free( mdn.bv_val );
}
- return rc;
+ return rs->sr_err;
}
/*
char *rmatch = NULL;
for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
- int err = LDAP_SUCCESS;
char *msg = NULL;
char *match = NULL;
- ldap_get_option( lsc->ld, LDAP_OPT_ERROR_NUMBER, &err );
- if ( err != LDAP_SUCCESS ) {
+ rs->sr_err = LDAP_SUCCESS;
+
+ ldap_get_option( lsc->ld, LDAP_OPT_ERROR_NUMBER, &rs->sr_err );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
/*
* better check the type of error. In some cases
* (search ?) it might be better to return a
LDAP_OPT_ERROR_STRING, &msg );
ldap_get_option( lsc->ld,
LDAP_OPT_MATCHED_DN, &match );
- err = ldap_back_map_result( err );
+ rs->sr_err = ldap_back_map_result( rs );
#ifdef NEW_LOGGING
LDAP_LOG( BACK_META, RESULTS,
/*
* FIXME: need to rewrite "match" (need rwinfo)
*/
- switch ( err ) {
+ switch ( rs->sr_err ) {
default:
- rerr = err;
+ rerr = rs->sr_err;
rmsg = msg;
msg = NULL;
rmatch = match;
goto finish;
}
- cres = ldap_result2error( lsc->ld, res, 1 );
- switch ( cres ) {
+ rs->sr_err = ldap_result2error( lsc->ld, res, 1 );
+ switch ( rs->sr_err ) {
case LDAP_COMPARE_TRUE:
case LDAP_COMPARE_FALSE:
break;
default:
- rres = ldap_back_map_result( cres );
+ rres = ldap_back_map_result( rs );
if ( err != NULL ) {
free( err );
*/
static int
init_one_conn(
- Operation *op,
- SlapReply *rs,
+ Operation *op,
+ SlapReply *rs,
struct metatarget *lt,
struct metasingleconn *lsc
)
{
- int err, vers;
+ int vers;
/*
* Already init'ed
/*
* Attempts to initialize the connection to the target ds
*/
- err = ldap_initialize( &lsc->ld, lt->uri );
- if ( err != LDAP_SUCCESS ) {
- return ldap_back_map_result( err );
+ rs->sr_err = ldap_initialize( &lsc->ld, lt->uri );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ return ldap_back_map_result( rs );
}
/*
LDAPMessage *res, *e;
int count, rc = 0, *msgid, sres = LDAP_NO_SUCH_OBJECT;
char *match = NULL, *err = NULL;
- char *mbase = NULL, *mmatch = NULL;
- struct berval mfilter;
+ char *mmatch = NULL;
BerVarray v2refs = NULL;
int i, last = 0, candidates = 0;
* Inits searches
*/
for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
- char *realbase = ( char * )op->o_req_dn.bv_val;
- int realscope = op->oq_search.rs_scope;
- ber_len_t suffixlen;
- char **mapped_attrs;
+ char *realbase = ( char * )op->o_req_dn.bv_val;
+ int realscope = op->oq_search.rs_scope;
+ ber_len_t suffixlen = 0;
+ char *mbase = NULL;
+ struct berval mfilter = { 0L, NULL };
+ char **mapped_attrs = NULL;
if ( lsc->candidate != META_CANDIDATE ) {
msgid[ i ] = -1;
goto finish;
case REWRITE_REGEXEC_ERR:
+#if 0
rs->sr_err = LDAP_OTHER;
- rs->sr_text = "rewrite error";
+ rs->sr_text = "Rewrite error";
send_ldap_result( op, rs );
rc = -1;
goto finish;
- }
+#endif
-#if 0
- /*
- * Rewrite the search filter, if required
- */
- switch ( rewrite_session( li->targets[ i ]->rwinfo,
- "searchFilter",
- filterstr->bv_val, conn, &mfilter.bv_val ) ) {
- case REWRITE_REGEXEC_OK:
- if ( mfilter.bv_val != NULL && mfilter.bv_val[ 0 ] != '\0') {
- mfilter.bv_len = strlen( mfilter.bv_val );
- } else {
- if ( mfilter.bv_val != NULL ) {
- free( mfilter.bv_val );
- }
- mfilter = *filterstr;
- }
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] searchFilter [%d]: \"%s\" -> \"%s\"\n",
- i, filterstr->bv_val, mfilter.bv_val );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS,
- "rw> searchFilter [%d]: \"%s\" -> \"%s\"\n",
- i, filterstr->bv_val, mfilter.bv_val );
-#endif /* !NEW_LOGGING */
- break;
-
- case REWRITE_REGEXEC_UNWILLING:
- send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
- NULL, "Operation not allowed",
- NULL, NULL );
- rc = -1;
- goto finish;
-
- case REWRITE_REGEXEC_ERR:
- send_ldap_result( conn, op, LDAP_OTHER,
- NULL, "Rewrite error", NULL, NULL );
- rc = -1;
- goto finish;
+ /*
+ * this target is no longer candidate
+ */
+ msgid[ i ] = -1;
+ goto new_candidate;
}
/*
- * Maps attributes in filter
+ * Maps filter
*/
- mapped_filter = ldap_back_map_filter( &li->targets[ i ]->at_map,
- &li->targets[ i ]->oc_map, &mfilter,
- BACKLDAP_MAP );
- if ( mapped_filter == NULL ) {
- mapped_filter = ( char * )mfilter.bv_val;
- } else {
- if ( mfilter.bv_val != filterstr->bv_val ) {
- free( mfilter.bv_val );
- }
- }
- mfilter.bv_val = NULL;
- mfilter.bv_len = 0;
-#endif
-
rc = ldap_back_filter_map_rewrite_( li->targets[ i ]->rwinfo,
op->o_conn,
&li->targets[ i ]->at_map,
&li->targets[ i ]->oc_map,
op->oq_search.rs_filter,
&mfilter, BACKLDAP_MAP );
+ if ( rc != 0 ) {
+ /*
+ * this target is no longer candidate
+ */
+ msgid[ i ] = -1;
+ goto new_candidate;
+ }
/*
* Maps required attributes
*/
- mapped_attrs = ldap_back_map_attrs( &li->targets[ i ]->at_map,
- op->oq_search.rs_attrs, BACKLDAP_MAP );
+ rc = ldap_back_map_attrs( &li->targets[ i ]->at_map,
+ op->oq_search.rs_attrs, BACKLDAP_MAP,
+ &mapped_attrs );
+ if ( rc != LDAP_SUCCESS ) {
+ /*
+ * this target is no longer candidate
+ */
+ msgid[ i ] = -1;
+ goto new_candidate;
+ }
+
+#if 0
if ( mapped_attrs == NULL && op->oq_search.rs_attrs) {
for ( count = 0; op->oq_search.rs_attrs[ count ].an_name.bv_val; count++ );
mapped_attrs = ch_malloc( ( count + 1 ) * sizeof(char *));
}
mapped_attrs[ count ] = NULL;
}
+#endif
/*
* Starts the search
}
} else {
- sres = ldap_result2error( lsc->ld,
+ rs->sr_err = ldap_result2error( lsc->ld,
res, 1 );
- sres = ldap_back_map_result( sres );
+ sres = ldap_back_map_result( rs );
if ( err != NULL ) {
free( err );
}