]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/search.c
fix controls run-time registered by global overlays (kludge non longer required?)
[openldap] / servers / slapd / back-ldap / search.c
index 4cf1c72b3dc9b9fac5b695b055f089b00f3046e9..b42352614f65e09159e8df6bfb80efcedadff3dd 100644 (file)
@@ -60,17 +60,17 @@ ldap_back_search(
        int             do_retry = 1;
        LDAPControl     **ctrls = NULL;
 
-       lc = ldap_back_getconn( op, rs );
+       lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR );
        if ( !lc ) {
-               return -1;
+               return rs->sr_err;
        }
 
        /*
         * FIXME: in case of values return filter, we might want
         * to map attrs and maybe rewrite value
         */
-       if ( !ldap_back_dobind( lc, op, rs ) ) {
-               return -1;
+       if ( !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) {
+               return rs->sr_err;
        }
 
        /* should we check return values? */
@@ -105,13 +105,11 @@ ldap_back_search(
        }
 
        ctrls = op->o_ctrls;
-#ifdef LDAP_BACK_PROXY_AUTHZ
        rc = ldap_back_proxy_authz_ctrl( lc, op, rs, &ctrls );
        if ( rc != LDAP_SUCCESS ) {
                dontfreetext = 1;
                goto finish;
        }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
        
 retry:
        rs->sr_err = ldap_search_ext( lc->lc_ld, op->o_req_ndn.bv_val,
@@ -122,7 +120,7 @@ retry:
 
        if ( rs->sr_err != LDAP_SUCCESS ) {
 fail:;
-               rc = ldap_back_op_result( lc, op, rs, msgid, 0 );
+               rc = ldap_back_op_result( lc, op, rs, msgid, LDAP_BACK_SENDERR );
                if ( freeconn ) {
                        ldap_back_freeconn( op, lc );
                        lc = NULL;
@@ -251,7 +249,7 @@ fail:;
        if ( rc == -1 ) {
                if ( do_retry ) {
                        do_retry = 0;
-                       if ( ldap_back_retry( lc, op, rs ) ) {
+                       if ( ldap_back_retry( lc, op, rs, LDAP_BACK_SENDERR ) ) {
                                goto retry;
                        }
                }
@@ -274,9 +272,7 @@ fail:;
 finish:;
        send_ldap_result( op, rs );
 
-#ifdef LDAP_BACK_PROXY_AUTHZ
        (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
        if ( rs->sr_ctrls ) {
                ldap_controls_free( rs->sr_ctrls );
@@ -504,7 +500,6 @@ ldap_back_entry_get(
                        *e = NULL;
        char            *gattr[3];
        char            *filter = NULL;
-       Connection      *oconn;
        SlapReply       rs;
        int             do_retry = 1;
        LDAPControl     **ctrls = NULL;
@@ -512,16 +507,12 @@ ldap_back_entry_get(
        /* Tell getconn this is a privileged op */
        do_not_cache = op->o_do_not_cache;
        op->o_do_not_cache = 1;
-       lc = ldap_back_getconn( op, &rs );
-       oconn = op->o_conn;
-       op->o_conn = NULL;
-       if ( !lc || !ldap_back_dobind( lc, op, &rs ) ) {
+       lc = ldap_back_getconn( op, &rs, LDAP_BACK_DONTSEND );
+       if ( !lc || !ldap_back_dobind( lc, op, &rs, LDAP_BACK_DONTSEND ) ) {
                op->o_do_not_cache = do_not_cache;
-               op->o_conn = oconn;
-               return 1;
+               return rs.sr_err;
        }
        op->o_do_not_cache = do_not_cache;
-       op->o_conn = oconn;
 
        if ( at ) {
                if ( oc && at != slap_schema.si_ad_objectClass ) {
@@ -547,12 +538,10 @@ ldap_back_entry_get(
        }
 
        ctrls = op->o_ctrls;
-#ifdef LDAP_BACK_PROXY_AUTHZ
        rc = ldap_back_proxy_authz_ctrl( lc, op, &rs, &ctrls );
        if ( rc != LDAP_SUCCESS ) {
                goto cleanup;
        }
-#endif /* LDAP_BACK_PROXY_AUTHZ */
        
 retry:
        rc = ldap_search_ext_s( lc->lc_ld, ndn->bv_val, LDAP_SCOPE_BASE, filter,
@@ -561,7 +550,7 @@ retry:
        if ( rc != LDAP_SUCCESS ) {
                if ( rc == LDAP_SERVER_DOWN && do_retry ) {
                        do_retry = 0;
-                       if ( ldap_back_retry( lc, op, &rs ) ) {
+                       if ( ldap_back_retry( lc, op, &rs, LDAP_BACK_DONTSEND ) ) {
                                goto retry;
                        }
                }
@@ -583,9 +572,7 @@ retry:
        }
 
 cleanup:
-#ifdef LDAP_BACK_PROXY_AUTHZ
        (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls );
-#endif /* LDAP_BACK_PROXY_AUTHZ */
 
        if ( result ) {
                ldap_msgfree( result );