Mapping generic access rights to object specific rights.

Firstly, thank you for the AccessControl namespace in .NET 2.0. This new class will make manipulating security in .NET far easier.

I noticed that when you call the GetAccessControl function from an object, no mapping from generic access rights (eg. GENERIC_READ to FILE_GENERIC_READ) is done.

The resultant access control list therefore returns duplicated ACEs everytime (one which represents the specific right, one which represents the generic right which propagates to children).

For example: calling

{
Microsoft.Win32.RegistryHive Hive = (Microsoft.Win32.RegistryHive)
(this.regHiveSelect.SelectedValue);
/* =="LocalMachine" */
string ComputerName =this.computerEdit.Text.Trim("//\\".ToCharArray'" href="'file://\\".ToCharArray'">\\".ToCharArray());
/* ==System.Environment.MachineName */
Microsoft.Win32.RegistryKey regKey
= Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Hive, ComputerName);
regKey = regKey.OpenSubKey(this.regKeyEdit.Text, true);
/* =="SOFTWARE\Microsoft" */
regKey.GetAccessControl();
}

returns D:AI(A;ID;KR;;;BU)(A;CIIOID;GR;;;BU)(A;ID;CCDCLCSWRPSDRC;;;PU)(A;CIIOID;SDGWGR;;;PU)(A;ID;KA;;;BA)(A;CIIOID;GA;;;BA)(A;ID;KA;;;SY)(A;CIIOID;GA;;;SY)(A;CIIOID;GA;;;CO).

Notice the first two ACEs which are:
Inherited Allow to KEY_READ to Users
Inherited Allow to GENERIC_READ to Users (CI IO OI)

When displayed to the user, I am expected to remap the generic access rights into specific rights for the object. This will allow the 2 access masks to be combined. However, I don't know of any .NET framework classes that can remap these access rights for the object. I'm looking for a class that maintains a GENERIC_MAPPING structure for registry rights, and calls MapGenericMask to remap the generic rights. Does anyone know how to do this without p/invoke?

[2248 byte] By [OShah] at [2007-12-16]
# 1

As far as I know, managed access control does not have this functionality. It will be up to each individual integrator (in this case the Registry integrator that sits on top of BCL's Managed Access Control) to do the work.

However, this is an interesting ask and we can consider it for net release so that the integrator can hide the mapping and get a simple and uniform behavior for callers.

Thanks for the input.

ShawnWu at 2007-8-21 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified