+ if ( conn->c_sasl_bind_mech.bv_val != NULL ) {
+ free(conn->c_sasl_bind_mech.bv_val);
+ conn->c_sasl_bind_mech.bv_val = NULL;
+ conn->c_sasl_bind_mech.bv_len = 0;
+ }
+ conn->c_sasl_bind_in_progress = 0;
+
+ slap_sasl_reset( conn );
+ ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+ }
+
+ if ( method == LDAP_AUTH_SIMPLE ) {
+ /* accept "anonymous" binds */
+ if ( cred.bv_len == 0 || ndn.bv_len == 0 ) {
+ rc = LDAP_SUCCESS;
+ text = NULL;
+
+ if( cred.bv_len &&
+ !( global_allows & SLAP_ALLOW_BIND_ANON_CRED ))
+ {
+ /* cred is not empty, disallow */
+ rc = LDAP_INVALID_CREDENTIALS;
+
+ } else if ( ndn.bv_len &&
+ !( global_allows & SLAP_ALLOW_BIND_ANON_DN ))
+ {
+ /* DN is not empty, disallow */
+ rc = LDAP_UNWILLING_TO_PERFORM;
+ text = "unwilling to allow anonymous bind with non-empty DN";
+
+ } else if ( global_disallows & SLAP_DISALLOW_BIND_ANON ) {
+ /* disallow */
+ rc = LDAP_INAPPROPRIATE_AUTH;
+ text = "anonymous bind disallowed";