Я пытаюсь создать консольное приложение C# для управления разрешениями аудита в домене (а не в файловой системе). Моя проблема в том, что я не могу прочитать существующие правила аудита в C#, я получаю только пустую коллекцию, хотя я уверен, что в домене есть правила аудита.
Мне нужно управлять более 100+ независимых доменов, поэтому я хочу найти программное решение для управления ими.
Я могу без проблем сделать это в PowerShell, используя следующую команду.
< бр />
Код: Выделить всё
$acl = Get-Acl -Path "DC=mydomain,DC=local" -Audit
$acl.Audit
Код: Выделить всё
string path = "LDAP://mydomain.local/DC=mydomain,DC=local";
DirectoryEntry domain = new DirectoryEntry(path);
AuthorizationRuleCollection authorizationRuleList1 = domain.ObjectSecurity.GetAuditRules(true, true, typeof(NTAccount));
AuthorizationRuleCollection authorizationRuleList2 = domain.ObjectSecurity.GetAuditRules(true, true, typeof(System.Security.Principal.SecurityIdentifier));
Console.WriteLine("Authorization Rules 1: " + authorizationRuleList1.Count);
Console.WriteLine("Authorization Rules 2: " + authorizationRuleList2.Count);
Я пробовал
[*]явно применить пароль для DirectoryEntry< /code> инициализация
[*]Запуск от имени администратора
[*]Проверка наличия разрешений аудита с помощью проводника LDAP
< /ol>
Будем очень признательны за любые указатели.
Обновлен код с использованием ActiveDs для получения дескриптора безопасности.
Код: Выделить всё
string path = "LDAP://demo.local/DC=demo,DC=local";
DirectoryEntry domain = new DirectoryEntry(path);
var ntSecurityDescriptor = domain.Properties["ntSecurityDescriptor"];
ActiveDs.ADsSecurityUtility secUtility = new ActiveDs.ADsSecurityUtility();
ActiveDs.IADsSecurityDescriptor sd = (IADsSecurityDescriptor)ntSecurityDescriptor[0];
ActiveDs.IADsAccessControlList aclList = ActiveDs.IADsAccessControlList)sd.DiscretionaryAcl;
Источник: https://stackoverflow.com/questions/781 ... hough-audi