[英]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.