Search code examples
c#globalization

The name of the Everyone group in non-english OSs


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?


Solution

  • 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)