1
我在Active Directory中四組:使用域組ACL C#
- 只讀
- 用戶
- 經理
- 合作伙伴
而且,我有一個Windows Server (2012)其中包含一些文件夾:
- 管理
- 公共
- 限制
- 規劃
- Ressources
如何使用這些廣告組在此服務器上應用訪問規則,在我的C#應用程序?
我在Active Directory中四組:使用域組ACL C#
而且,我有一個Windows Server (2012)其中包含一些文件夾:
如何使用這些廣告組在此服務器上應用訪問規則,在我的C#應用程序?
有辦法做到這一點!
AD組有這樣的特性:
group.properties["objectSID"];
我用它來:
SecurityIdentifier readOnlySID = new SecurityIdentifier(group.Properties["objectSID"][0] as byte[], 0);
最後:
FileSystemAccessRule(readOnlySID, FileSystemRights.Read, AccessControlType Allow);
這是管理ACL爲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
我想只使用C#:/ –
@BaptisteMarcos對不起,沒有辦法做到這一點W/O PowerShell –
@BaptisteMarcos你想看看這裏嗎?https://stackoverflow.com/questions/23780010 /共享-一個文件夾的許可,在-C-尖銳 –