SymptomsTask for user creating in Hosted CRM fails with the following error:
Exception during execution of MPF request: 'Unknown error 0x80131500
[<response><errorContext description="0x80040216 An unexpected error occurred."
code="0x80131500" executeSeqNo="2"><errorSource namespace="MsCRM Provider"
procedure="CreateUser"/><errorSource namespace="SW Managed MsCRM"
In most cases it is one of the following causes:
1. When PSA creates a CRM user, it passes AD user account (DOMAIN\windowsLogonName) into MS CRM API. MS CRM uses LookupAccountName Windows API function to retrieves SID of the user and then CRM uses this SID to identify user account in the AD. LookupAccountName have a cache of results of account resolving and, after user was deleted in AD, it is returning old user SID for a few minutes. MS CRM tries to use this non-existing SID for looking user in AD and fails. This situation is fixed after cache of LookupAccountName will be updated.
2. When PSA creates an AD user, it is created on one of the available AD domain controllers (PSA tries to use preferred domain controller) and then replicates to another controllers. This replication is not instant and can take some time. Just after creating an AD user PSA schedules a task to create MS CRM user. MS CRM code can use other AD domain controller than PSA and the MS CRM can fail due to replication issues.
Such tasks are rescheduled automatically and usually complete in 2-3 runs, but they can also fail due to various MS CRM or AD related issues.
If a task got "Failed" status finally after several execution attempts, it should be run manually in order to confirm that the error persists. In case the task keeps failing one should check if domain controller server is available on the corresponding server and investigate possible AD replication issues.
Also you can specify the preferred domain controller in the string value PreferredDc in registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM on the corresponding server.