The server principal 'AD\MYNAME' is not able to access the database "MSCRM_CONFIG" under the current security context

StackOverflow https://stackoverflow.com/questions/19411384

  •  01-07-2022
  •  | 
  •  

Question

Here is the problem.
CRM 4.0 Production crashed. Systems guys restored it, but our iframes are not working.

We were using SSPI in the web.config files before the crash and it was working, but ever since they restored everything it doesn't work. The workaround, for now, is to hard code the username and password in the web.config file.

My systems guy has no clue how to resolve this issue.

I get this error: The server principal 'AD\MYNAME' is not able to access the database "MSCRM_CONFIG" under the current security context.

Any ideas / suggestions?

Was it helpful?

Solution

That error is one created by SQL Server. When you restore a backup database to another server, you may experience a problem with orphaned users. That is to say that the SID system view sysuser is not mapped to a SID syslogins existing.

To detect orphaned users you can run the following command:

USE MSCRM_CONFIG
sp_change_users_login  @Action='Report';

You can see that the SID does not match the system views: sys.sysusers and sys.syslogins

USE MSCRM_CONFIG
SELECT sid FROM sys.sysusers WHERE name = 'AD\MYNAME'
SELECT sid FROM sys.syslogins WHERE name = 'AD\MYNAME'

To correct this problem of connection between the server connection account specified by the user and AD\MYNAME the database specified by AD\MYNAME, you can run the following command.

USE MSCRM_CONFIG
EXEC  sp_change_users_login @Action='update_one', @UserNamePattern='AD\MYNAME',@LoginName='AD\MYNAME'; 

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top