Hello @SH,
Thank you for posting your query on Microsoft Q&A.
Based on your description, it seems you've federated your custom domain (domainA.com) with Google IDP. This means any user with the domainA.com suffix is redirected to Google's endpoint for authentication. This setup works for users synchronized from Google to Entra ID, but you're now trying to achieve the same for on-premises user accounts. You've used Microsoft Entra Connect to sync these on-prem users to Entra ID. However, when these users attempt to sign in to office.com, they encounter the error: "AADSTS51004: The user account ******@mydomain.org does not exist in the xxxxx-xxxxx-xxxxx-xxxxx-xxxxx directory. To sign into this application, the account must be added to the directory."
This issue can occur if the Immutable ID is not correctly set for the user. To resolve this, follow these steps:
- Convert the federated user to a cloud-only user (update the UPN to a non-federated domain)
- Update the ImmutableId
- Convert the user back to a federated user
Here's a PowerShell example to update the ImmutableId for a federated user:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Install-Module Microsoft.Graph -Scope CurrentUser
Import-Module Microsoft.Graph
Connect-MgGraph -Scopes 'User.Read.All', 'User.ReadWrite.All'
#1. Convert the user from federated to cloud-only
Update-MgUser -UserId alton@example.com -UserPrincipalName ******@example.onmicrosoft.com
#2. Convert the user back to federated, while setting the immutableId
Update-MgUser -UserId ******@example.onmicrosoft.com -UserPrincipalName alton@example.com -OnPremisesImmutableId '260051'
Please refer the below document for more information.
Identity matching in Microsoft Entra ID
I hope this information is helpful. Please feel free to reach out if you have any further questions.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Thanks,
Raja Pothuraju.