2

I am trying to run a .Net 2.0 application from a network share without using the FullTrust permission set. I want to create a new permission set that has just the permissions my assemblies require, and then assign that to the exe on the shared path. Is it possible to do this? From my limited experiments, I find that I am unable to do get any application working from a network share without FullTrust. I tried creating a new perm set, and also tried the Everything and other perm sets, but none seem to work. Has anyone had any experience with this?

4

3 回答 3

2

您需要使用强名称对程序集进行签名,然后将您的强名称的 cas-policy 设置为完全信任。

为使用您的强名称签名的所有代码设置 FullTrust 的最简单方法是:

caspol.exe -q -m -ag MyZone -strong -hex [HexCodeOfYourStrongName] -noname -noversion FullTrust -name MyCode -description "Code trust for my code"';

如果您的代码被拆分为多个程序集,您需要使用该强名称对每个程序集进行签名。您可能需要SecurityPermission使用链接需求设置 -Attribute,以确保调用者的安全性接管。

[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.ControlPrincipal)]
于 2009-01-08T08:25:37.703 回答
0

在 .NET 3.5 之前,您需要完全信任共享才能从那里运行 .NET 应用程序。肖恩在此解释说:“如果不对默认 CAS 系统进行一些修改,我们将在加载包含安全对象的程序集和授予它们策略之间处于永无止境的循环中……进入 FullTrust 列表。”

在 .NET 3.5 中,此限制通过“...默认授予一组 FullTrust,使它们的行为与直接从您的计算机上启动一样”(来自 Shawn 的另一篇文章克服了这一限制

于 2009-01-08T08:19:49.010 回答
0

给予强命名的程序集 FullTrust 权限听起来不错,但不幸的是,我的程序集引用了几个第三方 COM Dll,如果我对主程序集进行强命名,它们也需要强命名。我猜然后将 FullTrust 赋予 Shawn 给出的路径是最好的解决方案: CasPol.exe -pp off -m -ag 1.2 -url file://\ShawnFa-Srv/Tools/* FullTrust

于 2009-01-08T10:40:28.057 回答