可以使用RegistryKey.SetAccessControl(new RegistrySecurity(...))设置新权限。但在那之后,inheritance is turned on。
是否有一种在不打开继承的情况下转让新权利的方法?
整个守则:
void test
{
SecurityIdentifier sidAccUser = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null);
NTAccount ntAccUser = sidAccUser.Translate(typeof(NTAccount)) as NTAccount;
RegistryAccessRule regAcRule = new RegistryAccessRule(
ntAccUser
, RegistryRights.FullControl
, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit
, PropagationFlags.None
, AccessControlType.Allow);
RegistrySecurity regSecurity = new RegistrySecurity();
regSecurity.AddAccessRule(regAcRule);
RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"ZZTEST", true);
// after that the inheritance is turned on
regKey.SetAccessControl(regSecurity);
}我找到了这个解决方案,但不想使用COM-Server:使用C#设置SetACL权限和阻止继承
发布于 2014-07-10 12:52:53
使用SetAccessRuleProtection保护DACL不受继承。
regSecurity.SetAccessRuleProtection(true, false);https://stackoverflow.com/questions/24676812
复制相似问题