非英语操作系统中Everyone组的名称

发布于 2024-07-10 05:56:19 字数 234 浏览 8 评论 0原文

我们创建 Mutex 的方式存在问题。 问题是:

MutexAccessRule rule = new MutexAccessRule("Everyone", MutexRights.FullControl, AccessControlType.Allow);

硬编码的“Everyone”字符串仅适用于英语操作系统,我们如何更改此行以便它适用于所有语言?

We have an issue with the way we are creating a Mutex. The problem line is:

MutexAccessRule rule = new MutexAccessRule("Everyone", MutexRights.FullControl, AccessControlType.Allow);

The hardcoded "Everyone" string only works on English OSes, how do we change this line so it works in all languages?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧伤还要旧人安 2024-07-17 05:56:19

Google 今天很有帮助:

看起来这会有所帮助

此代码解决了此问题:

  SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
  MutexAccessRule rule = new MutexAccessRule(sid, MutexRights.FullControl, AccessControlType.Allow);

VB:

Dim sid As System.Security.Principal.SecurityIdentifier = New System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, Nothing)
Dim rule As System.Security.AccessControl.MutexAccessRule = New System.Security.AccessControl.MutexAccessRule(sid, System.Security.AccessControl.MutexRights.FullControl, System.Security.AccessControl.AccessControlType.Allow)

Google is being helpful today:

Looks like this will help

This code solves this problem:

  SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
  MutexAccessRule rule = new MutexAccessRule(sid, MutexRights.FullControl, AccessControlType.Allow);

VB:

Dim sid As System.Security.Principal.SecurityIdentifier = New System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, Nothing)
Dim rule As System.Security.AccessControl.MutexAccessRule = New System.Security.AccessControl.MutexAccessRule(sid, System.Security.AccessControl.MutexRights.FullControl, System.Security.AccessControl.AccessControlType.Allow)
木森分化 2024-07-17 05:56:19

我遇到了同样的问题,但需要“Everyone”组名称的实际本地化字符串才能访问 MessageQueue。 这是我找到的解决方案,效果很好:

SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var acct = sid.Translate(typeof(NTAccount)) as NTAccount;
myMessageQueue.SetPermissions(acct.ToString(), MessageQueueAccessRights.FullControl); 

I had the same problem, but needed the actual localized string of the "Everyone" group name in order to enable access to a MessageQueue. Here's the solution I found, which works fine:

SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var acct = sid.Translate(typeof(NTAccount)) as NTAccount;
myMessageQueue.SetPermissions(acct.ToString(), MessageQueueAccessRights.FullControl); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文