This blog talks about an issue we face while running out of the box or custom reports from Microsoft Dynamics CRM 2011. We will observe that few of the users are able to run the report and in the organization suddenly start getting script errors and are unable to run any reports from CRM. In this scenario we receive different script errors. Following are the script errors we receive with the error message :-
'Sys' is undefined
Reportviewer.aspx
Code:0
OR
Message: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '
<html>
<head>
<t'.
Line:5
Char:84093
Code:0
OR
Webpage error details:
User Agent:Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2;.NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Timestamp: Tue, 17 Jul 2012 22:43:06 UTC
Message: Object expected
Line: 60
Char: 1
Code: 0
URI: http://crm2011:5555/CRMTest/CRMReports/rsviewer/reportviewer.aspx
Message: Object expected
Line: 60
Char: 1
Code: 0
URI: http://crm2011:5555/CRMTest/CRMReports/rsviewer/reportviewer.aspx
Following are the screenshots of the error we see when running reports from web client:-
Following is the screenshot of the error message we receive from CRM outlook client :-
I collected the CRM platform traces and found we see below error message which is weird as my user has a system administrator security role in the CRM organization from here the user is unable to run the report and receive the script errors:-
Error: The user is not assigned any privileges.
Error Number: 0x80042F09
Error Message: The user is not assigned any privileges.
Error Details: The user is not assigned any privileges.
Source File: Not available
Line Number: Not available
Stack Trace Info: [CrmException: The user is not assigned any privileges.]
at Microsoft.Crm.MainApplication.Application_OnPostAuthenticateRequest(Object sender, EventArgs eventArguments)
----------------------------------
An error occurred during the Application_OnPostAuthenticateRequest :
Error: The user is not assigned any privileges.
Stack Trace: at Microsoft.Crm.MainApplication.Application_OnPostAuthenticateRequest(Object sender, EventArgs eventArguments)
----------------------------------
This issue looked really looked different to me until I found out how the authentication works when a user runs a report from a particular organization in CRM.
CAUSE OF THIS ISSUE
This issue occurs when a user does not have Security Role assigned to him in his default organization in CRM . Now, by user's default organization we mean that organization in entire CRM deployment where the user was first created.
For instance I have 3 organization ORG1, ORG2 and ORG3 in CRM . I created a user say user1 in AD and then created this user as a CRM user in ORG 1 for the first time. Thus, ORG1 becomes the default organization for this user. Next, if I create the same user user1 in ORG2 it will not make a difference ORG1 still will be the default organization for USER1.
Thus, if future if we remove the security role of user1 from ORG1 , USER1 will not be able to run any reports from ORG2 or ORG3. The user will get all the above mentioned script errors.
REASON FOR THE AUTHENTICATION FAILURE
The issue is caused when the user is being authenticated to access the ScriptResource.axd, WebResource.axd and Reserved.ReportViewerWebControl.axd controls. The UserCache is being examined while running any report to authenticate the user using the default rganization information and since the user doesn't have any privileges in that organization, the authentication fails and throws an exception.
RESOLUTION
To resolve this issue we should to give a security role to the user in his default organization. Please follow the steps mentioned in the last section on how to find default organization for any CRM user.
I have also seen this issue occurring in scenarios where user's has security role in his default organization but that default organization is being disabled and no more in use but still present in deployment manager. Hence, in such cases either delete the disabled or unused organization from CRM deployment or enable the organization.
HOW TO FIND DEFAULT ORGANIZATION FOR ANY USER IN MULTIPLE ORGANIZATION CRM DEPLOYMENT
-Log in to SQL Server where we have CRM databases <org>_MSCRM and MSCRM_CONFIG. We have 4 different tables from where we will have to fetch the user entries.
-SystemUserBase,
-SystemUserOrganizations,
-SystemUser and then
-Organization
Refer to the following diagram which will help you understand how different tables are related for a specific user.
Run following queries one by one and fetch the GUID values as follows:-
Run below query on ORG_MSCRM database :-
Select domainname,systemuserid from systemuserbase where domainname ='domainname\username'
Note:-
domainname\username is for the affected user.
Copy SystemUserID = 7F0F58A8-5ED0-E111-B576-00155D5AC438
Run following query in MSCRM_CONFIG database :-
USE [MSCRM_CONFIG]
select UserId from systemuserorganizations where CrmUserId='7F0F58A8-5ED0-E111-B576-00155D5AC438'
Copy UserId = D058E3E4-EF63-E111-97DA-00155D5AC42A
USE [MSCRM_CONFIG]
select defaultOrganizationId from SystemUser where id='D058E3E4-EF63-E111-97DA-00155D5AC42A'
Copy default org id= 076DC913-4564-4569-9A8C-9CD1C4A4ABA2
USE [MSCRM_CONFIG]
select DatabaseName,UniqueName from organization where id = '076DC913-4564-4569-9A8C-9CD1C4A4ABA2'
Default Org XXX_MSCRM
This way we can find the default organization for any user.