diff --git a/ldap_sso/ldap_sso.module b/ldap_sso/ldap_sso.module
index 5669bd0..44b2387 100644
--- a/ldap_sso/ldap_sso.module
+++ b/ldap_sso/ldap_sso.module
@@ -89,106 +89,162 @@ function ldap_sso_boot() {
  * @return false
  */
 function ldap_sso_user_login_sso() {
+
+  $detailed_watchdog_log = variable_get('ldap_help_watchdog_detail', 0);
   $auth_conf = ldap_authentication_get_valid_conf();
   $implementation = $auth_conf->ldapImplementation;
   $enabled = $auth_conf->ssoEnabled;
-  if ($enabled == TRUE) {
-    switch ($implementation) {
-      case 'mod_auth_sspi' :
-        $remote_user = FALSE;
-        if (isset($_SERVER['REMOTE_USER'])) {
-          $remote_user = $_SERVER['REMOTE_USER'];
-        }
-        elseif (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
-          $remote_user = $_SERVER['REDIRECT_REMOTE_USER'];
-        }
-        break;
 
-      case 'mod_auth_kerb' :
-        $remote_user = FALSE;
-        if (isset($_SERVER['REMOTE_USER'])) {
-          $remote_user = $_SERVER['REMOTE_USER'];
-        }
-        elseif (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
-          $remote_user = $_SERVER['REDIRECT_REMOTE_USER'];
-        }
+  if ($detailed_watchdog_log) {
+    $watchdog_tokens = array(
+      '!implementation' => $auth_conf->ldapImplementation,
+      '!enabled' => $auth_conf->ssoEnabled,
+      '!server_remote_user' => @$_SERVER['REMOTE_USER'],
+      '!server_redirect_remote_user' => @$_SERVER['REDIRECT_REMOTE_USER'],
+      '!ssoRemoteUserStripDomainName' => $auth_conf->ssoRemoteUserStripDomainName,
+      '!seamlessLogin' => $auth_conf->seamlessLogin
+    );
 
-        if ($remote_user && preg_match('/^([A-Za-z0-9_\-\.]+)@([A-Za-z0-9_\-.]+)$/',
-          $remote_user,
-          $matches)) {
-          $remote_user = $matches[1];
-          $realm = $matches[2]; // This can be used later if realms is ever supported properly
-        }
-        break;
+    watchdog(
+      'ldap_sso',
+      'ldap_sso_user_login_sso.step1: implementation: !implementation, enabled: !enabled, server_remote_user: !server_remote_user, server_redirect_remote_user: !server_redirect_remote_user, ssoRemoteUserStripDomainName: !ssoRemoteUserStripDomainName,seamlessLogin: !seamlessLogin',
+      $watchdog_tokens,
+      WATCHDOG_DEBUG
+    );
+  }
+
+
+
+  if ($enabled != TRUE) {
+    drupal_goto('user/login');
+  }
+
+  $remote_user = NULL;
+  $realm = NULL;
+  $domain = NULL;
+
+  switch ($implementation) {
+    case 'mod_auth_sspi' :
+      $remote_user = FALSE;
+      if (isset($_SERVER['REMOTE_USER'])) {
+        $remote_user = $_SERVER['REMOTE_USER'];
+      }
+      elseif (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
+        $remote_user = $_SERVER['REDIRECT_REMOTE_USER'];
       }
+      break;
 
-    if ($remote_user) {
-      if ($auth_conf->ssoRemoteUserStripDomainName) {
-        // might be in form <remote_user>@<domain> or <domain>\<remote_user>
-        $domain = NULL;
-        $exploded = preg_split('/[\@\\\\]/', $remote_user);
-        if (count($exploded) == 2) {
-          if (strpos($remote_user, '@') !== FALSE) {
-            $remote_user = $exploded[0];
-            $domain = $exploded[1];
-          }
-          else {
-            $domain = $exploded[0];
-            $remote_user = $exploded[1];
-          }
+    case 'mod_auth_kerb' :
+      $remote_user = FALSE;
+      if (isset($_SERVER['REMOTE_USER'])) {
+        $remote_user = $_SERVER['REMOTE_USER'];
+      }
+      elseif (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
+        $remote_user = $_SERVER['REDIRECT_REMOTE_USER'];
+      }
+
+      if ($remote_user && preg_match('/^([A-Za-z0-9_\-\.]+)@([A-Za-z0-9_\-.]+)$/',
+        $remote_user,
+        $matches)) {
+        $remote_user = $matches[1];
+        $realm = $matches[2]; // This can be used later if realms is ever supported properly
+      }
+      break;
+  }
+
+  if ($detailed_watchdog_log) {
+    $watchdog_tokens['!remote_user'] = $remote_user;
+    $watchdog_tokens['!realm'] = $realm;
+    watchdog('ldap_authentication', 'ldap_sso_user_login_sso.implementation: username=!remote_user, (realm=!realm) found',
+              $watchdog_tokens, WATCHDOG_DEBUG);
+  }
+
+
+  if ($remote_user) {
+    if ($auth_conf->ssoRemoteUserStripDomainName) {
+      // might be in form <remote_user>@<domain> or <domain>\<remote_user>
+      $domain = NULL;
+      $exploded = preg_split('/[\@\\\\]/', $remote_user);
+      if (count($exploded) == 2) {
+        if (strpos($remote_user, '@') !== FALSE) {
+          $remote_user = $exploded[0];
+          $domain = $exploded[1];
+        }
+        else {
+          $domain = $exploded[0];
+          $remote_user = $exploded[1];
+        }
+        if ($detailed_watchdog_log) {
+          $watchdog_tokens['!remote_user'] = $remote_user;
+          $watchdog_tokens['!domain'] = $domain;
+          watchdog('ldap_authentication', 'ldap_sso_user_login_sso.stripdomain: remote_user=!remote_user, domain=!domain',$watchdog_tokens, WATCHDOG_DEBUG);
         }
       }
-      watchdog('ldap_authentication', '%username : $_SERVER[\'REMOTE_USER\'] found',
-              array('%username' => $remote_user), WATCHDOG_DEBUG);
-      $fake_form_state = array(
-        'values' => array(
-          'name' => check_plain($remote_user),
-         'pass' => user_password(20),
-        ),
-        'sso_login' => TRUE,
-      );
-      $user = ldap_authentication_user_login_authenticate_validate(array(), $fake_form_state);
-      if ($user && $user->uid > 0) {
-        if ($auth_conf->seamlessLogin == 1) {
-          setcookie("seamless_login", 'auto login', time() + $auth_conf->cookieExpire, base_path(), "");
-          $_SESSION['seamless_login'] = 'auto login';
-          setcookie("seamless_login_attempted", '');
-          unset($_SESSION['seamless_login_attempted']);
+    }
+
+    if ($detailed_watchdog_log) {
+      $watchdog_tokens['!remote_user'] = $remote_user;
+      $watchdog_tokens['!realm'] = $realm;
+      $watchdog_tokens['!domain'] = $domain;
+      watchdog('ldap_authentication', 'ldap_sso_user_login_sso.remote_user: username=!remote_user, (realm=!realm, domain=!domain) found', $watchdog_tokens, WATCHDOG_DEBUG);
+    }
+    $fake_form_state = array(
+      'values' => array(
+        'name' => check_plain($remote_user),
+        'pass' => user_password(20),
+      ),
+      'sso_login' => TRUE,
+    );
+    $user = ldap_authentication_user_login_authenticate_validate(array(), $fake_form_state);
 
+    if ($detailed_watchdog_log) {
+      $watchdog_tokens['!uid'] = is_object($user) ? $user->uid : NULL;
+      watchdog('ldap_authentication', 'ldap_sso_user_login_sso.remote_user: uid of user=!uid', $watchdog_tokens, WATCHDOG_DEBUG);
+    }
+
+    if ($user && $user->uid > 0) {
+      if ($auth_conf->seamlessLogin == 1) {
+        if ($detailed_watchdog_log) {watchdog('ldap_authentication', 'ldap_sso_user_login_sso.remote_user.user_success.seemlessLogin', $watchdog_tokens, WATCHDOG_DEBUG);}
+        setcookie("seamless_login", 'auto login', time() + $auth_conf->cookieExpire, base_path(), "");
+        $_SESSION['seamless_login'] = 'auto login';
+        setcookie("seamless_login_attempted", '');
+        unset($_SESSION['seamless_login_attempted']);
       }
       drupal_set_message(theme('ldap_authentication_login_message',
-                                  array('message' => t('You have been successfully authenticated'))));
+                                array('message' => t('You have been successfully authenticated'))));
+      if ($detailed_watchdog_log) {watchdog('ldap_authentication', 'ldap_sso_user_login_sso.remote_user.user_success.drupal_goto front', $watchdog_tokens, WATCHDOG_DEBUG);}
       drupal_goto('<front>');
-      }
-      else {
-        if ($auth_conf->seamlessLogin == 1) {
-          setcookie("seamless_login", 'do not auto login', time() + $auth_conf->cookieExpire, base_path(), "");
-          $_SESSION['seamless_login'] = 'do not auto login';
-      }
-      drupal_set_message(theme('ldap_authentication_message_not_found',
-          array('message' => t('Sorry, your LDAP credentials were not found, ' .
-          'or the LDAP server is not available. You may log in ' .
-           'with other credentials on the !user_login_form.',
-            array('!user_login_form' => l(t('user login form'), 'user/login'))))
-        ), 'error');
-      drupal_goto('user/login');
-      }
     }
     else {
-      watchdog('ldap_authentication', '$_SERVER[\'REMOTE_USER\'] not found', array(), WATCHDOG_DEBUG);
       if ($auth_conf->seamlessLogin == 1) {
+        if ($detailed_watchdog_log) {watchdog('ldap_authentication', 'ldap_sso_user_login_sso.remote_user.user_fail.seamlessLogin', $watchdog_tokens, WATCHDOG_DEBUG);}
         setcookie("seamless_login", 'do not auto login', time() + $auth_conf->cookieExpire, base_path(), "");
         $_SESSION['seamless_login'] = 'do not auto login';
       }
-      drupal_set_message(theme('ldap_authentication_message_not_authenticated',
-        array('message' =>
-        t('You were not authenticated by the server.
-        You may log in with your credentials below.')
-        )
+      drupal_set_message(theme('ldap_authentication_message_not_found',
+          array('message' => t('Sorry, your LDAP credentials were not found, ' .
+          'or the LDAP server is not available. You may log in ' .
+           'with other credentials on the !user_login_form.',
+            array('!user_login_form' => l(t('user login form'), 'user/login'))))
         ), 'error');
+      if ($detailed_watchdog_log) {watchdog('ldap_authentication', 'ldap_sso_user_login_sso.remote_user.user_fail.drupal_goto user/logint', $watchdog_tokens, WATCHDOG_DEBUG);}
       drupal_goto('user/login');
     }
   }
-  else
+  else {
+    watchdog('ldap_authentication', '$_SERVER[\'REMOTE_USER\'] not found', array(), WATCHDOG_DEBUG);
+    if ($auth_conf->seamlessLogin == 1) {
+      setcookie("seamless_login", 'do not auto login', time() + $auth_conf->cookieExpire, base_path(), "");
+      $_SESSION['seamless_login'] = 'do not auto login';
+      if ($detailed_watchdog_log) {watchdog('ldap_authentication', 'ldap_sso_user_login_sso.no_remote_user.seamlessLogin', $watchdog_tokens, WATCHDOG_DEBUG);}
+    }
+    drupal_set_message(theme('ldap_authentication_message_not_authenticated',
+      array('message' =>
+      t('You were not authenticated by the server.
+      You may log in with your credentials below.')
+      )
+      ), 'error');
+    if ($detailed_watchdog_log) {watchdog('ldap_authentication', 'ldap_sso_user_login_sso.no_remote_user.drupal_goto user/login', $watchdog_tokens, WATCHDOG_DEBUG);}
     drupal_goto('user/login');
+  }
 }
