UnauthorizedAccessException when creating a mutex

Given the following code snippet that Mutex uses:

string mutexName = @"Global\MyMutex";

try
{
    _mutex = Mutex.OpenExisting(mutexName, MutexRights.Synchronize);
}
catch (WaitHandleCannotBeOpenedException)
{
    SecurityIdentifier securityIdentifier = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
    MutexSecurity mutexSecurity = new MutexSecurity();
    mutexSecurity.AddAccessRule(new MutexAccessRule(securityIdentifier, MutexRights.Synchronize, AccessControlType.Allow));

    bool dummy = false;

    // Creates the internal Mutex without taking ownership on it.
    _mutex = new Mutex(false, mutexName, out dummy, mutexSecurity);
}

For some of my users, when a Mutex is created (in a catch block), a UnauthorizedAccessException is thrown. I am trying to find the reason for this exception.

Message

Access to the "Global \ MyMutex" path is denied.

I know that some of the users who have the problem are not administrators of their computer. I read on MSDN about Mutex and MutexAccessRule, but it is not clear to me where I can assign or see the Mutex-related permissions for this user.

+3
source share
1 answer

, Mutex, Global\namespace (SeCreateGlobalPrivilege).

, - .

+1

All Articles