Export (0) Print
Expand All

PermissionSet.SetPermission Method

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

[Visual Basic]
Public Overridable Function SetPermission( _
   ByVal perm As IPermission _
) As IPermission
[C#]
public virtual IPermission SetPermission(
 IPermission perm
);
[C++]
public: virtual IPermission* SetPermission(
 IPermission* perm
);
[JScript]
public function SetPermission(
   perm : IPermission
) : IPermission;

Parameters

perm
The permission to set.

Return Value

The set permission.

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.

Example

[Visual Basic] 
' Change the permission set using SetPermission.
ps5.SetPermission(New EnvironmentPermission(EnvironmentPermissionAccess.AllAccess, "USERNAME"))
Console.WriteLine("Permission set after SetPermission = " & ps5.ToString())

[C#] 
// Change the permission set using SetPermission.
ps5.SetPermission(new EnvironmentPermission(EnvironmentPermissionAccess.AllAccess, "USERNAME"));
Console.WriteLine("Permission set after SetPermission = " + ps5.ToString());

[C++] 
// Change the permission set using SetPermission.
ps5->SetPermission(
   new EnvironmentPermission(EnvironmentPermissionAccess::AllAccess, S"USERNAME"));
Console::WriteLine(S"Permission set after SetPermission = {0}", ps5);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

PermissionSet Class | PermissionSet Members | System.Security Namespace

Show:
© 2014 Microsoft