]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/bind.c
fix -ULDAP_DEVEL compile
[openldap] / servers / slapd / back-ldap / bind.c
index 1371f865e7f526cb49d18bf5669f341b748492d3..ce991e476c96b8e84ebf505a1efe4d04827f0a13 100644 (file)
@@ -251,7 +251,7 @@ ldap_back_prepare_conn( struct ldapconn **lcp, Operation *op, SlapReply *rs, lda
        if ( ( LDAP_BACK_USE_TLS( li ) || ( op->o_conn->c_is_tls && LDAP_BACK_PROPAGATE_TLS( li ) ) )
                                && !ldap_is_ldaps_url( li->url ) )
        {
-#if 1
+#ifdef SLAP_STARTTLS_ASYNCHRONOUS
                /*
                 * use asynchronous StartTLS
                 * in case, chase referral (not implemented yet)
@@ -315,12 +315,12 @@ retry:;
                                ldap_msgfree( res );
                        }
                }
-#else
+#else /* ! SLAP_STARTTLS_ASYNCHRONOUS */
                /*
                 * use synchronous StartTLS
                 */
                rs->sr_err = ldap_start_tls_s( ld, NULL, NULL );
-#endif
+#endif /* ! SLAP_STARTTLS_ASYNCHRONOUS */
 
                /* if StartTLS is requested, only attempt it if the URL
                 * is not "ldaps://"; this may occur not only in case
@@ -471,7 +471,6 @@ ldap_back_dobind_int(
 
        assert( retries >= 0 );
 
-       ldap_pvt_thread_mutex_lock( &lc->lc_mutex );
        if ( !lc->lc_bound ) {
                struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private;
 
@@ -511,14 +510,15 @@ ldap_back_dobind_int(
                if ( lc->lc_ispriv && li->acl_authmethod == LDAP_AUTH_SASL ) {
                        void            *defaults = NULL;
 
-#if 0  /* will deal with this later... */
-                       if ( sasl_secprops != NULL ) {
-                               rs->sr_err = ldap_set_option( lc->lc_ld, LDAP_OPT_X_SASL_SECPROPS,
-                                       (void *) sasl_secprops );
+#if 1  /* will deal with this later... */
+                       if ( li->acl_secprops != NULL ) {
+                               rc = ldap_set_option( lc->lc_ld,
+                                       LDAP_OPT_X_SASL_SECPROPS, li->acl_secprops);
 
-                               if ( rs->sr_err != LDAP_OPT_SUCCESS ) {
-                                       send_ldap_result( op, rs );
-                                       lc->lc_bound = 0;
+                               if( rc != LDAP_OPT_SUCCESS ) {
+                                       Debug( LDAP_DEBUG_ANY, "Error: ldap_set_option "
+                                               "(%s,SECPROPS,\"%s\") failed!\n",
+                                               li->url, li->acl_secprops, 0 );
                                        goto done;
                                }
                        }
@@ -585,14 +585,19 @@ retry:;
 
 done:;
        rc = lc->lc_bound;
-       ldap_pvt_thread_mutex_unlock( &lc->lc_mutex );
        return rc;
 }
 
 int
 ldap_back_dobind( struct ldapconn *lc, Operation *op, SlapReply *rs, ldap_back_send_t sendok )
 {
-       return ldap_back_dobind_int( lc, op, rs, sendok, 1 );
+       int     rc;
+
+       ldap_pvt_thread_mutex_lock( &lc->lc_mutex );
+       rc = ldap_back_dobind_int( lc, op, rs, sendok, 1 );
+       ldap_pvt_thread_mutex_unlock( &lc->lc_mutex );
+
+       return rc;
 }
 
 /*
@@ -705,18 +710,21 @@ retry:;
 int
 ldap_back_retry( struct ldapconn *lc, Operation *op, SlapReply *rs, ldap_back_send_t sendok )
 {
+       int     rc;
+
        ldap_pvt_thread_mutex_lock( &lc->lc_mutex );
        ldap_unbind_ext_s( lc->lc_ld, NULL, NULL );
        lc->lc_ld = NULL;
        lc->lc_bound = 0;
 
        /* lc here must be the regular lc, reset and ready for init */
-       if ( ldap_back_prepare_conn( &lc, op, rs, sendok ) != LDAP_SUCCESS ) {
-               return 0;
+       rc = ldap_back_prepare_conn( &lc, op, rs, sendok );
+       if ( rc == LDAP_SUCCESS ) {
+               rc = ldap_back_dobind_int( lc, op, rs, sendok, 0 );
        }
-
        ldap_pvt_thread_mutex_unlock( &lc->lc_mutex );
-       return ldap_back_dobind_int( lc, op, rs, sendok, 0 );
+
+       return rc;
 }
 
 static int