PolicyStatement.PermissionSet 属性

定义

注意

Code Access Security is not supported or honored by the runtime.

获取或设置策略语句的 PermissionSet

public:
 property System::Security::PermissionSet ^ PermissionSet { System::Security::PermissionSet ^ get(); void set(System::Security::PermissionSet ^ value); };
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public System.Security.PermissionSet PermissionSet { get; set; }
public System.Security.PermissionSet PermissionSet { get; set; }
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.PermissionSet : System.Security.PermissionSet with get, set
member this.PermissionSet : System.Security.PermissionSet with get, set
Public Property PermissionSet As PermissionSet

属性值

策略语句的 PermissionSet

属性

示例

下面的代码示例演示如何使用 PermissionSet 属性向策略语句添加权限。 此代码示例是为 PolicyStatement 类提供的一个更大示例的一部分。

NamedPermissionSet^ allPerms = gcnew NamedPermissionSet(
   L"allPerms" );
allPerms->AddPermission( gcnew SecurityPermission(
   SecurityPermissionFlag::Execution ) );
allPerms->AddPermission( gcnew ZoneIdentityPermission(
   SecurityZone::MyComputer ) );
allPerms->AddPermission( gcnew SiteIdentityPermission(
   L"www.contoso.com" ) );

( *policyStatement)->PermissionSet = allPerms;
NamedPermissionSet allPerms = new NamedPermissionSet("allPerms");
allPerms.AddPermission(
    new SecurityPermission(SecurityPermissionFlag.Execution));
allPerms.AddPermission(
    new ZoneIdentityPermission(SecurityZone.MyComputer));
allPerms.AddPermission(
    new SiteIdentityPermission("www.contoso.com"));

policyStatement.PermissionSet = allPerms;
Dim allPerms As New NamedPermissionSet("allPerms")
allPerms.AddPermission( _
    New SecurityPermission(SecurityPermissionFlag.Execution))
allPerms.AddPermission( _
    New ZoneIdentityPermission(SecurityZone.MyComputer))
allPerms.AddPermission( _
    New SiteIdentityPermission("www.contoso.com"))

policyStatement.PermissionSet = allPerms

注解

注意

代码访问安全性 (CAS) 已在所有版本的 .NET Framework 和 .NET 中弃用。 如果使用与 CAS 相关的 API,最新版本的 .NET 不会遵循 CAS 注释,并会生成错误。 开发人员应寻求用于完成安全任务的替代方法。

适用于