SetPermission Method

PermissionSet.SetPermission Method

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

Namespace: System.Security
Assembly: mscorlib (in mscorlib.dll)

public IPermission SetPermission (
	IPermission perm
)
public IPermission SetPermission (
	IPermission perm
)
public function SetPermission (
	perm : IPermission
) : IPermission
Not applicable.

Parameters

perm

The permission to set.

Return Value

The set permission.

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.

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

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2016 Microsoft