Members
Constructors
| Name |
Description |
RegistryAccessPermission(PermissionState state) |
Initializes a new instance of the RegistryAccessPermission class with the specified permission state. |
Methods
| Name |
Description |
Copy() |
Creates and returns an identical copy of the current permission object. |
Equals(object obj) |
Determines whether the specified object is equal to the current object. |
FromXml(SecurityElement e) |
Reconstructs a security object from an XML encoding. |
GetHashCode() |
Serves as a hash function for the current type. |
Intersect(IPermission target) |
When overridden in a derived class, creates and returns a new permission that represents the intersection of the current permission and the specified permission. |
IsSubsetOf(IPermission target) |
When overridden in a derived class, determines whether the current permission is a subset of the specified permission. |
IsUnrestricted() |
When overridden in a derived class, indicates whether the permission can be exercised without having to examine the permission state. |
ToXml() |
Returns an XML encoding of the security object. |
Union(IPermission target) |
When overridden in a derived class, creates and returns a new permission that represents the set of all points that are contained in both the current permission and the specified permission. |
Properties
| Name |
Description |
IsUnrestricted |
Gets a value indicating whether the current permission is unrestricted. |
Inherited Members
This class inherits members from the following base classes:
Example
The following C# code demonstrates how to grant RegistryAccessPermission to a specific code group:
using System;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
public class RegistryAccessExample
{
public static void GrantRegistryAccess()
{
// Define the code group that needs registry access
CodeGroup codeGroup = new FileCodeGroup(
new StrongNameMembershipCondition(new StrongNamePublicKeyBlob(new byte[] { /* your public key bytes */ })),
FileIOPermissionAccess.Read | FileIOPermissionAccess.Write
);
// Create a RegistryAccessPermission
RegistryAccessPermission registryPermission = new RegistryAccessPermission(PermissionState.Unrestricted);
// Create a NamedPermissionSet to hold the permissions
NamedPermissionSet permissionSet = new NamedPermissionSet("MyRegistryAccessSet");
permissionSet.AddPermission(registryPermission);
// Add the permission set to the code group's policy statement
codeGroup.PolicyStatement.PermissionSet = permissionSet;
Console.WriteLine("RegistryAccessPermission granted to the specified code group.");
}
public static void Main(string[] args)
{
// Note: This is a conceptual example. Actual policy manipulation requires
// administrative privileges and is typically done via code access security tools.
// In modern .NET, this CAS model is deprecated.
// GrantRegistryAccess();
Console.WriteLine("Conceptual example of granting RegistryAccessPermission.");
}
}