]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-meta/search.c
Merge branch 'mdb.master' of ssh://git-master.openldap.org/~git/git/openldap
[openldap] / servers / slapd / back-meta / search.c
index 2c958c719004931f69ba9117266976fbcef8d6d8..f4135fe2aba22549a91946805f7bbeebf612c3a3 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2010 The OpenLDAP Foundation.
+ * Copyright 1999-2011 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * Portions Copyright 1999-2003 Howard Chu.
  * All rights reserved.
@@ -32,9 +32,7 @@
 #include "slap.h"
 #include "../back-ldap/back-ldap.h"
 #include "back-meta.h"
-#undef ldap_debug      /* silence a warning in ldap-int.h */
-#include "ldap_log.h"
-#include "../../../libraries/libldap/ldap-int.h"
+#include "../../../libraries/liblber/lber-int.h"
 
 /* IGNORE means that target does not (no longer) participate
  * in the search;
@@ -237,6 +235,10 @@ meta_search_dobind_init(
 
        assert( msc->msc_ld != NULL );
 
+       /* connect must be async only the first time... */
+       ldap_set_option( msc->msc_ld, LDAP_OPT_CONNECT_ASYNC, LDAP_OPT_ON );
+
+retry:;
        if ( !BER_BVISEMPTY( &binddn ) && BER_BVISEMPTY( &cred ) ) {
                /* bind anonymously? */
                Debug( LDAP_DEBUG_ANY, "%s meta_search_dobind_init[%d] mc=%p: "
@@ -252,10 +254,6 @@ meta_search_dobind_init(
                goto other;
        }
 
-       /* connect must be async only the first time... */
-       ldap_set_option( msc->msc_ld, LDAP_OPT_CONNECT_ASYNC, LDAP_OPT_ON );
-
-retry:;
        rc = ldap_sasl_bind( msc->msc_ld, binddn.bv_val, LDAP_SASL_SIMPLE, &cred,
                        NULL, NULL, &candidates[ candidate ].sr_msgid );
 
@@ -329,6 +327,8 @@ down:;
 
                        if ( rc == LDAP_SUCCESS ) {
                                candidates[ candidate ].sr_msgid = META_MSGID_IGNORE;
+                               binddn = msc->msc_bound_ndn;
+                               cred = msc->msc_cred;
                                goto retry;
                        }
                }
@@ -622,13 +622,13 @@ meta_back_search_start(
 #ifdef SLAPD_META_CLIENT_PR
        save_ctrls = op->o_ctrls;
        {
-               LDAPControl *pr_c = NULL, **next_c = NULL;
+               LDAPControl *pr_c = NULL;
                int i = 0, nc = 0;
 
                if ( save_ctrls ) {
                        for ( ; save_ctrls[i] != NULL; i++ );
                        nc = i;
-                       pr_c = ldap_control_find( LDAP_CONTROL_PAGEDRESULTS, save_ctrls, &next_c );
+                       pr_c = ldap_control_find( LDAP_CONTROL_PAGEDRESULTS, save_ctrls, NULL );
                }
 
                if ( pr_c != NULL ) nc--;
@@ -1533,9 +1533,9 @@ really_bad:;
                                        case LDAP_SUCCESS:
                                                if ( ctrls != NULL && ctrls[0] != NULL ) {
 #ifdef SLAPD_META_CLIENT_PR
-                                                       LDAPControl *pr_c, **next_c;
+                                                       LDAPControl *pr_c;
 
-                                                       pr_c = ldap_control_find( LDAP_CONTROL_PAGEDRESULTS, ctrls, &next_c );
+                                                       pr_c = ldap_control_find( LDAP_CONTROL_PAGEDRESULTS, ctrls, NULL );
                                                        if ( pr_c != NULL ) {
                                                                BerElementBuffer berbuf;
                                                                BerElement *ber = (BerElement *)&berbuf;
@@ -1918,7 +1918,7 @@ free_message:;
        }
 
        rs->sr_err = sres;
-       rs->sr_matched = matched;
+       rs->sr_matched = ( sres == LDAP_SUCCESS ? NULL : matched );
        rs->sr_ref = ( sres == LDAP_REFERRAL ? rs->sr_v2ref : NULL );
        send_ldap_result( op, rs );
        op->o_private = savepriv;