PermissionSet.SetPermission(IPermission) 方法

定义

将权限设置为 PermissionSet,替换同一类型的任何现有权限。

public:
 System::Security::IPermission ^ SetPermission(System::Security::IPermission ^ perm);
public:
 virtual System::Security::IPermission ^ SetPermission(System::Security::IPermission ^ perm);
public System.Security.IPermission? SetPermission (System.Security.IPermission? perm);
public virtual System.Security.IPermission SetPermission (System.Security.IPermission perm);
public System.Security.IPermission SetPermission (System.Security.IPermission perm);
member this.SetPermission : System.Security.IPermission -> System.Security.IPermission
abstract member SetPermission : System.Security.IPermission -> System.Security.IPermission
override this.SetPermission : System.Security.IPermission -> System.Security.IPermission
Public Function SetPermission (perm As IPermission) As IPermission
Public Overridable Function SetPermission (perm As IPermission) As IPermission

参数

perm
IPermission

要设置的权限。

返回

设置的权限。

例外

示例

下面的代码示例演示如何使用 SetPermission 方法。 此代码示例是为 PermissionSet 类提供的一个更大示例的一部分。

// Change the permission set using SetPermission.
ps5->SetPermission( gcnew EnvironmentPermission( EnvironmentPermissionAccess::AllAccess,"USERNAME" ) );
Console::WriteLine( "Permission set after SetPermission = {0}", ps5 );
// Change the permission set using SetPermission.
ps5.SetPermission(new EnvironmentPermission(EnvironmentPermissionAccess.AllAccess, "USERNAME"));
Console.WriteLine("Permission set after SetPermission = " + ps5.ToString());
' Change the permission set using SetPermission.
ps5.SetPermission(New EnvironmentPermission(EnvironmentPermissionAccess.AllAccess, "USERNAME"))
Console.WriteLine("Permission set after SetPermission = " & ps5.ToString())

注解

此方法从 PermissionSet 中删除同一类型的任何现有权限对象,并将其 perm 替换为 参数。 如果在 上设置了实现 IUnrestrictedPermission 的权限,则Unrestricted生成的 PermissionSet 不再是 UnrestrictedPermissionSet

继承者说明

PermissionSet继承时,可以通过重写 SetPermissionImpl(IPermission) 方法来更改 方法的行为SetPermission(IPermission)

适用于