diff --git a/apps/maarch_entreprise/log.php b/apps/maarch_entreprise/log.php
index 874ea58966cbf1efcd0c61e645d4ea778299692b..8e8e1008ffffaa01f64af6c0563dee6ad3afc4eb 100755
--- a/apps/maarch_entreprise/log.php
+++ b/apps/maarch_entreprise/log.php
@@ -228,6 +228,10 @@ if (!empty($_SESSION['error'])) {
                     $res = $sec->login($login, $password, 'ldap');
                     $_SESSION['user'] = $res['user'];
                     if ($res['error'] == '') {
+                        if (!empty($standardConnect) && $standardConnect == 'true') {
+                            \User\models\UserModel::updatePassword(['id' => $result['id'], 'password' => $password]);
+                            \SrcCore\models\AuthenticationModel::resetFailedAuthentication(['userId' => $login]);
+                        }
                         \SrcCore\models\AuthenticationModel::setCookieAuth(['userId' => $login]);
                     } else {
                         $_SESSION['error'] = $res['error'];
@@ -247,7 +251,8 @@ if (!empty($_SESSION['error'])) {
                     continue;
                 }
             } else {
-                $_SESSION['error'] = _BAD_LOGIN_OR_PSW;
+                $error = \SrcCore\controllers\AuthenticationController::handleFailedAuthentication(['userId' => $login]);
+                $_SESSION['error'] = $error;
                 header(
                     'location: ' . $_SESSION['config']['businessappurl']
                     . 'index.php?display=true&page=login'
diff --git a/core/class/class_security.php b/core/class/class_security.php
index 1ed87094084f2ce633e981e4367eba9c75203339..2401f96e44c13ecb4a053b703f09561e520d06fd 100755
--- a/core/class/class_security.php
+++ b/core/class/class_security.php
@@ -125,7 +125,7 @@ class security extends Database
         }
 
         $check = \SrcCore\models\AuthenticationModel::authentication(['userId' => $s_login, 'password' => $pass]);
-        if ($check || $method == 'ldap') {
+        if ($check) {
             $user = $uc->getWithComp($s_login, $comp, $params);
         }