Password Expiration with AAD connect Password hash sync

Steel Contributor


When Password Sync is enabled, the cloud password for a synchronized user is set to “never expires”. This means that the password synchronized to the cloud is still valid after the on-premises password expires.

 

Please see scenarios below:

 

ITEM

USER ACTION

Effect in Password in Office 365

120-day password expiry in Local AD was enforced

User changed password

  • The new password hash will be synched to Office 365
  • User can login to Office 365

120-day password expiry in Local AD was enforced

User did not change password

  • The Old Password hash is still synced and cached to Azure AD
  • User can login to Office 365
  • No prompt in Office 365 that the Local AD password needs to be changed

 

 

Is there a way that we can enforce the following:

 

- force Office 365 users to change password in Local AD once the password expiration in local AD is enforced

- disable users in office 365 if the password in local AD is expired

 

thanks

 

14 Replies

You can certainly create some script or custom AAD Connect rules to disable the user upon password expiration, or force a password change in O365. But there is no out of the box solution, if that's what you ask for.

Or also switch over to a pass-through authentication model. This was your auth gets passed via agent to have your AD do the auth. This will follow all local AD rules.

https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-pta-quick-start

Hello @Marvin Oco,

I noticed MS is working to find the better solution about this (link: Allow password expiration policy to sync from on-prem AD to Azure AD).

 

At meanwhile, even if PasswordNeverExpires=True when password sync is enabled (AADConnect), however, Azure let change the attribute to False via PowerShell, can it be considered a workaround? Will it inherit the password expiration policy set in Azure AD, then ?

 

What about ?

 

Thank you,

Luca

I was investigating into this situation a bit and upon finding this thread - I thought it might be good to update it. Microsoft has added a feature in public preview where you can turn on password expiration when using the password hash synchronization scenario. Bad news however. documentation recommends that this be turned on before password sync is turned on.

 

https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-password-hash-synchron...

 

Also, I've seen comments in the user voice post Luca referenced saying that people have contacted MS support and have received other ways to work around this.

Hello @Timothy Balk,

well, we implemented the EnforceCloudPasswordPolicyForPasswordSyncedUsers feature time ago, and set the same password expiration policy like on-premise AD (90 days*) but unfortunately, it was enabled with password hash sync already in place; so every time a new user is synced to Azure AD (initial sync of password) the PasswordPolicies attribute is set to DisablePasswordExpiration value by default. The (manual) solution is to change it via PowerShell:

 

Single user:

 

Set-AzureADUser -ObjectId <user ID> -PasswordPolicies None

 

In bulk:

 

Get-AzureADUser -All $true | Set-AzureADUser -PasswordPolicies None

 

I hope Microsoft can find a more flexible way to manage it.

 

* - There is a limit when there are multiple on-premise AD domains with different password expiration policy, all syncing with same Azure AD tenant through AAD Connect and sharing the same registered domain.

Just to be sure:

When the on-premise password expiration policy is set to 90 days and the Azure AD policy is also set to 90 days, the password expires at the same time for on-premise and in the cloud, regardless when the Azure AD policy pwd is set to on?

Thanks

@ThomasK007,

I try to give you a detailed answer.

Until you have the EnforceCloudPasswordPolicyForPasswordSyncedUsers disabled (which is the default), an Azure AD user coming from on-premise AD (synced by AAD Connect) has its account password set to Never Expire.

 

"Password expiration policy

If a user is in the scope of password hash synchronization, by default the cloud account password is set to Never Expire.

You can continue to sign in to your cloud services by using a synchronized password that is expired in your on-premises environment. Your cloud password is updated the next time you change the password in the on-premises environment."

 

Reference: Implement password hash synchronization with Azure AD Connect sync | Microsoft Docs

 

Once you enable the EnforceCloudPasswordPolicyForPasswordSyncedUsers feature and set the PasswordPolicies attribute to None (instead of DisablePasswordExpiration), the expiration time for an Azure AD user should be calculated referring to read-only attribute LastPasswordChangeTimestamp (you can retrieve it by using the Get-MsolUser cmdlet), depending on expiration policy.

 

