How to export users with passwords? The Users export module cannot help, it export without passwords.
4 Answers
User passwords are stored using a one-way hashing algorithm and cannot be converted to plaintext. In addition, each Drupal site uses a unique cryptographic salt, so that the same plaintext password on two Drupal sites will not result in the same hashed password.
In other words, there is no way to generate a list of usernames and plaintext passwords.
-
-
6With all due respect, even though this answer is correct, the salt part is a bit misleading. If you copy the password hash from site A to site B,the original password will work in both sites. However, if site A and B generated the hashes for same plaintext password separately, the hashes would be different. So basically you cannot generate a dictionary to reverse lookup password from hashes. But for import/export purposes, copy the password hash will be enough.– AKSCommented Jan 30, 2016 at 2:52
-
1@MPD i want to make my users to login on Django (python) site with the same data, So if not possible export passwords i need to set new passwords - so now users need to remember 2 passswords from 2 parts of my service wihich is bad Commented Jan 30, 2016 at 10:07
As @MPD says, you can't do this, however you can export all the users and import with a random password and use this ways to set the password:
Use the Mass Password Reset module to reset all user accounts and notify all users.
Use the Force Password Change to force users to change their password on their next login.
Reference
Generate new password for users periodically and notify user of new password
-
1Nice workaround! never heard of these modules, until now :-) Commented Jan 29, 2016 at 23:48
-
@NoSssweat I hope that this modules can help the OP Commented Jan 30, 2016 at 0:01
In very limited use cases, you really might be in need to allow certain users seeing other user's passwords. You can use the AES module.
However, for exporting these passwords you will have to write a custom module using AES module's decryption mechanisms (as the passwords won't be stored as plain text as well).
A note of warning: I strongly suggest checking, whether you really need to have users see other user's passwords. This implies a huge security impact on your site, and - as many users still use the same passwords on different web sites - on the security of your user's other profiles around the web.
Edit: After you provided some more insights on your requirements, a way to change the passwords in another application when a Drupal user sets a new password, without having to store it unhashed.
You will need to create a custom module. Implement the following hooks (replace MYMODULE with your module name):
/**
* Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
// Alter all forms that allow editing the password:
switch ($form_id) {
case 'user_register_form':
case 'user_profile_form':
// Add an own submit handler to the user forms.
$form['#submit'][] = 'MYMODULE_set_password_submit';
break;
}
}
/**
* Submit handler setting the password in the third-party application.
*/
function MYMODULE_set_password_submit($form, &$form_state) {
// Whether the password was changed.
if (!empty($form_state['values']['pass'])) {
// Get the password.
$password = $form_state['values']['pass'];
// And now you can use the contents of $password to call
// your other applications API for resetting passwords or
// hashing / setting the password using direct database
// access.
}
}
-
i want to make my users to login on Django (python) site with the same data, So if not possible export passwords i need to set new passwords - so now users need to remember 2 passswords from 2 parts of my service wihich is bad. Commented Jan 30, 2016 at 10:08
-
Added a small example on how you could achieve your required feature without having to save/export unhashed passwords. You will just need to have a way to set the passwords in your Django application from within your Drupal. (An API or direct access to its database.) Commented Jan 30, 2016 at 11:42
you just export data only (not structure and data) from users table of old database and import this to the new database. All users with password can be export this way too