RegistryKey разрешения - C#
Формулировка задачи:
Возможно ли через RegistryKey перечислить привилегии?
Решение задачи: «RegistryKey разрешения»
textual
Листинг программы
- public static void ViewRegKeyRights()
- {
- // Get security information from a registry key.
- using (RegistryKey regKey =
- Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MyCompany\MyApp"))
- {
- RegistrySecurity regSecurity = regKey.GetAccessControl();
- DisplayRegKeySecurityInfo(regSecurity);
- }
- }
- public static void DisplayRegKeySecurityInfo(RegistrySecurity regSec)
- {
- Console.WriteLine("GetSecurityDescriptorSddlForm: {0}",
- regSec.GetSecurityDescriptorSddlForm(AccessControlSections.All));
- foreach (RegistryAccessRule ace in
- regSec.GetAccessRules(true, true, typeof(NTAccount)))
- {
- Console.WriteLine("\tIdentityReference.Value: {0}",
- ace.IdentityReference.Value);
- Console.WriteLine("\tAccessControlType: {0}", ace.AccessControlType);
- Console.WriteLine("\tRegistryRights: {0}", ace.RegistryRights.ToString());
- Console.WriteLine("\tInheritanceFlags: {0}", ace.InheritanceFlags);
- Console.WriteLine("\tIsInherited: {0}", ace.IsInherited);
- Console.WriteLine("\tPropagationFlags: {0}", ace.PropagationFlags);
- Console.WriteLine("-----------------\r\n\r\n");
- }
- foreach (RegistryAuditRule ace in
- regSec.GetAuditRules(true, true, typeof(NTAccount)))
- {
- Console.WriteLine("\tIdentityReference.Value: {0}",
- ace.IdentityReference.Value);
- Console.WriteLine("\tAuditFlags: {0}", ace.AuditFlags);
- Console.WriteLine("\tRegistryRights: {0}", ace.RegistryRights.ToString());
- Console.WriteLine("\tInheritanceFlags: {0}", ace.InheritanceFlags);
- Console.WriteLine("\tIsInherited: {0}", ace.IsInherited);
- Console.WriteLine("\tPropagationFlags: {0}", ace.PropagationFlags);
- Console.WriteLine("-----------------\r\n\r\n");
- }
- Console.WriteLine("GetGroup(typeof(NTAccount)).Value: {0}",
- regSec.GetGroup(typeof(NTAccount)).Value);
- Console.WriteLine("GetOwner(typeof(NTAccount)).Value: {0}",
- regSec.GetOwner(typeof(NTAccount)).Value);
- Console.WriteLine("---------------------------------------\r\n\r\n\r\n");
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д