A cloud-based identity and access management service for securing user authentication and resource access
In a Password Hash Synchronization (PHS) setup, the on-premises password expiration attribute does not sync directly to Microsoft Entra ID. By default, synchronized users in Microsoft Entra ID are set so the cloud password never expires, which is why users can still sign in to cloud apps with an expired on-premises password.
To fix this, enable CloudPasswordPolicyForPasswordSyncedUsersEnabled at the tenant level. This makes Microsoft Entra ID enforce its own password expiration policy for password-synchronized users instead of treating them as non-expiring.
Use Microsoft Graph PowerShell:
Connect-MgGraph -Scopes "OnPremDirectorySynchronization.ReadWrite.All"
$OnPremSync = Get-MgDirectoryOnPremiseSynchronization
$OnPremSync.Features.CloudPasswordPolicyForPasswordSyncedUsersEnabled = $true
Update-MgDirectoryOnPremiseSynchronization `
-OnPremisesDirectorySynchronizationId $OnPremSync.Id `
-Features $OnPremSync.Features
Important points before enabling it:
- Password expiration values are still separate between on-premises AD and Microsoft Entra ID. The setting does not sync the on-prem expiration date itself.
- Authentication location matters:
- On-premises sign-in uses the on-prem AD password expiration policy.
- Cloud sign-in to Microsoft 365 or Azure portal uses the Microsoft Entra ID password expiration policy.
- To avoid user confusion and reduce impact, configure the same password validity period in both on-premises AD and Microsoft Entra ID.
- If users must be able to change expired passwords from Microsoft Entra ID, password writeback must also be enabled in Microsoft Entra Connect.
- Existing synchronized users do not immediately lose the
DisablePasswordExpirationsetting when this feature is enabled. That value is removed on the next password hash sync after each user changes their password on-premises.
If the Microsoft Entra password policy must match the on-premises policy, the domain password validity period in Microsoft Entra ID can be updated with:
Update-MgDomain -DomainId "<domain name>" -PasswordValidityPeriodInDays <Int32> [-PasswordNotificationWindowInDays <Int32>]
Notes:
-
Update-MgDomaindoes not work on federated domains. - By design, users with an active Microsoft Entra session, refresh token, or passwordless sign-in might not be prompted immediately when the password has expired. The prompt appears when they explicitly authenticate with a password.
- If some synchronized accounts must remain non-expiring, set
DisablePasswordExpirationexplicitly on those accounts.
This is the lowest-impact approach for a PHS environment because it keeps PHS in place and changes only how Microsoft Entra ID evaluates password expiration for synced users.
References: