I'm in the process of leaving my current job, and that requires that all of my accounts be disabled. Well, some of those accounts are user 1 accounts in a few of our Drupal sites. Is it possible to just "transfer" user 1 to another account?
-
2I think if you change the email id associated with the account to the new user email id and set a temporary password for the new person to login it should be good.– junedkaziCommented Jan 10, 2013 at 19:13
-
it's really easy as that... and don't forget to opt out for update notifications! I had to configure several Gmail filters to get rid of these.– AKSCommented Jan 10, 2013 at 19:35
2 Answers
As others have said, the user account with ID equal to 1 is a special account: It is one of the default accounts created by Drupal during its installation, and it is the only account to which every permission is assigned. (See @Clive's answer.)
What can be done is changing the password, and the email associated with that account.
Create a file in the same directory containing index.php, and add the following code.
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$account = user_load(1);
$edit = array(
'pass' => 'New password';
'mail' => 'New email';
);
user_save($account, $edit);
With this code, everybody with access to the filesystem of the server can change the password, and the email of the user #1. I am not suggesting to change the password directly in the database because the password in clear; Drupal saves the hash obtained from user_hash_password(), whenever user_hash_password()
is the function implemented by Drupal, or from third-party modules.
If Drush is available, changing the password is even easier. Everybody could execute the following command:
drush user-password <username> --password="<password>"
Not as such, no. The user_access()
function (which is invoked for most, if not all, access checks) has these lines in it:
// User #1 has all privileges:
if ($account->uid == 1) {
return TRUE;
}
It explicitly checks for a user ID of 1, and bypasses any further checks based on that. The only way to simulate the same behaviour is to assign all system permissions to a role that another account has.
The easiest thing to do would just be to update the the user 1 accounts with the new admin's details as junedkazi suggests in the comments.