Now if you have AAD Connect with password hash sync, same password expiration policy set on both Azure AD and on-premise AD (e.g. 90 days), every time a password is changed on-premise AD, pwdlastset attribute is updated, the password itself synced with Azure AD and the LastPasswordChangeTimestamp updates accordingly - so they both expires at same time (maybe few  minutes off); if you also have the password writeback functionality in place (link: How does self-service password reset writeback work in Azure Active Directory? | Microsoft Docs) the behavior described above works when the password is change from Azure AD and synced back to on-premise AD.

 

It should be right (please, can someone else confirm that ?)

I hope I was clear.

 

Bye,

Luca

@lucafabbri365 Great explanation.

 

If a company usees Fine-grained Password Policy to apply different password expiration policies inside the same AD domain - would that still work out with Azure AD?

Hello @Thomas Kofler,

yours is a good question.

Well, Fine-grained Password Policy is supported by Azure Active Directory Domain Services (Azure AD DS) for sure. Azure AD DS integrates with existing Azure AD tenant, but is a different service.

Definition

"Azure Active Directory Domain Services (AD DS) provides managed domain services such as domain join, group policy, lightweight directory access protocol (LDAP), and Kerberos / NTLM authentication. You use these domain services without the need to deploy, manage, and patch domain controllers (DCs) in the cloud."

 

References

Instead, we are speaking about password expiration on Azure AD tenant.

 

This post On-premise Password policy & Azure AD Password policy (Visual Studio forums) treats the same argument: basically, you can define a password policy per custom domain in Azure AD.

I think the logic is the same I described previously: it depends on the password policy set for the custom domain where Azure AD user belongs and the password policy set for the same user, on-premise: if they match the behavior is the same (password will expire at same time), otherwise they will have different expiration time.

 

Please, let me know if it's clear, or I can write down some practical examples.

 

Bye,

Luca

 

Hi@lucafabbri365,

 

We have similar issue and it's a major security concern. Now my infosec team wants to get rid of expired passwords should get block.

 

As i said am planning to run below command for entire Organization.

Get-AzureADUser -All $true | Set-AzureADUser -PasswordPolicies None

Is it going to impact the users which are already logged into the mailboxes, cloud apps, on-prem custom apps when we run the above command.

 

Any help really appreciated.

 

 

 

ps sscript can be used to overcome this, I was searching for the same for one of our customers so created the script which is now live in couple of our environments.
Use below script to fill this gap till we have a full solution from MS.
https://techwizard.cloud/2021/02/17/password-hash-sync-password-expiry-set-to-never-expire/

@lucafabbri365 

 

Thanks for detailing this step by step and it is helpful!

 

A question on this to get further more clarity - After implementing all this policy changes what happens the next time when a user resets his password and it is synced to AzureAD via AD sync tool ?

 

Is it expected that the "PasswordPolicies" attribute again going back to "DisablePasswordExpiration" so that against each password sync the "PasswordPolicies" attribute to be set as "None" using a daily script or something ?

Hello @Sujesh1415,

assuming you enabled the EnforceCloudPasswordPolicyForPasswordSyncedUsersfeature, as per Microsoft article Implement password hash synchronization with Azure AD Connect sync:

 

"...Azure AD does not go to each synchronized user to remove the DisablePasswordExpiration value from the PasswordPolicies attribute. Instead, the DisablePasswordExpiration value is removed (None) from PasswordPolicies during the next password hash sync for each user, upon their next password change in on-premises AD".

 

Microsoft recommends enabling EnforceCloudPasswordPolicyForPasswordSyncedUsers prior to enabling password hash sync, so that the initial sync of password hashes does not add the DisablePasswordExpiration value to the PasswordPolicies attribute for the users.

 

But if you enabled the feature AFTER setting up password hash sync, then you have to choices for setting PasswordPolicies to None:

 

  1. Wait for the user’s next password change to occur on the on-premises AD
  2. Run a PowerShell script (once) to update it:

Single user:

 

Set-AzureADUser -ObjectId <user ID> -PasswordPolicies None​

 

 All users:

 

Get-AzureADUser -All $true | Set-AzureADUser -PasswordPolicies None​

 

 

Does it answer to your question ?

Hi @lucafabbri365,

 

Thanks for the information. For further clarity, we've already had Hash sync enabled. So If I enable the feature org-wide and set it to none. Will it cause any issues for those getting ready to change there password. For instance, not every user will change there password exactly at 90 days ex. New employees etc.