]> git.sur5r.net Git - openldap/commitdiff
need this to be able to bound searches when back-ldap and the source are on the same...
authorPierangelo Masarati <ando@openldap.org>
Thu, 3 Apr 2003 21:44:43 +0000 (21:44 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 3 Apr 2003 21:44:43 +0000 (21:44 +0000)
servers/slapd/back-ldap/bind.c

index e050576c29c0eb610a0ba56fee8ac8cb489eeb16..1548cb306a4e7a761f108cc7289da40e7784c703 100644 (file)
@@ -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