diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php
index 1806d9f297099fca21ff2647b83dcda6f99bfb86..403530ac80b96c7d4b44e43c9b5201f4fb5a77ba 100644
--- a/htdocs/core/login/functions_ldap.php
+++ b/htdocs/core/login/functions_ldap.php
@@ -55,7 +55,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
 	$login='';
 	$resultFetchUser='';
 
-	if (! empty($_POST["username"]))
+	if (!empty($_POST["username"]) || $usertotest)
 	{
 		// If test username/password asked, we define $test=false and $login var if ok, set $_SESSION["dol_loginmesg"] if ko
 		$ldaphost=$dolibarr_main_auth_ldap_host;
@@ -228,4 +228,4 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
 }
 
 
-?>
\ No newline at end of file
+?>