Reporting Services LocalReport and WIF

ⅰ亾dé卋堺 提交于 2020-01-02 01:12:10

问题


I have a wcf webservice that uses WIF for authentication. Part of the responsibility of this webservice is to generate a report and email it. If I render the report with data only everything is fine. If I include any report parameters, report constants, or even just DateTime.Now I get the following exception:

An error occurred during local report processing.Failed to load expression host assembly. Details: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

I can run the same report in a WCF service that does not use WIF, so clearly something about the security environment is fubarred.

I really don't know how to proceed with solving this problem. Can anyone help? Thanks!


回答1:


This works:

var reportInstance = new LocalReport();
reportInstance.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));

I don't really understand why. I do understand that the report is being granted permissions it can't get from WIF, but I don't understand which permissions those are or why it needs them. So, my answer "gives a man a fish," but can someone else "teach a man to fish" by explaining the deeper issue?




回答2:


I was facing the same problem with an MVC 3/WinForms hybrid app with Windows Authentication. I spent some time trying to determine the minimum permissions required for the report to run. For me, this also works:

var permissionSet = new PermissionSet(PermissionState.None);
var flags = SecurityPermissionFlag.Execution | 
            SecurityPermissionFlag.ControlPrincipal;
var permission = new SecurityPermission(flags);
permissionSet.AddPermission(permission);

ReportViewer.LocalReport.SetBasePermissionsForSandboxAppDomain(permissionSet);

Depending on how paranoid you are, you might feel safer with a bit more locked down permission set.

Sadly, I have no explanation for why these particular permissions are necessary and don't know if others are needed under different circumstances, but I hope this is useful.



来源:https://stackoverflow.com/questions/4794968/reporting-services-localreport-and-wif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!