Configuring Password Expiration Policy with Password Hash Sync

%3CLINGO-SUB%20id%3D%22lingo-sub-1670091%22%20slang%3D%22en-US%22%3EConfiguring%20Password%20Expiration%20Policy%20with%20Password%20Hash%20Sync%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1670091%22%20slang%3D%22en-US%22%3E%3CP%20class%3D%22p1%22%3EWe%20are%20using%20Password%20Hash%20Sync%20to%20sync%20users%20from%20on-prem%20to%20o365.%20I%20try%20to%20enable%20password%20expiration%20on%20O365%20so%20I%20used%20below%20command%20to%20enable%20it%20without%20any%20problem%3A%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSTRONG%3ESet-MsolDirSyncFeature%20-Feature%20EnforceCloudPasswordPolicyForPasswordSyncedUsers%20-Enable%20%24true%3C%2FSTRONG%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22p1%22%3EAs%20a%20second%20step%2C%20I%20need%20to%20set%26nbsp%3BPasswordPolicy%20to%20None%20for%20synchronized%20users%20using%20below%20command%3A%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSTRONG%3EGet-AzureADUser%20-All%20%24true%20%7C%20Where-Object%20%7B%20%24_.DirSyncEnabled%20-eq%20%24true%20-and%20%24_.PasswordPolicies%20-eq%20'DisablePasswordExpiration'%20%7D%20%7C%20ForEach-Object%20%7BSet-AzureADUser%20-ObjectId%20%24_.ObjectID%20-PasswordPolicies%20None%7D%3C%2FSTRONG%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22p1%22%3EI%20get%20below%20error%20message%20when%20I%20try%20to%20set%20PasswordPolicies%20parameter%20to%20None.%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CI%3ESet-AzureADUser%20%3A%20Error%20occurred%20while%20executing%20SetUser%3C%2FI%3E%3CBR%20%2F%3E%3CI%3ECode%3A%20Request_BadRequest%3C%2FI%3E%3CBR%20%2F%3E%3CI%3EMessage%3A%20Unable%20to%20update%20the%20specified%20properties%20for%20on-premises%20mastered%20Directory%20Sync%20objects%20or%20objects%3C%2FI%3E%3CBR%20%2F%3E%3CI%3Ecurrently%20undergoing%20migration.%3C%2FI%3E%3CBR%20%2F%3E%3CI%3ERequestId%3A%208ff45ed7-829d-4357-a6a6-f35e72ebb326%3C%2FI%3E%3CBR%20%2F%3E%3CI%3EDateTimeStamp%3A%20Tue%2C%2015%20Sep%202020%2015%3A43%3A37%20GMT%3C%2FI%3E%3CBR%20%2F%3E%3CI%3EHttpStatusCode%3A%20BadRequest%3C%2FI%3E%3CBR%20%2F%3E%3CI%3EHttpStatusDescription%3A%20Bad%20Request%3C%2FI%3E%3CBR%20%2F%3E%3CI%3EHttpResponseStatus%3A%20Completed%3C%2FI%3E%3CBR%20%2F%3E%3CI%3EAt%20line%3A1%20char%3A68%3C%2FI%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22p1%22%3EHow%20can%20I%20set%20this%20parameter%20to%20none%20so%20that%20I%20can%20disable%20%22Password%20Never%20Expire%22%20feature%20for%20synced%20users.%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22p1%22%3EBelow%2C%20you%20may%20find%20references%20I%20use%20to%20set%20this%20option%3A%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22p2%22%3E%3CSPAN%20class%3D%22s1%22%3E%3CA%20href%3D%22https%3A%2F%2Fevotec.xyz%2Fazuread-enable-password-expiration-with-password-hash-synchronization%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fevotec.xyz%2Fazuread-enable-password-expiration-with-password-hash-synchronization%2F%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p2%22%3E%3CSPAN%20class%3D%22s1%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fadmin%2Fadd-users%2Fset-password-to-never-expire%3Fview%3Do365-worldwide%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fhybrid%2Fhow-to-connect-password-hash-synchronization%23public-preview-of-the-enforcecloudpasswordpolicyforpasswordsyncedusers-feature%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1670091%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1672514%22%20slang%3D%22en-US%22%3ERe%3A%20Configuring%20Password%20Expiration%20Policy%20with%20Password%20Hash%20Sync%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1672514%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F794479%22%20target%3D%22_blank%22%3E%40yzgulec%3C%2FA%3E%26nbsp%3BHi%2C%20as%20far%20as%20I%20understand%20that%20is%20set%20to%20%22none%22%20by%20default%20when%20using%20EnforceCloudPasswordPolicyForPasswordSyncedUsers%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E%22Once%20enabled%2C%20Azure%20AD%20does%20not%20go%20to%20each%20synchronized%20user%20to%20remove%20the%26nbsp%3BDisablePasswordExpiration%26nbsp%3Bvalue%20from%20the%E2%80%AFPasswordPolicies%E2%80%AFattribute.%20Instead%2C%20the%20value%20is%20set%20to%26nbsp%3BNone%26nbsp%3Bduring%20the%E2%80%AFnext%20password%20sync%E2%80%AFfor%20each%20user%20when%20they%20next%20change%20their%20password%20in%20on-premises%20AD.%E2%80%AF%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fhybrid%2Fhow-to-connect-password-hash-synchronization%23enforcecloudpasswordpolicyforpasswordsyncedusers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fhybrid%2Fhow-to-connect-password-hash-synchronization%23enforcecloudpasswordpolicyforpasswordsyncedusers%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

