[英]Use domain group for ACL C#
我的活動目錄中有四個組:
而且,我有一個Windows Server(2012),其中包含一些文件夾:
如何在我的C#應用程序中使用這些AD組在此服務器上應用訪問規則?
我已經制作了程序,將數據插入C#並導出到Powershell文件並運行它
這是用於寫權限的powershell代碼
$acl = Get-Acl "\\Server\Testshare"
$acl.SetAccessRuleProtection($False,$false)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule('Server_Testshare_local','modify','ContainerInherit,ObjectInherit','None','Allow')
$acl.AddAccessRule($rule)
Set-Acl "\\Server\Testshare" $acl
並閱讀權利
$acl = Get-Acl "\\Server\Testshare"
$acl.SetAccessRuleProtection($False,$false)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule('Server_Testshare_Read local','ReadAndExecute','ContainerInherit,ObjectInherit','None','Allow')
$acl.AddAccessRule($rule)
Set-Acl "\\Server\Testshare" $acl
有一種方法可以做到!
廣告組具有以下屬性:
group.properties["objectSID"];
我用它來:
SecurityIdentifier readOnlySID = new SecurityIdentifier(group.Properties["objectSID"][0] as byte[], 0);
最后:
FileSystemAccessRule(readOnlySID, FileSystemRights.Read, AccessControlType Allow);
這是管理AD組ACL的唯一方法!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.