473,408 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

EventWaitHandle - UnauthorizedAccessException

Hi all!

I'm trying to use a named EventWaitHandle to signal events between processes
that run on the same computer. One of them is a service running as SYSTEM and
the other one is a normal user. Creating the handle seems to be no problem,
but when the other process is calling EventWaitHandle.OpenExisting with the
same name, an UnauthorizedAccessException is thrown with the message "Access
to the path is denied.".

Any idea on how to make it work? I'm completely clueless on this one...

- Kristoffer -

Apr 12 '06 #1
5 8905
Hello, Kristoffer!

KP> I'm trying to use a named EventWaitHandle to signal events between
KP> processes that run on the same computer. One of them is a service
KP> running as SYSTEM and the other one is a normal user. Creating the
KP> handle seems to be no problem, but when the other process is calling
KP> EventWaitHandle.OpenExisting with the same name, an
KP> UnauthorizedAccessException is thrown with the message "Access to the
KP> path is denied.".

What process is calling EventWaitHandle.OpenExisting? Service or application under common user?

Can you post code, where you create and initialize EventWaitHandle object?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Apr 12 '06 #2
When I test it, I start the executable first and then the service. If the
executable is running as an administrator, there is no problem. If it is a
normal user, the service will fail to open the existing event.

( If I start the service first, then the program as a normal user, then the
program will fail at an earlier stage, when a mutex is created with mutex =
new System.Threading.Mutex(false, "MyMutexName"); )

The code I use is taken from the help on the
EventWaitHandle.SetAccessControl method. I took Main, made it a public static
method with the name as an inparam and removed the deny rule on Synchronize
and Modify when the named event is created.

So, I guess the problem is to figure out how to give the normal user access
to work with a named Mutex/EventWaitHandle...

- Kristoffer -

"Vadym Stetsyak" wrote:
Hello, Kristoffer!

KP> I'm trying to use a named EventWaitHandle to signal events between
KP> processes that run on the same computer. One of them is a service
KP> running as SYSTEM and the other one is a normal user. Creating the
KP> handle seems to be no problem, but when the other process is calling
KP> EventWaitHandle.OpenExisting with the same name, an
KP> UnauthorizedAccessException is thrown with the message "Access to the
KP> path is denied.".

What process is calling EventWaitHandle.OpenExisting? Service or application under common user?

Can you post code, where you create and initialize EventWaitHandle object?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot

Apr 13 '06 #3
Ahh... simple when you know the answer...

To create a named Mutex or EventWaitHandle that can be shared between users,
you should create Allow access rules for the identity "Everyone".

EventWaitHandleSecurity ewhSec =
new EventWaitHandleSecurity();

EventWaitHandleAccessRule rule =
new EventWaitHandleAccessRule("Everyone",
EventWaitHandleRights.Synchronize |
EventWaitHandleRights.Modify,
AccessControlType.Allow);
ewhSec.AddAccessRule(rule);

ewh = new EventWaitHandle(false,
EventResetMode.AutoReset,
ewhName,
out wasCreated,
ewhSec);

- Kristoffer -

Apr 13 '06 #4
Hello, Kristoffer!

KP> ( If I start the service first, then the program as a normal user, then
KP> the program will fail at an earlier stage, when a mutex is created with
KP> mutex = new System.Threading.Mutex(false, "MyMutexName"); )

What is the problem here? What exception is being thrown?
I suppose that mutex object is already created by the service without ( default ) mutex security.

To open mutex you can use same approach as for EventWaitHandle. That is Mutex.OpenExisting(...)
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Apr 13 '06 #5
Hello, Kristoffer!

KP> To create a named Mutex or EventWaitHandle that can be shared between
KP> users, you should create Allow access rules for the identity
KP> "Everyone".

I think using "Everyone" is not secure, it will be better to limit it to particular user.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Apr 13 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Doug Taylor | last post by:
Hi, I originally posted this in dotnet.security, but have moved it here by request: Hi, I am trying to programmatically add a user with read permissions to the DACL of a registry key. ...
4
by: ASP Yaboh | last post by:
I have app that writes text files to any location of the users choosing in the network. It has been working for 18months. An exception has begun occurring where a folder on a network share is...
2
by: GM | last post by:
Any help is greatly appreciated! I'm up against a meeting deadline. Directory.CreateDirectory Method throws UnauthorizedAccessException Here is the path: ...
1
by: Hal 9000 | last post by:
In c# we have a function that creates a virtual directory in IIS 6.0 using DirectoryServices API. The code looks like this: // log in to IIS DirectoryEntry rootDir = new...
12
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files...
0
by: nime | last post by:
I've got a problem. I cannot debug my app. which one contains WebBrowser control. I found a resolution but it's for an ASP related problem. I couldn't find a correct "user" to give permisson then...
1
by: =?Utf-8?B?VHJlY2l1cw==?= | last post by:
Hello, Newsgroupians: I'm still trying to work on synchronization of events. I think I can do it using WaitHandle, EventWaitHandle, or Mutex. However, is it possible to determine if the state...
2
by: swartzbill2000 | last post by:
Hello, I am using a VB.Net COM library to provide multi-threading to an existing VB6 app. Library functions that start background operations create an EventWaitHandle to be used to cancel the...
8
by: imukai | last post by:
I have a forms-based authentication application on our intranet - ASP.NET 3.5 (C#). For security purposes there is one specific .aspx file that we have enabled Integrated Windows Authentication...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.