AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1123245
Accepted
Legenda
Legenda
Asked: 2023-02-19 13:20:17 +0800 CST2023-02-19 13:20:17 +0800 CST 2023-02-19 13:20:17 +0800 CST

通过代码成功修改了用户组的权限,但更改未反映在用户组的安全选项卡中

  • 772

我有 C# 代码(最后):

  1. 创建一个文件
  2. 打印当前 ACL
  3. 授予内置用户组对先前创建的文件的“写入权限”
  4. 打印当前修改的 ACL

如您在控制台输出中所见,写入权限已通过代码成功分配。

在此处输入图像描述

我的问题是:为什么文件的安全选项卡不反映用户组的权限更改?

在此处输入图像描述

C#代码:

var file = "sectest.txt";
File.WriteAllText(file, "File security test.");
var sid = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null);

string strBuiltInUsersAccount = sid.Translate(typeof(NTAccount)).ToString();
  
FileSecurity fileSecurity = new FileSecurity(file,
AccessControlSections.Owner |
AccessControlSections.Group |
AccessControlSections.Access);

Console.WriteLine("AFTER CREATE:");

ShowSecurity(fileSecurity); // BUILTIN\Users group doesn't have Write permission

// short: give "builtin\users" write permissions
var fsAccessRule = new FileSystemAccessRule(strBuiltInUsersAccount,
                                            FileSystemRights.Write,
                                            AccessControlType.Allow);

fileSecurity.ModifyAccessRule(AccessControlModification.Add, fsAccessRule, out bool modified);

Console.WriteLine();

Console.WriteLine("AFTER MODIFY:");
ShowSecurity(fileSecurity); // BUILTIN\Users has Write permission
security
  • 1 1 个回答
  • 18 Views

1 个回答

  • Voted
  1. Best Answer
    Greg Askew
    2023-02-20T04:48:00+08:002023-02-20T04:48:00+08:00

    这只会修改 ACE 中的单一访问规则。然后需要将其保存到文件中。请参阅 File.SetAccessControl(文件路径,文件安全)

    https://learn.microsoft.com/en-us/dotnet/api/system.security.accesscontrol.filesecurity?view=net-7.0

    • 1

相关问题

  • OpenSSH 漏洞 [重复]

  • 选择什么安全套件?

  • 安全地授予对 SQL 2005 复制监视器的访问权限以创建快照

  • SSH 服务器零日漏洞利用 - 保护自己的建议

  • 如何将安全组添加到正在运行的 EC2 实例?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve