May*_*r J 3 c# shared-directory user-permissions
我想用C#编写代码以列出所有有权访问(读/写/完全)服务器上共享文件夹的用户/组。
例如:我有一个共享文件夹\ servername \ MyData。现在,我想列出有权访问此文件夹的用户/组。
这应该使您指向正确的方向,我无法测试它的atm,但应该类似。
private bool CheckAccess(DirectoryInfo directory)
{
// Get the collection of authorization rules that apply to the current directory
AuthorizationRuleCollection acl = directory.GetAccessControl().GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier));
foreach (var rule in acl)
{
// do something here
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3923 次 |
| 最近记录: |