Index: webserver_auth-DRUPAL-6--1/webserver_auth.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webserver_auth/Attic/webserver_auth.module,v
retrieving revision 1.22.2.1
diff -u -p -r1.22.2.1 webserver_auth.module
--- webserver_auth-DRUPAL-6--1/webserver_auth.module	7 Aug 2008 16:38:49 -0000	1.22.2.1
+++ webserver_auth-DRUPAL-6--1/webserver_auth.module	24 Dec 2009 19:04:56 -0000
@@ -16,6 +16,20 @@ function webserver_auth_menu() {
   return $items;
 }
 
+function webserver_auth_prettify_authname($authname) {
+    $authname = trim($authname);
+    // Pretty up the username for NTLM authentication (i.e. Windows)
+    if (variable_get('webserver_auth_strip_prefix', TRUE)) {
+      // Get 'bar' from 'foo1\foo2\bar'
+      $authname = array_pop(explode("\\", $authname));
+    }
+    if (variable_get('webserver_auth_strip_domain', TRUE)) {
+      // Get 'foo' from 'foo@bar'
+      $authname = array_shift(explode('@', $authname));
+    }
+    return $authname;
+}
+
 /**
  * Implementation of hook_init().
  */
@@ -37,6 +51,7 @@ function webserver_auth_init() {
   unset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
 
   // Retrieve user credentials
+  $authname = webserver_auth_prettify_authname($authname);
   $result = db_query("SELECT uid FROM {authmap} WHERE authname = '%s' AND module = 'webserver_auth'", $authname);
   $expected = db_fetch_array($result);
 
@@ -64,16 +79,7 @@ function webserver_auth_init() {
  */
 function webserver_auth_user($op, &$edit, &$account, $category = NULL) {
   if ($op == 'insert' && $category = 'account') {
-    $account->name = trim($account->name);
-    // Pretty up the username for NTLM authentication (i.e. Windows)
-    if (variable_get('webserver_auth_strip_prefix', TRUE)) {
-      // Get 'bar' from 'foo1\foo2\bar'
-      $account->name = array_pop(explode("\\", $account->name));
-    }
-    if (variable_get('webserver_auth_strip_domain', TRUE)) {
-      // Get 'foo' from 'foo@bar'
-      $account->name = array_shift(explode('@', $account->name));
-    }
+    $account->name = webserver_auth_prettify_authname($account->name);
     db_query("UPDATE {users} SET name = '%s' WHERE uid = %d", $account->name, $account->uid);
     // Generate an e-mail address automagically
     if ($domain = variable_get('webserver_auth_email_domain', '')) {
