diff --git a/sites/all/modules/contrib/webserver_auth/inc/webserver_auth.helpers.inc b/sites/all/modules/contrib/webserver_auth/inc/webserver_auth.helpers.inc
index e69de29..c20e25c 100644
--- a/sites/all/modules/contrib/webserver_auth/inc/webserver_auth.helpers.inc
+++ b/sites/all/modules/contrib/webserver_auth/inc/webserver_auth.helpers.inc
@@ -0,0 +1,40 @@
+<?php
+
+function webserver_auth_helper_get_authname() {
+  $authname = FALSE;
+  if (isset ($_SERVER ['REDIRECT_REMOTE_USER'])) return $_SERVER ['REDIRECT_REMOTE_USER'];
+  elseif (isset ($_SERVER ['REMOTE_USER'])) return $_SERVER ['REMOTE_USER'];
+
+  return $authname;
+}
+
+function webserver_auth_helper_authmap_sync($op = 'insert', &$account = NULL) {
+  if(empty($account)) return FALSE;
+
+  switch($op) {
+    case 'insert':
+      $authname = webserver_auth_helper_get_authname();
+      if (empty($authname)) $authname = $account->name;
+      $query = db_merge('authmap')
+          ->key(array('uid' => $account->uid))
+          ->fields(array('uid' => $account->uid, 'authname' => $authname, 'module' => 'webserver_auth'));
+
+      try {
+        $query->execute();
+      } catch (PDOException $e) {
+        watchdog('webserver_auth', 'PDOException in `webserver_auth_helper_authmap_sync($op = \'insert\', &$account = NULL)`: !exception', array('!exception' => var_export($e->getMessage())));
+      }
+      break;
+    case 'delete':
+      $query = db_delete('authmap')
+          ->condition('uid', $account->uid);
+
+      try {
+        $query->execute();
+      } catch (PDOException $e) {
+        watchdog('webserver_auth', 'PDOException in `webserver_auth_helper_authmap_sync($op = \'insert\', &$account = NULL)`: !exception', array('!exception' => var_export($e->getMessage())));
+      }
+      break;
+  }
+}
+
diff --git a/sites/all/modules/contrib/webserver_auth/webserver_auth.module b/sites/all/modules/contrib/webserver_auth/webserver_auth.module
index e3ea513..078f22b 100644
--- a/sites/all/modules/contrib/webserver_auth/webserver_auth.module
+++ b/sites/all/modules/contrib/webserver_auth/webserver_auth.module
@@ -29,10 +29,9 @@ function webserver_auth_init() {
     return;
   }
   // get the login name from the $_SERVER variable.
-  $authname = '';
-  if (isset ($_SERVER ['REDIRECT_REMOTE_USER'])) $authname = $_SERVER ['REDIRECT_REMOTE_USER'];
-  elseif (isset ($_SERVER ['REMOTE_USER'])) $authname = $_SERVER ['REMOTE_USER'];
- 
+  module_load_include('inc', 'webserver_auth', 'inc/webserver_auth.helpers');
+
+  $authname = webserver_auth_helper_get_authname();
   if ($authname)
   {
     $authname = webserver_auth_prepare_username($authname);
@@ -77,7 +76,7 @@ function webserver_auth_init() {
 function webserver_auth_attempt_login($preparedauthname)
 {
   // can we find the user in the db already?
-  $uid = db_query('SELECT uid FROM {authmap} WHERE lower(authname) = lower(:authname) AND module = :module', array (':authname' => $preparedauthname, ':module' => 'webserver_auth')) -> fetchField ();
+  $uid = db_query('SELECT uid FROM {authmap} WHERE lower(authname) = lower(:authname) AND module = :module', array (':authname' => $preparedauthname, ':module' => 'webserver_auth')) -> fetchField();
 
   if (is_numeric($uid))
   {
@@ -109,8 +108,30 @@ function webserver_auth_user_presave(&$edit, $account, $category) {
   }
 }
 
+/**
+ * Implements hook_user_insert().
+ * A user account was created.
+ *
+ * @see http://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_insert/7
+ */
 function webserver_auth_user_insert(&$edit, $account, $category) {
+  dsm('1');
   if ($code = variable_get('webserver_auth_insert', '')) eval('?>'. $code);
+  dsm('2');
+  module_load_include('inc', 'webserver_auth', 'inc/webserver_auth.helpers');
+
+  webserver_auth_helper_authmap_sync('insert', $account);
+}
+
+/**
+ * Implements hook_user_delete().
+ * Respond to user deletion.
+ *
+ * @see http://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_delete/7
+ */
+function webserver_auth_user_delete($account) {
+  module_load_include('inc', 'webserver_auth', 'inc/webserver_auth.helpers');
+  webserver_auth_helper_authmap_sync('delete', $account);
 }
 
 function webserver_auth_user_logout($account) {
