From: Pierangelo Masarati Date: Thu, 3 Apr 2003 21:44:43 +0000 (+0000) Subject: need this to be able to bound searches when back-ldap and the source are on the same... X-Git-Tag: AUTOCONF_2_57~97 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d07ea8b45054e2950a3f1ce2bedfacde8b508920;p=openldap need this to be able to bound searches when back-ldap and the source are on the same server; does it look fine? --- diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index e050576c29..1548cb306a 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -242,11 +242,22 @@ ldap_back_getconn(struct ldapinfo *li, Operation *op, SlapReply *rs) LDAP *ld; int is_priv = 0; + /* + * The local DN is the op->o_req_ndn if binding, otherwise + * it's the op->o_conn->c_ndn + */ + struct berval *cdn = &op->o_conn->c_ndn; + /* Searches for a ldapconn in the avl tree */ /* Explicit binds must not be shared */ if ( op->o_tag == LDAP_REQ_BIND ) { lc_curr.conn = op->o_conn; + cdn = &op->o_req_ndn; + + } else if ( op->o_conn->c_ndn.bv_len ) { + lc_curr.conn = op->o_conn; + } else { lc_curr.conn = NULL; } @@ -256,7 +267,7 @@ ldap_back_getconn(struct ldapinfo *li, Operation *op, SlapReply *rs) lc_curr.local_dn = li->be->be_rootndn; is_priv = 1; } else { - lc_curr.local_dn = op->o_ndn; + lc_curr.local_dn = *cdn; } ldap_pvt_thread_mutex_lock( &li->conn_mutex ); lc = (struct ldapconn *)avl_find( li->conntree, @@ -277,7 +288,10 @@ ldap_back_getconn(struct ldapinfo *li, Operation *op, SlapReply *rs) /* Set LDAP version. This will always succeed: If the client * bound with a particular version, then so can we. */ - ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &vers); + ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, + (const void *)&vers); + /* FIXME: configurable? */ + ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON); lc = (struct ldapconn *)ch_malloc(sizeof(struct ldapconn)); lc->conn = lc_curr.conn; @@ -296,11 +310,15 @@ ldap_back_getconn(struct ldapinfo *li, Operation *op, SlapReply *rs) #ifdef ENABLE_REWRITE /* * Sets a cookie for the rewrite session + * + * FIXME: the o_conn might be no longer valid, + * since we may have different entries + * for the same connection */ ( void )rewrite_session_init( li->rwinfo, op->o_conn ); #endif /* ENABLE_REWRITE */ - if ( op->o_conn->c_dn.bv_len != 0 ) { + if ( !is_priv && op->o_conn->c_dn.bv_len != 0 ) { /* * Rewrite the bind dn if needed