]> git.sur5r.net Git - openldap/commitdiff
Rework scope defaulting to only default scope for references.
authorKurt Zeilenga <kurt@openldap.org>
Wed, 10 Jan 2001 23:48:24 +0000 (23:48 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 10 Jan 2001 23:48:24 +0000 (23:48 +0000)
Might break LDAPv2 partial results

libraries/libldap/ldap-int.h
libraries/libldap/request.c
libraries/libldap/result.c

index f2dcea3488e54bca41f438dec2b11b62f45a520e..9ed399fae438959d5968ef12f50ee3ad99de0329 100644 (file)
@@ -442,8 +442,10 @@ LDAP_F (void) ldap_free_request( LDAP *ld, LDAPRequest *lr );
 LDAP_F (void) ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
 LDAP_F (void) ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all );
 LDAP_F (void) ldap_dump_requests_and_responses( LDAP *ld );
-LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp );
-LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char **referralsp, int *hadrefp );
+LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr,
+       char **errstrp, int sref, int *hadrefp );
+LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr,
+       char **refs, int sref, char **referralsp, int *hadrefp );
 LDAP_F (int) ldap_append_referral( LDAP *ld, char **referralsp, char *s );
 
 /*
index 880b0015bce11c8479e49c0d36645bf388ed1a22..b1e7e170c29033d79b6d72606801247bcf5d99a6 100644 (file)
@@ -49,6 +49,7 @@ static BerElement *
 re_encode_request( LDAP *ld,
        BerElement *origber,
        ber_int_t msgid,
+       int sref,
        LDAPURLDesc *srv,
        int *type );
 
@@ -626,7 +627,7 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char *
        /* parse out & follow referrals */
        for( i=0; refarray[i] != NULL; i++) {
                /* Parse the referral URL */
-               if (( rc = ldap_url_parse( refarray[i], &srv)) != LDAP_SUCCESS) {
+               if (( rc = ldap_url_parse_ext( refarray[i], &srv)) != LDAP_SUCCESS) {
                        ld->ld_errno = rc;
                        rc = -1;
                        goto done;
@@ -655,7 +656,8 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char *
                                 * if two search references come in one behind the other
                                 * for the same server with different contexts.
                                 */
-                               Debug( LDAP_DEBUG_TRACE, "ldap_chase_v3referrals: queue referral \"%s\"\n",
+                               Debug( LDAP_DEBUG_TRACE,
+                                       "ldap_chase_v3referrals: queue referral \"%s\"\n",
                                        refarray[i], 0, 0);
                                if( lc->lconn_rebind_queue == NULL ) {
                                        /* Create a referral list */
@@ -700,14 +702,17 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char *
                        srv->lud_dn = LDAP_STRDUP( "" );
                }
 
-               if (( ber = re_encode_request( ld, origreq->lr_ber,
-                           ++ld->ld_msgid, srv, &rinfo.ri_request )) == NULL ) {
+               ber = re_encode_request( ld, origreq->lr_ber, ++ld->ld_msgid,
+                       sref, srv, &rinfo.ri_request );
+
+               if( ber == NULL ) {
                        ld->ld_errno = LDAP_ENCODING_ERROR;
                        rc = -1;
                        goto done;
                }
 
-               Debug( LDAP_DEBUG_TRACE, "ldap_chase_v3referral: msgid %d, url \"%s\"\n",
+               Debug( LDAP_DEBUG_TRACE,
+                       "ldap_chase_v3referral: msgid %d, url \"%s\"\n",
                        lr->lr_msgid, refarray[i], 0);
 
                /* Send the new request to the server - may require a bind */
@@ -781,7 +786,11 @@ done:
  * XXX merging of errors in this routine needs to be improved
  */
 int
-ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
+ldap_chase_referrals( LDAP *ld,
+       LDAPRequest *lr,
+       char **errstrp,
+       int sref,
+       int *hadrefp )
 {
        int             rc, count, len;
        char            *p, *ref, *unfollowed;
@@ -858,7 +867,7 @@ ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
                *hadrefp = 1;
 
                ber = re_encode_request( ld, origreq->lr_ber,
-                   ++ld->ld_msgid, srv, &rinfo.ri_request );
+                   ++ld->ld_msgid, sref, srv, &rinfo.ri_request );
 
                if( ber == NULL ) {
                        return -1 ;
@@ -929,6 +938,7 @@ static BerElement *
 re_encode_request( LDAP *ld,
        BerElement *origber,
        ber_int_t msgid,
+       int sref,
        LDAPURLDesc *srv,
        int *type )
 {
@@ -981,7 +991,7 @@ re_encode_request( LDAP *ld,
                        /* use the scope provided in reference */
                        scope = srv->lud_scope;
 
-               } else if ( scope != LDAP_SCOPE_SUBTREE ) {
+               } else if ( sref && scope != LDAP_SCOPE_SUBTREE ) {
                        /* use scope implied by previous operation */
                        /*   base -> base */
                        /*   one -> base */
index 75f89e07473ab63982575577db1d03716388f5ee..f9e70a2cf2778aaea0b864543277ba5539b045b2 100644 (file)
@@ -334,7 +334,7 @@ try_read1msg(
        ber_int_t msgid,
        int all,
        Sockbuf *sb,
-    LDAPConn *lc,
+       LDAPConn *lc,
        LDAPMessage **result )
 {
        BerElement      *ber;
@@ -426,7 +426,8 @@ try_read1msg(
                return( -1 );
        }
 
-       Debug( LDAP_DEBUG_TRACE, "ldap_read: message type %s msgid %ld, original id %ld\n",
+       Debug( LDAP_DEBUG_TRACE,
+               "ldap_read: message type %s msgid %ld, original id %ld\n",
            ldap_int_msgtype2str( tag ),
                (long) lr->lr_msgid, (long) lr->lr_origid );
 
@@ -534,14 +535,13 @@ try_read1msg(
                        tmpber = *ber;  /* struct copy */
                        if ( v3ref == 1 ) {
                                ; /* V3 search reference or V3 referral sucessfully chased */
-                       } else
-                       if ( ber_scanf( &tmpber, "{iaa}", &lderr,
+                       } else if ( ber_scanf( &tmpber, "{iaa}", &lderr,
                            &lr->lr_res_matched, &lr->lr_res_error )
                            != LBER_ERROR ) {
                                if ( lderr != LDAP_SUCCESS ) {
                                        /* referrals are in error string */
                                        refer_cnt = ldap_chase_referrals( ld, lr,
-                                           &lr->lr_res_error, &hadref );
+                                               &lr->lr_res_error, -1, &hadref );
                                        lr->lr_status = LDAP_REQST_COMPLETED;
                                        Debug( LDAP_DEBUG_TRACE,
                                            "read1msg:  V2 referral chased, mark request completed, id = %d\n", lr->lr_msgid, 0, 0);