free( mdn.bv_val );
}
- return( ldap_back_op_result( li, lc, op, rs, msgid, j, 1 ) );
+ return( ldap_back_op_result( lc, op, rs, msgid, j, 1 ) );
}
#ifdef ENABLE_REWRITE
struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
int ldap_back_map_result(int err);
-int ldap_back_op_result(struct ldapinfo *li, struct ldapconn *lc,
- Operation *op, SlapReply *rs, ber_int_t msgid, int rc, int sendok);
+int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
+ ber_int_t msgid, int rc, int sendok);
int back_ldap_LTX_init_module(int argc, char *argv[]);
void ldap_back_dn_massage(struct ldapinfo *li, struct berval *dn,
/* method is always LDAP_AUTH_SIMPLE if we got here */
rc = ldap_sasl_bind(lc->ld, mdn.bv_val, LDAP_SASL_SIMPLE,
&op->oq_bind.rb_cred, op->o_ctrls, NULL, &msgid);
- rc = ldap_back_op_result( li, lc, op, rs, msgid, rc, 1 );
+ rc = ldap_back_op_result( lc, op, rs, msgid, rc, 1 );
if (rc == LDAP_SUCCESS) {
lc->bound = 1;
if ( mdn.bv_val != op->o_req_dn.bv_val ) {
int
ldap_back_dobind( struct ldapconn *lc, Operation *op, SlapReply *rs )
{
- struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private;
int rc;
ber_int_t msgid;
if ( !lc->bound ) {
rc = ldap_sasl_bind(lc->ld, lc->bound_dn.bv_val,
LDAP_SASL_SIMPLE, &lc->cred, NULL, NULL, &msgid);
- rc = ldap_back_op_result( li, lc, op, rs, msgid, rc, 0 );
+ rc = ldap_back_op_result( lc, op, rs, msgid, rc, 0 );
if (rc == LDAP_SUCCESS) {
lc->bound = 1;
}
}
int
-ldap_back_op_result(struct ldapinfo *li, struct ldapconn *lc,
- Operation *op, SlapReply *rs, ber_int_t msgid, int err, int sendok)
+ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
+ ber_int_t msgid, int err, int sendok)
{
+ struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private;
char *match = NULL;
LDAPMessage *res;
int rc;
free( mdn.bv_val );
}
- return( ldap_back_op_result( li, lc, op, rs, msgid, rc, 1 ) );
+ return( ldap_back_op_result( lc, op, rs, msgid, rc, 1 ) );
}
free( mdn.bv_val );
}
- return( ldap_back_op_result( li, lc, op, rs, msgid, rc, 1 ) );
+ return( ldap_back_op_result( lc, op, rs, msgid, rc, 1 ) );
}
ch_free( mods );
ch_free( modv );
- return ldap_back_op_result( li, lc, op, rs, msgid, rc, 1 );
+ return ldap_back_op_result( lc, op, rs, msgid, rc, 1 );
}
free( mnewSuperior.bv_val );
}
- return( ldap_back_op_result( li, lc, op, rs, msgid, rc, 1 ) );
+ return( ldap_back_op_result( lc, op, rs, msgid, rc, 1 ) );
}
case REWRITE_REGEXEC_OK:
if ( mbase.bv_val == NULL ) {
mbase = op->o_req_dn;
+ } else {
+ mbase.bv_len = strlen( mbase.bv_val );
}
#ifdef NEW_LOGGING
LDAP_LOG( BACK_LDAP, DETAIL1,
: NULL, op->oq_search.rs_slimit, &msgid);
if ( rc != LDAP_SUCCESS ) {
fail:;
- rc = ldap_back_op_result(li, lc, op, rs, msgid, rc, 0);
+ rc = ldap_back_op_result(lc, op, rs, msgid, rc, 0);
goto finish;
}
struct berval *bv;
const char *text;
+ /* safe assumptions ... */
+ assert( ent );
+ ent->e_bv.bv_val = NULL;
+
if ( ber_scanf( &ber, "{m{", bdn ) == LBER_ERROR ) {
return LDAP_DECODING_ERROR;
}
/*
* get the current connection
*/
- lc = meta_back_getconn( li, op, rs, META_OP_REQUIRE_SINGLE,
+ lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE,
&op->o_req_ndn, &candidate );
if ( !lc ) {
send_ldap_result( op, rs );
#define META_OP_REQUIRE_ALL 0x02
extern struct metaconn *
meta_back_getconn(
- struct metainfo *li,
Operation *op,
SlapReply *rs,
int op_type,
static int
meta_back_do_single_bind(
- struct metainfo *li,
struct metaconn *lc,
Operation *op,
- struct berval *dn,
- struct berval *ndn,
- struct berval *cred,
- int method,
int candidate
);
int
meta_back_bind( Operation *op, SlapReply *rs )
- /*
- Backend *be,
- Connection *conn,
- Operation *op,
- struct berval *dn,
- struct berval *ndn,
- int method,
- struct berval *cred,
- struct berval *edn
-) */
{
struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
struct metaconn *lc;
int op_type = META_OP_ALLOW_MULTIPLE;
int err = LDAP_SUCCESS;
- struct berval *realdn = &op->o_req_dn;
- struct berval *realndn = &op->o_req_ndn;
- struct berval *realcred = &op->oq_bind.rb_cred;
- int realmethod = op->oq_bind.rb_method;
-
#ifdef NEW_LOGGING
LDAP_LOG( BACK_META, ENTRY, "meta_back_bind: dn: %s.\n",
op->o_req_dn.bv_val, 0, 0 );
ber_dupbv( &op->oq_bind.rb_edn, be_root_dn( op->o_bd ) );
op_type = META_OP_REQUIRE_ALL;
}
- lc = meta_back_getconn( li, op, rs, op_type,
+ lc = meta_back_getconn( op, rs, op_type,
&op->o_req_ndn, NULL );
if ( !lc ) {
#ifdef NEW_LOGGING
lc->bound_target = META_BOUND_NONE;
ndnlen = op->o_req_ndn.bv_len;
for ( i = 0; i < li->ntargets; i++ ) {
- int lerr;
+ int lerr;
+ struct berval orig_dn = op->o_req_dn;
+ struct berval orig_ndn = op->o_req_ndn;
+ struct berval orig_cred = op->oq_bind.rb_cred;
+ int orig_method = op->oq_bind.rb_method;
+
/*
* Skip non-candidates
}
if ( isroot && li->targets[ i ]->pseudorootdn.bv_val != NULL ) {
- realdn = &li->targets[ i ]->pseudorootdn;
- realndn = &li->targets[ i ]->pseudorootdn;
- realcred = &li->targets[ i ]->pseudorootpw;
- realmethod = LDAP_AUTH_SIMPLE;
- } else {
- realdn = &op->o_req_dn;
- realndn = &op->o_req_ndn;
- realcred = &op->oq_bind.rb_cred;
- realmethod = op->oq_bind.rb_method;
+ op->o_req_dn = li->targets[ i ]->pseudorootdn;
+ op->o_req_ndn = li->targets[ i ]->pseudorootdn;
+ op->oq_bind.rb_cred = li->targets[ i ]->pseudorootpw;
+ op->oq_bind.rb_method = LDAP_AUTH_SIMPLE;
}
- lerr = meta_back_do_single_bind( li, lc, op,
- realdn, realndn, realcred, realmethod, i );
+ lerr = meta_back_do_single_bind( lc, op, i );
if ( lerr != LDAP_SUCCESS ) {
err = lerr;
( void )meta_clear_one_candidate( &lc->conns[ i ], 1 );
} else {
rc = LDAP_SUCCESS;
}
+
+ op->o_req_dn = orig_dn;
+ op->o_req_ndn = orig_ndn;
+ op->oq_bind.rb_cred = orig_cred;
+ op->oq_bind.rb_method = orig_method;
}
if ( isroot ) {
*/
static int
meta_back_do_single_bind(
- struct metainfo *li,
struct metaconn *lc,
Operation *op,
- struct berval *dn,
- struct berval *ndn,
- struct berval *cred,
- int method,
int candidate
)
{
+ struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
struct berval mdn = { 0, NULL };
int rc;
ber_int_t msgid;
* Rewrite the bind dn if needed
*/
switch ( rewrite_session( li->targets[ candidate ]->rwinfo,
- "bindDn", dn->bv_val, lc->conn, &mdn.bv_val ) ) {
+ "bindDn", op->o_req_dn.bv_val,
+ lc->conn, &mdn.bv_val ) ) {
case REWRITE_REGEXEC_OK:
if ( mdn.bv_val == NULL ) {
- mdn = *dn;
+ mdn = op->o_req_dn;
+ } else {
+ mdn.bv_len = strlen( mdn.bv_val );
}
#ifdef NEW_LOGGING
LDAP_LOG( BACK_META, DETAIL1,
- "[rw] bindDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn.bv_val, 0 );
+ "[rw] bindDn: \"%s\" -> \"%s\"\n",
+ op->o_req_dn.bv_val, mdn.bv_val, 0 );
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> bindDn: \"%s\" -> \"%s\"\n%s",
- dn->bv_val, mdn.bv_val, "" );
+ op->o_req_dn.bv_val, mdn.bv_val, "" );
#endif /* !NEW_LOGGING */
break;
}
rc = ldap_sasl_bind(lc->conns[ candidate ].ld, mdn.bv_val,
- LDAP_SASL_SIMPLE, cred, op->o_ctrls, NULL, &msgid);
+ LDAP_SASL_SIMPLE, &op->oq_bind.rb_cred,
+ op->o_ctrls, NULL, &msgid);
if ( rc != LDAP_SUCCESS ) {
rc = ldap_back_map_result( rc );
+
} else {
- ber_dupbv( &lc->conns[ candidate ].bound_dn, dn );
+ /*
+ * FIXME: handle response!!!
+ */
+ ber_dupbv( &lc->conns[ candidate ].bound_dn, &op->o_req_dn );
lc->conns[ candidate ].bound = META_BOUND;
lc->bound_target = candidate;
if ( li->savecred ) {
if ( lc->conns[ candidate ].cred.bv_val )
ch_free( lc->conns[ candidate ].cred.bv_val );
- ber_dupbv( &lc->conns[ candidate ].cred, cred );
+ ber_dupbv( &lc->conns[ candidate ].cred,
+ &op->oq_bind.rb_cred );
ldap_set_rebind_proc( lc->conns[ candidate ].ld,
meta_back_rebind,
&lc->conns[ candidate ] );
}
if ( li->cache.ttl != META_DNCACHE_DISABLED
- && ndn->bv_len != 0 ) {
+ && op->o_req_ndn.bv_len != 0 ) {
( void )meta_dncache_update_entry( &li->cache,
- ndn, candidate );
+ &op->o_req_ndn, candidate );
}
}
return_results:;
- if ( mdn.bv_val != dn->bv_val ) {
+ if ( mdn.bv_val != op->o_req_dn.bv_val ) {
free( mdn.bv_val );
}
{
struct metaconn* lc;
result->type = SUCCESS;
- lc = meta_back_getconn( li, conn, op, op_type, nbase, NULL );
+ lc = meta_back_getconn( conn, op, op_type, nbase, NULL );
if (!lc) {
result->type = CONN_ERR;
return 0;
int cres = LDAP_SUCCESS, rres = LDAP_SUCCESS;
int *msgid;
- lc = meta_back_getconn( li, op, rs, META_OP_ALLOW_MULTIPLE,
+ lc = meta_back_getconn( op, rs, META_OP_ALLOW_MULTIPLE,
&op->o_req_ndn, NULL );
if ( !lc ) {
send_ldap_result( op, rs );
*/
struct metaconn *
meta_back_getconn(
- struct metainfo *li,
Operation *op,
SlapReply *rs,
int op_type,
struct berval *ndn,
int *candidate )
{
+ struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
struct metaconn *lc, lc_curr;
int cached = -1, i = -1, err = LDAP_SUCCESS;
int new_conn = 0;
char *mdn = NULL;
- lc = meta_back_getconn( li, op, rs, META_OP_REQUIRE_SINGLE,
+ lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE,
&op->o_req_ndn, &candidate );
if ( !lc ) {
send_ldap_result( op, rs );
char *mdn;
struct berval mapped;
- lc = meta_back_getconn( li, op, rs, META_OP_REQUIRE_SINGLE,
+ lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE,
&op->o_req_ndn, &candidate );
if ( !lc ) {
rc = -1;
char *mdn = NULL,
*mnewSuperior = NULL;
- lc = meta_back_getconn( li, op, rs, META_OP_REQUIRE_SINGLE,
+ lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE,
&op->o_req_ndn, &candidate );
if ( !lc ) {
rc = -1;
* FIXME: in case of values return filter, we might want
* to map attrs and maybe rewrite value
*/
- lc = meta_back_getconn( li, op, rs, META_OP_ALLOW_MULTIPLE,
+ lc = meta_back_getconn( op, rs, META_OP_ALLOW_MULTIPLE,
&op->o_req_ndn, NULL );
if ( !lc ) {
send_ldap_result( op, rs );