diff --git a/www/auth/login.php b/www/auth/login.php
index df69a8787f388f328947fafb366b412faa7c2da1..d10af1a6060461d2fb3d82946f962bb4925299e2 100644
--- a/www/auth/login.php
+++ b/www/auth/login.php
@@ -96,7 +96,7 @@ if (isset($_POST['username'])) {
 		/*
 		 * Do LDAP bind using DN.
 		 */
-		if (!$ldap->bind($dn, $password)) {
+		if (($pwd == "") or (!$ldap->bind($dn, $pwd))) {
 			SimpleSAML_Logger::info('AUTH - ldap: '. $username . ' failed to authenticate. DN=' . $dn);
 			throw new Exception('error_wrongpassword');
 		}