this is the code to set Registry full Access and ther is an UnauthorizedAccessException
i need to have access read and write for evey user that login to the server
with out changing registry permissions group policy
SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
NTAccount account_demo = sid.Translate(typeof(NTAccount)) as NTAccount ; (> Option)
NTAccount account = new NTAccount(Environment.UserName);
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(key))
{
RegistrySecurity rs = new RegistrySecurity();
RegistryAccessRule rar = new RegistryAccessRule(
account.ToString(), RegistryRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,AccessControlType.Allow);
rs.AddAccessRule(rar);
rk.SetAccessControl(rs);
}
}
}