Is there any API that could check is the new password is matching the Salesforce password policy or not?

We need to show the suggestion on the fly while the user is typing the password instead of showing the message after submitting.

Password must include: ...


You can query the following via Metadata API:

  • For the Organization's default security, retrieve Settings then look at SecuritySettings > passwordPolicies > complexity
  • User's Profile's overridden security, retrieve ProfilePasswordPolicy which returns a record for each Profile that has a Password Policy differing from the Organization's default. Then see ProfilePasswordPolicy's passwordComplexity Field

See financialforcedev/apex-mdapi's Github repo for a great Apex Wrapper for the Metadata API. Particularly, look at the subclasses of MetadataService.cls:

  • Organization's default security:
    • SecuritySettings
    • PasswordPolicies
  • User's Profile's overridden security:
    • Profile
    • There should be a subclass called ProfilePasswordPolicy which either extends Metadata (meaning you can call readMetadata(...) or retrieve(...)) or should be included when reading/retrieving Profile. However, the subclass doesn't exist in financialforcedev/apex-mdapi. This could probably be added, and if you add this yourself, make sure to send a Pull Request!

As far as I can tell, you can only access these settings via the metadata API, so you'd have to have administrative access to even see those settings, and then you'd need to parse the settings manually. This might be something that'd be a good idea.


Depends how the login page is spawned. The dynamic password complexity can be measured with Orgs password complexity requirements.The call needs to happen to wrapper api that takes the current password as input and internally does the check with Org password policy (based on settings retreived by metadata api). This way the wrapper uses a different high level session internally not leaking any session info to parent login page and returning the current complexity assessment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.