Restore missing user in MSCRM_CONFIG

In some rare scenario's you'll not be able to login to CRM though you are sure that you're use has been added to the organization and you have a security role as well. The pesky error message generally is:

404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

If this is the case, then it could be that your user is missing in the MSCRM_CONFIG database. Especially if you're moving around database with backup and restore, then this could happen. If you think this could be the case in your scenario, then make sure to start a SQL profiler and grab the entry that shows up when refreshing the page. It would like like this:

exec sp_executesql N'exec p_GetCrmUserId @OrganizationId, @AuthInfo',N'@OrganizationId uniqueidentifier,@AuthInfo nvarchar(46)',@OrganizationId='0474D466-1234-E311-1234-A02B3F591536',@AuthInfo=N'W:S-1-5-21-123456789-1234567890-123456789-1234'

When executing that query against the MSCRM_CONFIG you should not get any result. If this is indeed the case, then you can add your user back into this table with the query below. The usual statements apply, backup first, unsupported and only execute this when you know what you're doing.

GOINSERT INTO [dbo].[SystemUserOrganizations]
((select systemuserid from [2011FR2_MSCRM].dbo.SystemUserBase where DomainName='[domain]\[username]')
,(select id from organization where DatabaseName = '[ORG]_MSCRM')
,(select userid from SystemUserAuthentication where authinfo='[Auth info as copied from the SQL profiler')

No comments: