RegistryKey.GetAccessControl Method

Definition

Returns the access control security for the current registry key.

Overloads

GetAccessControl()

Returns the access control security for the current registry key.

GetAccessControl(AccessControlSections)

Returns the specified sections of the access control security for the current registry key.

GetAccessControl()

Source:
RegistryKey.cs

Returns the access control security for the current registry key.

C#
public System.Security.AccessControl.RegistrySecurity GetAccessControl ();

Returns

An object that describes the access control permissions on the registry key represented by the current RegistryKey.

Exceptions

The user does not have the necessary permissions.

The RegistryKey being manipulated is closed (closed keys cannot be accessed).

The current key has been deleted.

Remarks

This method overload is equivalent to calling the GetAccessControl(AccessControlSections) method overload with the bitwise combination of the following flags: AccessControlSections.Access, AccessControlSections.Owner, and AccessControlSections.Group. You can use that overload to search for other permissions.

The user must have RegistryRights.ReadPermissions rights to call this method.

Applies to

.NET 9 and other versions
Product Versions
.NET 6, 7, 8, 9
.NET Framework 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, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5

GetAccessControl(AccessControlSections)

Source:
RegistryKey.cs

Returns the specified sections of the access control security for the current registry key.

C#
public System.Security.AccessControl.RegistrySecurity GetAccessControl (System.Security.AccessControl.AccessControlSections includeSections);

Parameters

includeSections
AccessControlSections

A bitwise combination of enumeration values that specifies the type of security information to get.

Returns

An object that describes the access control permissions on the registry key represented by the current RegistryKey.

Exceptions

The user does not have the necessary permissions.

The RegistryKey being manipulated is closed (closed keys cannot be accessed).

The current key has been deleted.

Remarks

To request the access permissions currently granted to users, specify the bitwise combination of the following flags: AccessControlSections.Access, AccessControlSections.Owner, and AccessControlSections.Group. Alternatively, you can use the GetAccessControl() method overload, which specifies exactly that combination of values.

The user must have RegistryRights.ReadPermissions rights to call this method.

Applies to

.NET 9 and other versions
Product Versions
.NET 6, 7, 8, 9
.NET Framework 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, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5