We are using Password Hash Sync to sync users from on-prem to o365. I try to enable password expiration on O365 so I used below command to enable it without any problem:

 

Set-MsolDirSyncFeature -Feature EnforceCloudPasswordPolicyForPasswordSyncedUsers -Enable $true

 

As a second step, I need to set PasswordPolicy to None for synchronized users using below command:

 

Get-AzureADUser -All $true | Where-Object { $_.DirSyncEnabled -eq $true -and $_.PasswordPolicies -eq 'DisablePasswordExpiration' } | ForEach-Object {Set-AzureADUser -ObjectId $_.ObjectID -PasswordPolicies None}

 

I get below error message when I try to set PasswordPolicies parameter to None.

 

Set-AzureADUser : Error occurred while executing SetUser
Code: Request_BadRequest
Message: Unable to update the specified properties for on-premises mastered Directory Sync objects or objects
currently undergoing migration.
RequestId: 8ff45ed7-829d-4357-a6a6-f35e72ebb326
DateTimeStamp: Tue, 15 Sep 2020 15:43:37 GMT
HttpStatusCode: BadRequest
HttpStatusDescription: Bad Request
HttpResponseStatus: Completed
At line:1 char:68

 

How can I set this parameter to none so that I can disable "Password Never Expire" feature for synced users.

 

Below, you may find references I use to set this option:

 

https://evotec.xyz/azuread-enable-password-expiration-with-password-hash-synchronization/

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

2 Replies
Highlighted

@yzgulec Hi, as far as I understand that is set to "none" by default when using EnforceCloudPasswordPolicyForPasswordSyncedUsers

 

"Once enabled, Azure AD does not go to each synchronized user to remove the DisablePasswordExpiration value from the PasswordPolicies attribute. Instead, the value is set to None during the next password sync for each user when they next change their password in on-premises AD. "

 

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

Highlighted

@bec064 Thanks for reply.

 

I tested and noticed that when user changes on-prime password and synced to O365, the "PasswordPolicies" attribute becomes "None" (Exactly same as stated "Instead, the value is set to None during the next password sync for each user when they next change their password in on-premises AD. ")

 

But I couldn't manage the change it manually by using PS commands.