Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2007

Tip: Looking for answers? Try searching our database.

New Mutex constructor with MutexSecurity

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steven Kilby - 21 Sep 2007 08:42 GMT
Hi,

With .NET 2.0 a new Mutex constructor was added that takes a MutexSecurity
object as a parameter.  The interesting thing is the following statement
from the MSDN documentation:

If the named mutex has already been created with access control security,
and the caller does not have MutexRights.FullControl, an exception is
thrown.

I wrote two test programs.  The first runs as an Administrator and calls the
constructor with a MutexSecurity object that contains an Allow rule for
'Everyone' with MutexRights.Synchronize | MutexRights.Modify.  The second
program runs as a normal user and also calls the constructor.  Based on the
MSDN documentation I would expect an exception when the second program runs,
but it works fine.  Things got more odd when I added a deny rule for
'Everyone' with MutexRights.FullControl.  With that, I got the exception I
expected.  That implies the default rule for a MutexSecurity object is
FullControl, but I know that isn't true.

Can anyone explain the behavior I am seeing?

Thanks!
Steven
Michael Nemtsev, MVP - 21 Sep 2007 12:12 GMT
Hello Steven,

Did you create global mutex?

---
WBR,
Michael  Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour 

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

SK> MutexSecurity object as a parameter. The interesting thing is the
SK> following statement from the MSDN documentation:
SK>
SK> If the named mutex has already been created with access control
SK> security, and the caller does not have MutexRights.FullControl, an
SK> exception is thrown.
SK>
SK> I wrote two test programs. The first runs as an Administrator and
SK> calls the constructor with a MutexSecurity
SK>
Steven Kilby - 21 Sep 2007 20:19 GMT
Hi,

Yes, the mutex is global.  AFAIK the MSDN documentation doesn't call out
global mutexes as a special case.  Is there a difference?

Thanks
Steven

<Michael Nemtsev>; "MVP" <nemtsev@msn.com> wrote in message
news:3d9fba1a6d298c9caab38fdf090@msnews.microsoft.com...
> Hello Steven,
>
[quoted text clipped - 14 lines]
> SK> calls the constructor with a MutexSecurity
> SK>
Michael Nemtsev, MVP - 22 Sep 2007 10:17 GMT
Hello Steven,

SK> I wrote two test programs. The first runs as an Administrator and
SK> calls the constructor with a MutexSecurity object that contains an
SK> Allow rule for 'Everyone' with MutexRights.Synchronize |
SK> MutexRights.Modify. The second program runs as a normal user and
SK> also calls the constructor. Based on the MSDN documentation I would
SK> expect an exception when the second program runs, but it works fine.

Could your refer to the documentation which implies this?

See MutexAccessRule class sample

what is u doing just allows user to have access, not block the user

       // Add a rule that grants the current user the
       // right to enter or release the mutex.
       MutexAccessRule rule = new MutexAccessRule(user,
           MutexRights.Synchronize | MutexRights.Modify,
           AccessControlType.Allow);
       mSec.AddAccessRule(rule);

---
WBR,
Michael  Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour 

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Steven Kilby - 22 Sep 2007 15:04 GMT
Hi,

The documentation is at:
http://msdn2.microsoft.com/en-us/library/9zf2f5bz.aspx.  If that link
doesn't work you can find it by using these search terms in Google: "Mutex
MutexRights.FullControl".  The relevant text from this page is:

If the named mutex has already been created with access control security,
and the caller does not have
System.Security.AccessControl.MutexRights.FullControl, an exception is
thrown. To open an existing named mutex with only those permissions needed
for synchronizing thread activities, see the OpenExisting method.

Thanks
Steven

<Michael Nemtsev>; "MVP" <nemtsev@msn.com> wrote in message
news:3d9fba1a73978c9cb6469050490@msnews.microsoft.com...
> Hello Steven,
>
[quoted text clipped - 22 lines]
> "The greatest danger for most of us is not that our aim is too high and we
> miss it, but that it is too low and we reach it" (c) Michelangelo

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.