diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php
index 5886101..51b2dff 100644
--- a/auth/ldap/auth.php
+++ b/auth/ldap/auth.php
@@ -1866,17 +1866,20 @@ class auth_plugin_ldap extends auth_plugin_base {
                     ? $_SERVER['HTTP_REFERER'] : NULL;
             }
 
+            // Make sure we don't drop the auto login guest 'hint'
+            $loginguest = optional_param('loginguest', 0, PARAM_BOOL) ? '&loginguest=true' : '';
+
             // Now start the whole NTLM machinery.
             if(!empty($this->config->ntlmsso_ie_fastpath)) {
                 // Shortcut for IE browsers: skip the attempt page at all
                 if(check_browser_version('MSIE')) {
                     $sesskey = sesskey();
-                    redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_magic.php?sesskey='.$sesskey);
+                    redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_magic.php?sesskey='.$sesskey.$loginguest);
                 } else {
-                    redirect($CFG->httpswwwroot.'/login/index.php?authldap_skipntlmsso=1');
+                    redirect($CFG->httpswwwroot.'/login/index.php?authldap_skipntlmsso=1'.$loginguest);
                 }
             } else {
-                redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_attempt.php');
+                redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_attempt.php'.$loginguest);
             }
         }
  
diff --git a/auth/ldap/ntlmsso_attempt.php b/auth/ldap/ntlmsso_attempt.php
index 2278896..fa5fb9a 100644
--- a/auth/ldap/ntlmsso_attempt.php
+++ b/auth/ldap/ntlmsso_attempt.php
@@ -2,6 +2,9 @@
 
 require_once(dirname(dirname(dirname(__FILE__)))."/config.php");
 
+// Make sure we don't drop the auto login guest 'hint'
+$loginguest = optional_param('loginguest', 0, PARAM_BOOL);
+
 //HTTPS is potentially required in this page
 httpsrequired();
 
@@ -31,11 +34,12 @@ $navlinks = array(array('name' => $loginsite, 'link' => null, 'type' => 'misc'))
 $navigation = build_navigation($navlinks);
 print_header("$site->fullname: $loginsite", $site->fullname, $navigation, '', '', true);
 
+$loginguest = $loginguest ? '&loginguest=true' : '';
 $msg = '<p>'.get_string('ntlmsso_attempting','auth').'</p>'
     . '<img width="1", height="1" '
     . ' src="' . $CFG->wwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey='
     . $sesskey . '" />';
-redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_finish.php', $msg, 3);
+redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_finish.php'.$loginguest, $msg, 3);
 
 
 
diff --git a/auth/ldap/ntlmsso_finish.php b/auth/ldap/ntlmsso_finish.php
index 4720e11..24e9c1c 100644
--- a/auth/ldap/ntlmsso_finish.php
+++ b/auth/ldap/ntlmsso_finish.php
@@ -2,6 +2,9 @@
 
 require_once(dirname(dirname(dirname(__FILE__)))."/config.php");
 
+// Make sure we don't drop the auto login guest 'hint'
+$loginguest = optional_param('loginguest', 0, PARAM_BOOL);
+
 //HTTPS is potentially required in this page
 httpsrequired();
 
@@ -30,7 +33,8 @@ if (!$authplugin->ntlmsso_finish()) {
     $navlinks = array(array('name' => $loginsite, 'link' => null, 'type' => 'misc'));
     $navigation = build_navigation($navlinks);
     print_header("$site->fullname: $loginsite", $site->fullname, $navigation, '', '', true);
-    redirect($CFG->httpswwwroot . '/login/index.php?authldap_skipntlmsso=1', 
+    $loginguest = $loginguest ? '&loginguest=true' : '';
+    redirect($CFG->httpswwwroot . '/login/index.php?authldap_skipntlmsso=1'.$loginguest, 
              get_string('ntlmsso_failed','auth'), 3);
 }
 ?>

