How to force users password change weekly?

How to force users password change weekly?

by Mario Gonzalez -
Number of replies: 5
Hi all,

I am trying to force all users to change thier password every week, but I only could force them to change it at their first loggin.

It is possible to force a password change periodically?

Thanks.
Average of ratings: -
In reply to Mario Gonzalez

Re: How to force users password change weekly?

by Aaron Wells -
I think, out of Moodle 1.9's authentication modules, only the LDAP module has a setting for periodic password expiration (and that's mostly just support for a normal LDAP server's password expiration feature).

If you're using the Manual authentication plugin, you could write a cron job to do this. You'd need to do something like the following:

1. Update the Manual auth plugin's "user_update_password()" function so that it records the time when a user's password is updated (probably recorded either as a user preference using set_user_preference(), or as a custom profile field)

2. Create a local cron job by creating a file called local/cron.php. In this cron job, search the database for users whose last password change date is greater than 7 days. Mark them for a password reset by calling set_user_preference('auth_forcepasswordchange', 1, $userid).

3. Also in the local cron job, check for users who don't have a last password change date set, and fill in the present time as their last password change date.

Cheers,
Aaron
In reply to Aaron Wells

Re: How to force users password change weekly?

by Mario Gonzalez -
Really tanks Aaron for your help. It works perfectly.

I´m using the Manual authentication plugin so I had to create a new cron.php and launch it with a schedule task.



In reply to Aaron Wells

Re: How to force users password change weekly?

by Clara MG -

Would it work for self registration accounts by email? Thanks in advance.

In reply to Mario Gonzalez

Re: How to force users password change weekly?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Forcing users to change their passwords every week seems over the top. What are you trying to achieve, other than annoying your users?
In reply to Tim Hunt

Re: How to force users password change weekly?

by Mario Gonzalez -
This is not my decision, I told the same to the client, but he decides. At Least finally the password changes monthly.