Επεξεργασία

Κοινή χρήση μέσω


PermissionSet.SetPermission(IPermission) Method

Definition

Sets a permission to the PermissionSet, replacing any existing permission of the same type.

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

Parameters

perm
IPermission

The permission to set.

Returns

The set permission.

Exceptions

The method is called from a ReadOnlyPermissionSet.

Examples

The following code example shows the use of the SetPermission method. This code example is part of a larger example provided for the PermissionSet class.

// 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())

Remarks

This method removes any existing permission object of the same type from the PermissionSet and replaces it with the perm parameter. If a permission that implements IUnrestrictedPermission is set on a PermissionSet that is Unrestricted, the resulting PermissionSet is no longer Unrestricted.

Notes to Inheritors

When you inherit from PermissionSet, you can change the behavior of the SetPermission(IPermission) method by overriding the SetPermissionImpl(IPermission) method.

Applies to