diff -Naur /home/stevep/build/webserver_auth_cvs/webserver_auth/webserver_auth.module webserver_auth/webserver_auth.module
--- webserver_auth/webserver_auth.module	2008-04-21 12:43:26.000000000 -0400
+++ webserver_auth/webserver_auth.module	2008-07-18 18:05:00.000000000 -0400
@@ -52,12 +52,22 @@
       // try to log into Drupal. if unsuccessful, register the user
       $test_user = user_external_load($account->name);
       if (!$test_user->uid) {
-        if (variable_get("user_register", 1) == 1) {
-          $user_default = array("name" => $account->name, "pass" => "cyan", "init" => db_escape_string($name), "authname_webserver_auth" => $account->name, "status" => 1, "roles" => array(DRUPAL_AUTHENTICATED_RID));
-          // TODO - the hook_user('register') will fire but only for loaded modules. could be a problem for sites using page cache and that hook+operation
-          $user = user_save("", array_merge($user_default, (array)$account));
-          watchdog("user", "new user: $user->name (webserver_auth)", l(t("edit user"), "admin/user/edit/$user->uid"));
-        }
+        // This is a special case that usually occurs when webserver auth is first being turned on.
+        // This will only occur if there isn't an authmap entry for an existing user whose account
+        // is the same as the external auth username.
+        $test_existing_user = user_load(array('name' => $account->name));
+        if($test_existing_user->uid){
+          watchdog("user", "mapped existing user to external user: $user->name (webserver_auth)", l(t("edit user"), "admin/user/edit/$user->uid"));
+	  user_save($test_existing_user, array('authname_webserver_auth' => $account->name));
+	  $user = $test_existing_user;
+        }else{
+          if (variable_get("user_register", 1) == 1) {
+            $user_default = array("name" => $account->name, "pass" => "cyan", "init" => db_escape_string($name), "authname_webserver_auth" => $account->name, "status" => 1, "roles" => array(DRUPAL_AUTHENTICATED_RID));
+            // TODO - the hook_user('register') will fire but only for loaded modules. could be a problem for sites using page cache and that hook+operation
+            $user = user_save("", array_merge($user_default, (array)$account));
+            watchdog("user", "new user: $user->name (webserver_auth)", l(t("edit user"), "admin/user/edit/$user->uid"));
+          }
+	}
       }
       else{
         $user = $test_user;
