Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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

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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft