- ldap_pvt_thread_mutex_lock( &conn->c_mutex );
- connection2anonymous( conn );
- ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
-
- if ( op->o_dn.bv_val != NULL ) {
- free( op->o_dn.bv_val );
- op->o_dn.bv_val = ch_strdup( "" );
+ ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
+ if ( op->o_conn->c_sasl_bind_in_progress ) {
+ be = op->o_conn->c_authz_backend;
+ }
+ if ( !BER_BVISEMPTY( &op->o_conn->c_dn ) ) {
+ /* log authorization identity demotion */
+ Statslog( LDAP_DEBUG_STATS,
+ "%s BIND anonymous mech=implicit ssf=0\n",
+ op->o_log_prefix, 0, 0, 0, 0 );
+ }
+ connection2anonymous( op->o_conn );
+ if ( op->o_conn->c_sasl_bind_in_progress ) {
+ op->o_conn->c_authz_backend = be;
+ }
+ ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
+ if ( !BER_BVISNULL( &op->o_dn ) ) {
+ /* NOTE: temporarily wasting few bytes
+ * (until bind is completed), but saving
+ * a couple of ch_free() and ch_strdup("") */
+ op->o_dn.bv_val[0] = '\0';