--- tcllib/modules/sasl/gtoken.tcl.orig	2006-04-26 13:05:11.000000000 +0400
+++ tcllib/modules/sasl/gtoken.tcl	2007-08-15 20:10:56.000000000 +0400
@@ -49,16 +49,20 @@
         foreach line [split [http::data $tok] \n] {
             array set g [split $line =]
         }
-        set query [http::formatQuery SID $g(SID) LSID $g(LSID) \
-                       service mail Session true]
-        set tok2 [http::geturl $URLb -query $query -timeout 30000]
+        if {![info exists g(Error)]} {
+            set query [http::formatQuery SID $g(SID) LSID $g(LSID) \
+                           service mail Session true]
+            set tok2 [http::geturl $URLb -query $query -timeout 30000]
 
-        if {[http::status $tok2] eq "ok"} {
-            set reply "\0$username\0[http::data $tok2]"
-        } else {
-            set err [http::error $tok2]
-        }
-        http::cleanup $tok2
+            if {[http::status $tok2] eq "ok"} {
+                set reply "\0$username\0[http::data $tok2]"
+            } else {
+                set err [http::error $tok2]
+            }
+            http::cleanup $tok2
+       } else {
+           set err "Invalid username or password"
+       }
     } else {
         set err [http::error $tok]
     }
