The name of the Everyone group in non-English OS

We have a problem with the way we create Mutex . Problem line:

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

The hard-coded string "Everyone" works only on English OS, how can we change this string so that it works in all languages?

+7
c # globalization
source share
2 answers

Google is useful today:

This seems to 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) 
+12
source share

I had the same problem, but I need the actual localized string for the Everyone group name to allow access to MessageQueue. Here's a solution that works fine:

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

All Articles