2

As the title says, if i use the System.setPassword() method to set the password for a user (as an admin), does the password expiry still count from when the user did the change on the UI or does it start counting from when the setPassword() method changed the Password ?

I want to be able to test this out without waiting for a users password to expire over 30 days. Is there a way ?

2
  • Side note: it's bad security practice to expire passwords (1, 2, 3), especially so quickly. It will encourage users to choose a simple password with an increasing number appended. Or worse, write down their passwords on sticky notes.
    – marcelm
    Commented Aug 7 at 10:50
  • Yes, that's true. This is a situation in a sandbox where our Learning and Development conduct trainings on mocked data. They 'own' multiple logins and wanted a way to set passwords in bulk. Since most of these logins are created at the same time, they tend to expire at the same time as well. We just want give them a way to set passwords in bulk.
    – Nagen Sahu
    Commented Aug 7 at 12:03

1 Answer 1

1

Every time the password is set or reset, regardless of who does it, or the manner in which a change is effected, the expiry is reset to the policy. For example, users can use the Forgot Password feature, change their password in Personal Setup, have an admin click the Reset Password button on their user, or the user or an admin can use the setPassword function in Apex, or even through an API call. In other words, if the user's profile requires a password change every 30 days, and an administrator sets a new password, that password will be valid for 30 days.

2
  • Thank you sfdcfox ! Hoping to watch your session at DF this year.
    – Nagen Sahu
    Commented Aug 7 at 12:06
  • @NagenSahu I don't have a session this year, but if you want to meet up, I'll be happy to try and arrange something.
    – sfdcfox
    Commented Aug 7 at 12:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .