Set Need To Change Password In Code

I am migrating users from a Legacy system to Litium 7.2. I am wanting to set the field “User must change password at next login” by default on these users . What is the best practice for doing this? I do not see any properties for this on the Person object and I canot find the Field Id.

You can add a new custom boolean field on Person object and create a logic to check that on login.

Are you saying that ther is no way of setting the login property for this via the api?

You can set the Person.LoginCredential.PasswordExpirationDate to a past date and it should trigger that user need to change password.

That property is actually not stored in the DB and it’s an aggregated value like shown here:
result.NeedToChangePassword = source.LoginCredential.PasswordExpirationDate.HasValue && source.LoginCredential.PasswordExpirationDate.Value < DateTimeOffset.UtcNow;

You can get/set it in Person object:
person.LoginCredential.PasswordExpirationDate = model.NeedToChangePassword ? DateTimeOffset.UtcNow : (DateTimeOffset?)null;

1 Like

Thanks that works.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.