]> git.sur5r.net Git - openldap/commitdiff
fix server-size controls handling in back-{ldap,meta}
authorPierangelo Masarati <ando@openldap.org>
Thu, 29 Aug 2002 15:07:18 +0000 (15:07 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 29 Aug 2002 15:07:18 +0000 (15:07 +0000)
servers/slapd/back-ldap/bind.c
servers/slapd/back-meta/bind.c

index 760b152c96427efe42ff35bf35543e4c39433dc1..e65ea665a6804aa5f274a95d9d08dbb0663bb4b6 100644 (file)
@@ -75,7 +75,11 @@ ldap_back_bind(
        }
 
        if ( op->o_ctrls ) {
-               ldap_set_option( lc->ld, LDAP_OPT_SERVER_CONTROLS, op->o_ctrls );
+               if ( ldap_set_option( lc->ld, LDAP_OPT_SERVER_CONTROLS,
+                                       op->o_ctrls ) != LDAP_SUCCESS ) {
+                       ldap_back_op_result( lc, op );
+                       return( -1 );
+               }
        }
        
        /*
@@ -355,16 +359,19 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op)
  */
 int
 ldap_back_dobind( struct ldapconn *lc, Operation *op )
-{
+{      
+       if ( op->o_ctrls ) {
+               if ( ldap_set_option( lc->ld, LDAP_OPT_SERVER_CONTROLS,
+                               op->o_ctrls ) != LDAP_SUCCESS ) {
+                       ldap_back_op_result( lc, op );
+                       return( 0 );
+               }
+       }
+       
        if ( lc->bound ) {
                return( lc->bound );
        }
 
-       if ( op->o_ctrls ) {
-               ldap_set_option( lc->ld, LDAP_OPT_SERVER_CONTROLS,
-                               op->o_ctrls );
-       }
-       
        if ( ldap_bind_s( lc->ld, lc->bound_dn.bv_val, lc->cred.bv_val, 
                                LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
                ldap_back_op_result( lc, op );
index b3c3f809a89094ab9f35cb4037cb549a33f59938..2a800c5c5c1728c445c48bf48902d70fbe23b2c5 100644 (file)
@@ -277,8 +277,12 @@ meta_back_do_single_bind(
        }
 
        if ( op->o_ctrls ) {
-               ldap_set_option( lc->conns[ candidate ].ld, 
+               rc = ldap_set_option( lc->conns[ candidate ].ld, 
                                LDAP_OPT_SERVER_CONTROLS, op->o_ctrls );
+               if ( rc != LDAP_SUCCESS ) {
+                       rc = ldap_back_map_result( rc );
+                       goto return_results;
+               }
        }
        
        rc = ldap_bind_s( lc->conns[ candidate ].ld, mdn.bv_val, cred->bv_val, method );
@@ -295,6 +299,8 @@ meta_back_do_single_bind(
                                        ndn, candidate );
                }
        }
+
+return_results:;
        
        if ( mdn.bv_val != dn->bv_val ) {
                free( mdn.bv_val );
@@ -329,6 +335,17 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                        continue;
                }
 
+               /*
+                * If required, set controls
+                */
+               if ( op->o_ctrls ) {
+                       if ( ldap_set_option( lsc->ld, LDAP_OPT_SERVER_CONTROLS,
+                                       op->o_ctrls ) != LDAP_SUCCESS ) {
+                               ( void )meta_clear_one_candidate( lsc, 1 );
+                               continue;
+                       }
+               }
+       
                /*
                 * If the target is already bound it is skipped
                 */
@@ -348,11 +365,7 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                        lsc->bound_dn.bv_len = 0;
                }
                
-               if ( op->o_ctrls ) {
-                       ldap_set_option( lsc->ld, LDAP_OPT_SERVER_CONTROLS,
-                                       op->o_ctrls );
-               }
-       
+
                rc = ldap_bind_s( lsc->ld, 0, NULL, LDAP_AUTH_SIMPLE );
                if ( rc != LDAP_SUCCESS ) {