diff --git a/openid_provider.module b/openid_provider.module
index 40e0ab7..0134bca 100644
--- a/openid_provider.module
+++ b/openid_provider.module
@@ -106,10 +106,11 @@ function openid_provider_user($op, &$edit, &$account, $category = NULL) {
   switch ($op) {
     case 'insert':
     case 'update':
+      // Use the username to automatically create an alias, unless the user has
+      // the site root configured for an alias.
       $src = openid_provider_user_path($account->uid);
-      if (module_exists('pathauto')) {
+      if ($src && module_exists('pathauto')) {
         module_load_include('inc', 'pathauto');
-        // Use the username to automatically create an alias
         $pathauto_user = (object) array_merge((array) $account, $edit);
         if ($account->name) {
           $placeholders = pathauto_get_placeholders('user', $pathauto_user);
@@ -120,10 +121,13 @@ function openid_provider_user($op, &$edit, &$account, $category = NULL) {
       cache_clear_all($src, 'cache_page', FALSE);
       break;
     case 'delete':
-      // If the user is deleted, remove the path aliases
+      // If the user is deleted, remove the path aliases (if not site root).
       if (module_exists('pathauto')) {
         $account = (object) $account;
-        path_set_alias(openid_provider_user_path($account->uid));
+        $src = openid_provider_user_path($account->uid);
+        if ($src) {
+          path_set_alias($src);
+        }
       }
       break;
     case 'view':
@@ -174,6 +178,12 @@ function openid_provider_user_path($uid) {
   if (is_object($uid)) {
     $uid = $uid->uid;
   }
+  if ($uid == variable_get('openid_provider_root_user', -1) ) {
+    // Return site root, if that is configured for a specific user.
+    // (If this function is inadvertantly called for an anonymous user,
+    // it seems better not to return the root - so the default value is -1.)
+    return '';
+  }
   return sprintf('user/%s/identity', $uid);
 }
 
@@ -231,6 +241,36 @@ function openid_provider_admin_settings() {
     '#default_value' => @implode(PHP_EOL, variable_get('openid_provider_blacklist', array())),
     '#description' => t('Sites on this list will be completely forbidden to login through the OpenID provider. Enter one site per line with the full URL e.g. <em>http://www.example.com/</em>. The blacklist has precendence over the whitelist, that is: sites also on the whitelist will be considered blacklisted.'),
   );
+
+  $rootuser = variable_get('openid_provider_root_user', -1);
+  if ($rootuser == -1) {
+    // Display empty sting as #default_value.
+    $rootuser = '';
+  }
+  // The variable holds a User ID (which influences output of
+  // openid_provider_user_path()). Display as name if possible. If not found,
+  // display the original value, which will throw a validation error.
+  elseif (is_numeric($rootuser) && $rootuser > 0) {
+    // Display userID as name.
+    $username = db_result(db_query("SELECT name FROM {users} WHERE uid=%d", $rootuser));
+    if ($username) {
+      $rootuser = $username;
+    }
+  }
+  $rootpath = preg_replace('|https?://(.+)/|', '$1', openid_provider_url(''));
+  $form['openid_provider_root_user'] = array(
+    '#type' => 'textfield',
+    '#title' => t('User having site root as OpenID'),
+    '#default_value' => $rootuser,
+    '#autocomplete_path' => 'user/autocomplete',
+    '#size' => '18',
+    '#description' => t("<p>The OpenID (identity path) for users on this site is of the form %userpath. One user can use the 'site root' (%rootpath) instead.</p>
+      <p>It is usually not necessary to set this, but it's applicable for someone who is already using this 'site root' as their identity path, and is switching to this Drupal module for an identity provider.</p>
+      <p>Leave empty to not enable this option for any user.</p>",
+      array('%userpath' => openid_provider_user_path('%user'), '%rootpath' => $rootpath)),
+  );
+
+  $form['#validate'][] = 'openid_provider_admin_settings_validate';
   return system_settings_form($form);
 }
 
@@ -249,6 +289,16 @@ function openid_provider_admin_settings_validate($form, &$form_state) {
     $sites = preg_split( '/\r\n|\r|\n/', $form_state['values']['openid_provider_blacklist']);
   }
   $form_state['values']['openid_provider_blacklist'] = $sites;
+
+  if (!empty($form_state['values']['openid_provider_root_user'])) {
+    // Convert name in textbox to userID.
+    if ($uid = db_result(db_query("SELECT uid FROM {users} WHERE name='%s'", $form_state['values']['openid_provider_root_user']))) {
+      $form_state['values']['openid_provider_root_user'] = $uid;
+    }
+    else {
+      form_set_error('openid_provider_root_user', 'Invalid username');
+    }
+  }
 }
 
 /**
@@ -412,7 +462,7 @@ function openid_provider_pathauto_bulkupdate() {
   while ($user = db_fetch_object($result)) {
     $placeholders = pathauto_get_placeholders('user', $user);
     $src = openid_provider_user_path($user->uid);
-    if ($alias = pathauto_create_alias('openid_provider', 'bulkupdate', $placeholders, $src, $user->uid)) {
+    if ($src && pathauto_create_alias('openid_provider', 'bulkupdate', $placeholders, $src, $user->uid)) {
       $count++;
     }
   }
