gpt4 book ai didi

c# - 每个人都在 Windows 8 中

转载 作者:行者123 更新时间:2023-11-30 16:17:19 25 4
gpt4 key购买 nike

我正在开发应在 Windows 8 和 7 上运行的 .net 3.5 应用程序。

作为应用程序的一部分,我在 C:\ProgramData 下创建了一个新文件夹。

创建文件夹后,我设置了以下 ACL - 允许所有人读写。

 var directorySecurity = directoryInfo.GetAccessControl();
var worldSecurityIdentifier = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
directorySecurity.AddAccessRule(new FileSystemAccessRule(worldSecurityIdentifier, FileSystemRights.Read, AccessControlType.Allow));
directorySecurity.AddAccessRule(new FileSystemAccessRule(worldSecurityIdentifier, FileSystemRights.Write, AccessControlType.Allow));

在 Windows 8 上,我遇到以下行为:如果我将文件复制到该目录,当我查看文件属性中的安全选项卡时,这就是我所看到的。

Security tab of a file that was copied into the directory

我不明白这个用户是谁以及它是如何创建的。还有我为每个人定义的 ACL 在哪里?

似乎这个未知的 SID 获得了我为 Everyone 设置的 ACL。

我怀疑这可能是因为我在 .net 3.5 而不是 4 上开发,但是当我将目标框架更改为 4 时它没有帮助。

当我在调试时检查什么是 worldSecurityIdentifier,这就是我得到的

enter image description here

谁能帮我解决这个问题?

最佳答案

尝试:

directorySecurity.AddAccessRule(
new FileSystemAccessRule(
worldSecurityIdentifier,
FileSystemRights.Read | FileSystemRights.Write,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));

这将设置 ACE,使其由子对象继承。

关于c# - 每个人都在 Windows 8 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17326700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com