PermissionSet.SetPermission(IPermission) PermissionSet.SetPermission(IPermission) PermissionSet.SetPermission(IPermission) 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 System.Security.IPermission SetPermission (System.Security.IPermission perm);
member this.SetPermission : System.Security.IPermission -> System.Security.IPermission
Public Function SetPermission (perm As IPermission) As IPermission

Parameters

perm
IPermission IPermission IPermission IPermission

The permission to set.

Returns

Exceptions

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