Reputation: 131142
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?
Upvotes: 8
Views: 2449
Reputation: 41
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);
Upvotes: 4
Reputation: 131142
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)
Upvotes: 14