Replication troubleshooting...

A customer has custom code that uses the Microsoft Provisioning Framework to do the following in their respective order:
1) Create a user
2) Create a Sharepoint site (When the Sharepoint site is created, roles are also created.)
3) Add the user created in 1) to a role defined for the Sharepoint Site created in 2)

When the code executes 3) the following error occurs:

MPF Response: System.Exception -

<response>
<errorContext description=" The user does not exist. 0x81020054" code="0x80131500" executeSeqNo="409">
<errorSource namespace="SharePoint Provider" procedure="AddUsersToRole"/>
<errorSource namespace="Managed Sharepoint Hosting" procedure="AddUsersToRole"/>
<errorSource namespace="COMET Hosting" procedure="CreateUser"/>
</errorContext>
</response>

The customer needed assistance in successfully executing step 3)

The issue is found to be related to AD synchronisation. When the Secured Channel for each Sharepoint Server is the same as the preferred domain controller in the MPS requests, the issue does not reproduce. If you are experiencing what appears to be the same issue in your environment, you might want to confirm using the following command:-

netdom reset <target machine name> /Domain:<domain name> /Server:<preferred DC>

If you are experiecing the same issue, you may want to consider changing the domain topology so that servers naturally point to the appropriate DC
a. Create a site in AD
b. Associate the subnet with the Sharepoint Servers to the new Site
c. Move the preferred DC to the new site