【问题标题】:Displaying permissions of a folder for all users and groups using C# Programatically以编程方式使用 C# 显示所有用户和组的文件夹权限
【发布时间】:2014-01-24 22:12:45
【问题描述】:

我正在处理一个要求,我需要使用 C# 以编程方式为所有用户和组显示文件夹的权限。

这里是代码,我正在使用它:

 DirectorySecurity filesecure = Directory.GetAccessControl(txtPath.Text);

 StringBuilder strbldACLlist = new StringBuilder();

 filesecure.GetSecurityDescriptorSddlForm(AccessControlSections.All);

 foreach (FileSystemAccessRule ace in filesecure.GetAccessRules(true, true, typeof(NTAccount)))
                {
                    strbldACLlist.Append(ace.FileSystemRights + ":" + ' ' + ace.IdentityReference.Value + "\n");
                }

我得到这样的输出:

"ReadAndExecute, Synchronize: dm1\\55555\nFullControl: dm1\\343556\n268435456: dm1\\343556\nFullControl: NT AUTHORITY\\SYSTEM\n268435456: NT AUTHORITY\\SYSTEM\nFullControl: BUILTIN\\Administrators\n268435456: BUILTIN\\Administrators\n"

在这里,对于第一个用户,我获得了正确的文件权限。但是,如果您看到第二个用户 ID 即 343556 ,我会得到两次结果,因为您可以第一次看到完全控制和一些我不理解的数字 n268435456 .

谁能分析输出并解释实际发生的情况..

【问题讨论】:

    标签: c# permissions directory


    【解决方案1】:

    看看here。它是说 FileSystemAccessRights 是一个 Flags 枚举(即它的值可以是或-ed)。您得到的实际数字 268435456 - 是一个没有提供名称的组合。

    干杯-

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-03
      • 2011-04-23
      • 1970-01-01
      • 1970-01-01
      • 2010-10-25
      • 2012-07-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多