报告服务 LocalReport 和 WIF

发布于 2024-10-14 04:42:23 字数 513 浏览 1 评论 0原文

我有一个使用 WIF 进行身份验证的 wcf Web 服务。该网络服务的部分职责是生成报告并通过电子邮件发送。如果我只用数据呈现报告,一切都很好。如果我包含任何报告参数、报告常量,甚至只是 DateTime。现在我会得到以下异常:

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

我可以在不使用 WIF 的 WCF 服务中运行相同的报告,因此显然有关安全环境的某些内容是令人困惑的。

我真的不知道如何继续解决这个问题。有人可以帮忙吗? 谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

離殇 2024-10-21 04:42:23

这有效:

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

我真的不明白为什么。我确实知道该报告被授予了无法从 WIF 获得的权限,但我不明白这些权限是什么或者为什么需要它们。那么,我的回答是“授人以鱼”,但其他人能否通过解释更深层次的问题来“授人以鱼”呢?

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?

无言温柔 2024-10-21 04:42:23

我在使用带有 Windows 身份验证的 MVC 3/WinForms 混合应用程序时遇到了同样的问题。我花了一些时间尝试确定报告运行所需的最低权限。对我来说,这也有效:

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

ReportViewer.LocalReport.SetBasePermissionsForSandboxAppDomain(permissionSet);

根据您的偏执程度,您可能会因为更锁定的权限集而感到更安全。

遗憾的是,我没有解释为什么这些特定权限是必要的,也不知道在不同情况下是否需要其他权限,但我希望这是有用的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文