Is it possible to force existing users to change their passwords? I'd like to make all students, teachers, etc change their passwords to meet new complexity requirements.
Thanks
Force existing users to change password
Number of replies: 1Re: Force existing users to change password
I'm pretty sure this is Moodle version specific so as always, your mileage may vary. I've tested the following process on Moodle version 1.9.4+ (Build: 20090429) with all the user accounts created under that version of Moodle.
When a user account is created, Moodle inserts entries in a variety of tables including the mdl_user_preferences table. If you look at the contents of this table you will notice rows that include a few preferences assigned to a userid. See the table below.
+----+--------+--------------------------+-------+
| id | userid | name | value |
+----+--------+--------------------------+-------+
| 1 | 2 | auth_forcepasswordchange | 0 |
| 2 | 2 | email_bounce_count | 1 |
| 3 | 2 | email_send_count | 1 |
| 4 | 3 | auth_forcepasswordchange | 1 |
| 5 | 3 | email_bounce_count | 1 |
| 6 | 3 | email_send_count | 1 |
Notice the row with "auth_forcepasswordchange" ? The value of "0" is not enabled and the value of "1" is enabled. I confirmed in the Moodle interface that the user account with the value of "1" set is required to change their password on next login.
Based on this research I concluded that by issuing the following SQL query you would be able to force all users on the system to update their password. Again, I believe this is heavily dependant on your version of Moodle and may not work for user accounts created in previous versions or different versions of Moodle. This will force ALL users including the admin user to update on next login.
Backup your production database and be sure you can restore it before trying this !!!
UPDATE mdl_user_preferences SET value='1' WHERE name='auth_forcepasswordchange';
Hope this helps.
When a user account is created, Moodle inserts entries in a variety of tables including the mdl_user_preferences table. If you look at the contents of this table you will notice rows that include a few preferences assigned to a userid. See the table below.
+----+--------+--------------------------+-------+
| id | userid | name | value |
+----+--------+--------------------------+-------+
| 1 | 2 | auth_forcepasswordchange | 0 |
| 2 | 2 | email_bounce_count | 1 |
| 3 | 2 | email_send_count | 1 |
| 4 | 3 | auth_forcepasswordchange | 1 |
| 5 | 3 | email_bounce_count | 1 |
| 6 | 3 | email_send_count | 1 |
Notice the row with "auth_forcepasswordchange" ? The value of "0" is not enabled and the value of "1" is enabled. I confirmed in the Moodle interface that the user account with the value of "1" set is required to change their password on next login.
Based on this research I concluded that by issuing the following SQL query you would be able to force all users on the system to update their password. Again, I believe this is heavily dependant on your version of Moodle and may not work for user accounts created in previous versions or different versions of Moodle. This will force ALL users including the admin user to update on next login.
Backup your production database and be sure you can restore it before trying this !!!
UPDATE mdl_user_preferences SET value='1' WHERE name='auth_forcepasswordchange';
Hope this helps.