是否可以将永久性小组设置为文件?

发布于 2025-02-02 03:07:15 字数 1245 浏览 2 评论 0 原文

我有一个文件,我试图将其主要组更改为 localsystemsid s-1-5-32-544 ), a>函数。
只要程序正在运行,它都可以正常工作。
当我再次启动程序时,主组返回为 s-1-5-21-<域> -513 (使用
getgroup getGroup ):

string path = @"c:\tmp\myfile.txt";
FileSecurity accessControl = new FileInfo(path).GetAccessControl();
// S-1-5-32-544
IdentityReference localSystemGroup = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null);

// S-1-5-21-<domain>-513
IdentityReference group = accessControl.GetGroup(typeof(SecurityIdentifier));
// Primary group changed to S-1-5-32-544
accessControl.SetGroup(localSystemGroup);

// Next run it will become S-1-5-21-<domain>-513 again

IS是否可以将主要群体变为永久?因此,下次我将调用 getGroup 它将返回 localsystemsid S-1-1-5-32-544 )?

I have a file that I am trying to change its primary group to LocalSystemSid (S-1-5-32-544) with the SetGroup function.
It works fine as long as the program is running.
When I start the program again, the primary group returns to be S-1-5-21-<domain>-513 (checked with GetGroup):

string path = @"c:\tmp\myfile.txt";
FileSecurity accessControl = new FileInfo(path).GetAccessControl();
// S-1-5-32-544
IdentityReference localSystemGroup = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null);

// S-1-5-21-<domain>-513
IdentityReference group = accessControl.GetGroup(typeof(SecurityIdentifier));
// Primary group changed to S-1-5-32-544
accessControl.SetGroup(localSystemGroup);

// Next run it will become S-1-5-21-<domain>-513 again

Is it possible to change the primary group to be permanent? So next time I will call GetGroup it will return LocalSystemSid (S-1-5-32-544)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文