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.Synchronize | MutexRights.Modify | MutexRights.ReadPermissions,AccessControlType.Allow);
mSec.RemoveAccessRuleSpecific(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);
}
}
}