When attempting to enable Domain Rewrite for a specific user, the task gets stuck or fails with the following error message:
Unable to prepare <user@domain.com>, a cloud source and/or on-premises target environment could not be found in Directory Sync and is required to enable rewrite on a matched on-premises mailbox [UserMigrationId #<id
This issue occurs on hybrid user objects when there is an active local Directory Sync agent, but backend object mapping between local Active Directory and the cloud tenant encounters a temporary sync conflict during the rewrite preparation phase.
To resolve the state conflict and successfully enable Domain Rewrite for the user, perform the following sequence:
Disable Directory Sync for the affected user/environment.
Temporarily change the user object to cloud-only.
Run a Domain Rewrite Discovery task.
Enable Domain Rewrite for the user.
Revert the user object back to hybrid.
Enable Directory Sync again to resume normal synchronization.