Add a rule that allows the current user the right to read permissions on the mutex. : MutexSecurity « Security « C# / CSharp Tutorial






using System;
using System.Threading;
using System.Security.AccessControl;
using System.Security.Principal;

public class Example
{
    public static void Main()
    {
        string user = Environment.UserDomainName + "\\" + Environment.UserName;
        MutexSecurity mSec = new MutexSecurity();
        MutexAccessRule ruleA = new MutexAccessRule(user,MutexRights.Synchronize | MutexRights.Modify,AccessControlType.Allow);
        mSec.AddAccessRule(ruleA);


        MutexAccessRule rule = new MutexAccessRule(user,MutexRights.ReadPermissions,AccessControlType.Allow);
        mSec.AddAccessRule(rule);


        foreach(MutexAccessRule ar in mSec.GetAccessRules(true, true, typeof(NTAccount)))
        {
            Console.WriteLine("User: {0}", ar.IdentityReference);
            Console.WriteLine("Type: {0}", ar.AccessControlType);
            Console.WriteLine("Rights: {0}", ar.MutexRights);
        }
    }
}








35.21.MutexSecurity
35.21.1.MutexSecurity and MutexAccessRule
35.21.2.Add a rule that allows the current user the right to read permissions on the mutex.