PermissionSet.SetPermission(IPermission) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
- perm
- IPermission
The permission to set.
The set permission.
The method is called from a ReadOnlyPermissionSet.
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())
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
.
When you inherit from PermissionSet, you can change the behavior of the SetPermission(IPermission) method by overriding the SetPermissionImpl(IPermission) method.
Product | Versions |
---|---|
.NET | Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
.NET feedback
.NET is an open source project. Select a link to provide feedback: