* Rewrite the bind dn if needed
*/
#ifdef ENABLE_REWRITE
- switch ( rewrite_session( li->rwinfo, "bindDn", op->o_req_dn.bv_val, op->o_conn, &mdn.bv_val ) ) {
+ switch ( rewrite_session( li->rwinfo, "bindDn",
+ op->o_req_dn.bv_val,
+ op->o_conn, &mdn.bv_val ) ) {
case REWRITE_REGEXEC_OK:
if ( mdn.bv_val == NULL ) {
- mdn.bv_val = ( char * )op->o_req_dn.bv_val;
+ mdn = op->o_req_dn;
+ } else {
+ mdn.bv_len = strlen( mdn.bv_val );
}
+
#ifdef NEW_LOGGING
LDAP_LOG( BACK_LDAP, DETAIL1,
- "[rw] bindDn: \"%s\" -> \"%s\"\n", op->o_req_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",
- op->o_req_dn.bv_val, mdn.bv_val, "" );
+ Debug( LDAP_DEBUG_ARGS, "rw> bindDn: \"%s\" -> \"%s\"\n",
+ op->o_req_dn.bv_val, mdn.bv_val, 0 );
#endif /* !NEW_LOGGING */
break;
}
/* must re-insert if local DN changed as result of bind */
- if ( lc->bound && ber_bvcmp(&op->o_req_ndn, &lc->local_dn ) ) {
- int err;
+ if ( lc->bound && !bvmatch(&op->o_req_ndn, &lc->local_dn ) ) {
+ int lerr;
+
ldap_pvt_thread_mutex_lock( &li->conn_mutex );
- lc = avl_delete( &li->conntree, (caddr_t)lc, ldap_back_conn_cmp );
+ lc = avl_delete( &li->conntree, (caddr_t)lc,
+ ldap_back_conn_cmp );
if ( lc->local_dn.bv_val )
ch_free( lc->local_dn.bv_val );
ber_dupbv( &lc->local_dn, &op->o_req_ndn );
- err = avl_insert( &li->conntree, (caddr_t)lc,
+ lerr = avl_insert( &li->conntree, (caddr_t)lc,
ldap_back_conn_cmp, ldap_back_conn_dup );
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
- if ( err == -1 ) {
+ if ( lerr == -1 ) {
ldap_back_conn_free( lc );
}
}
/* For shared sessions, conn is NULL. Only explicitly
* bound sessions will have non-NULL conn.
*/
- return lc1->conn - lc2->conn;
+ return (int)lc1->conn - (int)lc2->conn;
}
/*
printf( " " );
lc = root->avl_data;
- printf( "lc(%lx) local(%s) conn(%lx) %d\n", lc, lc->local_dn.bv_val, lc->conn, root->avl_bf );
+ printf( "lc(%lx) local(%s) conn(%lx) %d\n",
+ lc, lc->local_dn.bv_val, lc->conn, root->avl_bf );
ravl_print( root->avl_left, depth+1 );
}
ber_dupbv( &lc->local_dn, &lc_curr.local_dn );
if ( is_priv ) {
- ber_str2bv( li->bindpw, 0, 1, &lc->cred );
+ ber_dupbv( &lc->cred, &li->bindpw );
} else {
lc->cred.bv_len = 0;
lc->cred.bv_val = NULL;
lc->bound_dn.bv_val = NULL;
lc->bound_dn.bv_len = 0;
switch ( rewrite_session( li->rwinfo, "bindDn",
- op->o_conn->c_dn.bv_val, op->o_conn,
+ op->o_conn->c_dn.bv_val,
+ op->o_conn,
&lc->bound_dn.bv_val ) ) {
case REWRITE_REGEXEC_OK:
if ( lc->bound_dn.bv_val == NULL ) {
ber_dupbv( &lc->bound_dn,
&op->o_conn->c_dn );
+ } else {
+ lc->bound_dn.bv_len = strlen( lc->bound_dn.bv_val );
}
#ifdef NEW_LOGGING
LDAP_LOG( BACK_LDAP, DETAIL1,
"[rw] bindDn: \"%s\" ->"
- " \"%s\"\n%s",
+ " \"%s\"\n",
op->o_conn->c_dn.bv_val,
- lc->bound_dn.bv_val, "" );
+ lc->bound_dn.bv_val, 0 );
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> bindDn: \"%s\" ->"
- " \"%s\"\n%s",
+ " \"%s\"\n",
op->o_conn->c_dn.bv_val,
- lc->bound_dn.bv_val, "" );
+ lc->bound_dn.bv_val, 0 );
#endif /* !NEW_LOGGING */
break;
"ldap_back_getconn: conn %lx inserted\n", lc, 0, 0);
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
- "=>ldap_back_getconn: conn %lx inserted\n%s%s",
- lc, "", "" );
+ "=>ldap_back_getconn: conn %lx inserted\n", lc, 0, 0 );
#endif /* !NEW_LOGGING */
/* Err could be -1 in case a duplicate ldapconn is inserted */
lc, 0, 0 );
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_TRACE,
- "=>ldap_back_getconn: conn %lx fetched%s%s\n",
- lc, "", "" );
+ "=>ldap_back_getconn: conn %lx fetched\n", lc, 0, 0 );
#endif /* !NEW_LOGGING */
}
}
if (rs->sr_matched != match) free((char *)rs->sr_matched);
rs->sr_matched = NULL;
- if ( match ) free( match );
+ if ( match ) ldap_memfree( match );
if ( rs->sr_text ) {
- free( (char *)rs->sr_text );
+ ldap_memfree( (char *)rs->sr_text );
rs->sr_text = NULL;
}
return( (err==LDAP_SUCCESS) ? 0 : -1 );
struct ldapconn *lc;
struct timeval tv;
LDAPMessage *res, *e;
- int count, rc = 0, msgid, sres = LDAP_SUCCESS;
+ int count, rc = 0, msgid;
char *match = NULL;
char **mapped_attrs = NULL;
struct berval mbase;
struct berval mfilter = { 0, NULL };
struct slap_limits_set *limit = NULL;
int isroot = 0;
- BerVarray v2refs = NULL;
lc = ldap_back_getconn(li, op, rs);
if ( !lc ) {
Entry ent;
struct berval bdn;
e = ldap_first_entry(lc->ld,res);
- if ( ldap_build_entry(op->o_bd, op->o_conn, e, &ent, &bdn, 1) == LDAP_SUCCESS ) {
+ if ( ldap_build_entry(op, e, &ent, &bdn, 1) == LDAP_SUCCESS ) {
Attribute *a;
rs->sr_entry = &ent;
rs->sr_attrs = op->oq_search.rs_attrs;
int
ldap_build_entry(
- Backend *be,
- Connection *conn,
+ Operation *op,
LDAPMessage *e,
Entry *ent,
struct berval *bdn,
int private
)
{
- struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+ struct ldapinfo *li = (struct ldapinfo *) op->o_bd->be_private;
struct berval a, mapped;
BerElement ber = *e->lm_ber;
Attribute *attr, **attrp;
* Rewrite the dn of the result, if needed
*/
switch ( rewrite_session( li->rwinfo, "searchResult",
- bdn->bv_val, conn, &ent->e_name.bv_val ) ) {
+ bdn->bv_val, op->o_conn,
+ &ent->e_name.bv_val ) ) {
case REWRITE_REGEXEC_OK:
if ( ent->e_name.bv_val == NULL ) {
ent->e_name = *bdn;
switch ( rewrite_session( li->rwinfo,
"searchResult",
bv->bv_val,
- conn,
+ op->o_conn,
&newval.bv_val )) {
case REWRITE_REGEXEC_OK:
/* left as is */
*ent = ch_malloc(sizeof(Entry));
- rc = ldap_build_entry(op->o_bd, op->o_conn, e, *ent, &bdn, 0);
+ rc = ldap_build_entry(op, e, *ent, &bdn, 0);
if (rc != LDAP_SUCCESS) {
ch_free(*ent);