how can I force reset the passowrd after every 30 days

sunnysunny
Kilo Contributor

Can anyone please explain me in detail , I couldnot followed the wiki .

1 ACCEPTED SOLUTION

Sunny,



var gr = new GlideRecord('sys_user');


//The below query will reset the password for all users whose date of password is dated more than 20 days before.Change accordingly.


gr.addQuery('u_date_of_password','<','gs.daysAgo(-20))');


gr.query();


while (gr.next())


{


    gr.password_needs_reset = true;


    gr.update();


}


View solution in original post

16 REPLIES 16

Hi Sunny,



As noted earlier, you can do this without any scripting if you use the update set I created.



When ever there is a scriptless solution and a scripted solution - take the scriptless approach. It's easier to create and maintain (for you and for others.)


Chuck Tomasi
Tera Patron

Here's how I would approach it.


  • Create a date field on the user table (sys_user) to track when the last time they changed their password.
    • Hint: use a business rule that triggers on change of the password field then updates this date field.
  • Use my Scriptless Scheduled Jobs update set to filter on records where that date is > 30 days ago (and the password needs reset field is false), then set the Password needs reset field to true.


Pretty quick and easy. Next time the person logs in, they get prompted to change their password and the date resets. If they choose to reset their password before the expiration, same thing.


Orthogonal to this discussion, but... is there anywhere a password policy can be set (expiry, warning, min/max age, lockout threshold, etc)?


Thank you alot .. your comments is to the point 🙂

As a followup, the Scriptless scheduled jobs add-on was a stop-gap measure before we got Flow Designer. When it comes to making easy-to-manage scheduled jobs, please look at Flow Designer first!

Flow Designer | ServiceNow Docs