diff --git a/ldap_authentication/ldap_authentication.inc b/ldap_authentication/ldap_authentication.inc
index 2eea661..9e59a26 100644
--- a/ldap_authentication/ldap_authentication.inc
+++ b/ldap_authentication/ldap_authentication.inc
@@ -449,7 +449,7 @@ function ldap_authentication_test_credentials($auth_conf, $sso_login, $authname,
     if ($ldap_server->bind_method == LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT ||
         $ldap_server->bind_method == LDAP_SERVERS_BIND_METHOD_ANON_USER
         ) {
-      $bind_success = ($ldap_server->bind() == LDAP_SUCCESS);
+      $bind_success = ($ldap_server->bind(NULL, NULL, FALSE) == LDAP_SUCCESS);
     }
     elseif ($ldap_server->bind_method == LDAP_SERVERS_BIND_METHOD_ANON) {
       $bind_success = ($ldap_server->bind(NULL, NULL, TRUE) == LDAP_SUCCESS);
@@ -464,7 +464,7 @@ function ldap_authentication_test_credentials($auth_conf, $sso_login, $authname,
         $transformname =  $ldap_server->userUsernameToLdapNameTransform($authname, $watchdog_tokens);
         $replace = array($basedn, $transformname);
         $userdn = str_replace($search, $replace, $ldap_server->user_dn_expression);
-        $bind_success = ($ldap_server->bind($userdn, $password) == LDAP_SUCCESS);
+        $bind_success = ($ldap_server->bind($userdn, $password, FALSE) == LDAP_SUCCESS);
         if ($bind_success) {
           break;
         }
@@ -545,7 +545,7 @@ function ldap_authentication_test_credentials($auth_conf, $sso_login, $authname,
       $credentials_pass = (boolean)($ldap_user);
     }
     else {
-      $credentials_pass = ($ldap_server->bind($ldap_user['dn'], $password) == LDAP_SUCCESS);
+      $credentials_pass = ($ldap_server->bind($ldap_user['dn'], $password, FALSE) == LDAP_SUCCESS);
     }
     if (!$credentials_pass) {
       if ($detailed_watchdog_log) {
diff --git a/ldap_servers/LdapServer.class.php b/ldap_servers/LdapServer.class.php
index 81f87b1..da691f3 100644
--- a/ldap_servers/LdapServer.class.php
+++ b/ldap_servers/LdapServer.class.php
@@ -288,7 +288,11 @@ class LdapServer {
       watchdog('ldap', "LDAP bind failure for user %user. Not connected to LDAP server.", array('%user' => $userdn));
       return LDAP_CONNECT_ERROR;
     }
-    if ($anon_bind) {
+    
+    if ($anon_bind !== FALSE && $userdn === NULL && $pass === NULL && $this->bind_method == LDAP_SERVERS_BIND_METHOD_ANON) {
+      $anon_bind = TRUE;
+    }
+    if ($anon_bind === TRUE) {
       if (@!ldap_bind($this->connection)) {
         if ($this->detailedWatchdogLog) {
           watchdog('ldap', "LDAP anonymous bind error. Error %errno: %error", array('%errno' => ldap_errno($this->connection), '%error' => ldap_error($this->connection)));
@@ -299,6 +303,11 @@ class LdapServer {
     else {
       $userdn = ($userdn != NULL) ? $userdn : $this->binddn;
       $pass = ($pass != NULL) ? $pass : $this->bindpw;
+      
+      if (drupal_strlen($pass) == 0 || drupal_strlen($userdn) == 0) {
+        watchdog('ldap', "LDAP bind failure for user userdn=%userdn, pass=%pass.", array('%userdn' => $userdn, '%pass' => $pass));
+        return LDAP_LOCAL_ERROR;
+      }
       if (@!ldap_bind($this->connection, $userdn, $pass)) {
         if ($this->detailedWatchdogLog) {
           watchdog('ldap', "LDAP bind failure for user %user. Error %errno: %error", array('%user' => $userdn, '%errno' => ldap_errno($this->connection), '%error' => ldap_error($this->connection)));
diff --git a/ldap_servers/ldap_servers.test_form.inc b/ldap_servers/ldap_servers.test_form.inc
index c56aa4a..ef2976c 100644
--- a/ldap_servers/ldap_servers.test_form.inc
+++ b/ldap_servers/ldap_servers.test_form.inc
@@ -262,7 +262,7 @@ function ldap_servers_test_form_submit($form, &$form_state) {
     }
     $results_tables['basic'][] = array(t('Binding with DN (%bind_dn).  Using supplied password ',
       array('%bind_dn' =>  $ldap_user['dn'])));
-    $result = $ldap_server->bind($ldap_user['dn'], $values['testing_drupal_userpw']);
+    $result = $ldap_server->bind($ldap_user['dn'], $values['testing_drupal_userpw'], FALSE);
     if ($result == LDAP_SUCCESS) {
       $results_tables['basic'][] = array(t('Successfully bound to server'), 'PASS');
     }
@@ -359,7 +359,7 @@ function ldap_servers_test_binding_credentials(&$ldap_server, $bindpw, &$results
   }
 
   if (!$errors) {
-    $bind_result = $ldap_server->bind($ldap_server->binddn, $bindpw);
+    $bind_result = $ldap_server->bind($ldap_server->binddn, $bindpw, FALSE);
     if ($bind_result == LDAP_SUCCESS) {
       $results_tables['basic'][] =  array(t('Successfully bound to server'));
     }
