I want to set a mutex in one windows account and allow another windows account to access this mutex.
For testing I have two forms that create a mutex using the C# mutex class. I am logging into Windows XP as "User1" and creating and locking the mutex from "User1" using the 1st form. I then use the "switch users" function to log in as "User2" and run the 2nd form and attempt to create the mutex (using the same name). When I try this I get access denied.
I have then tried to use the Win32 classes (as below) but still not working (same problem "access denied"). Any ideas?
namespace MyWin32API
{
// Required SecurityAttributes Structure LPSECURITY_ATTRIBUTES
[StructLayout(LayoutKind.Sequential)]
public class SecurityAttributes
{
public int nLength = Marshal.SizeOf(typeof(SecurityAttributes));
public long lpSecurityDescriptor;
public bool bInheritHandle;
}
public class CWin32
{
// Security Rights Constants - See Winnt.h
public const UInt32 SYNCHRONIZE = 0x00100000;
public const UInt32 STANDARD_RIGHTS_REQUIRED = 0x000F0000;
public const UInt32 MUTANT_QUERY_STATE = 0x0001;
// Security Rights Constants - See winbase.h and winnt.h
public static UInt32 MUTEX_ALL_ACCESS = (SYNCHRONIZE |
STANDARD_RIGHTS_REQUIRED | MUTANT_QUERY_STATE);
//CreateMutex
[DllImport("kernel32.dll", SetLastError=true)]
private static extern UInt32 CreateMutex(SecurityAttributes
lpMutexAttributes, bool InitialOwner, string MutexName);
// Win 32 Masked Method - does not use return handle currently
public UInt32 Win32CreateMutex(bool InitialOwner, string MutexName)
{
SecurityAttributes sa = new SecurityAttributes();
sa.bInheritHandle = false;
sa.lpSecurityDescriptor = CWin32.MUTEX_ALL_ACCESS;
return CWin32.CreateMutex(sa,InitialOwner,MutexName);
}
}
Thank you,
Kris 2 7022
You need to create a DACL containing an ACE's for all trustee's you want to
access the Mutex object, and set the DACL's address in the
SecurityAttributes lpSecurityDescriptor member.
Willy.
"Kris" <an*******@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com... I want to set a mutex in one windows account and allow another windows account to access this mutex.
For testing I have two forms that create a mutex using the C# mutex class. I am logging into Windows XP as "User1" and creating and locking the mutex from "User1" using the 1st form. I then use the "switch users" function to log in as "User2" and run the 2nd form and attempt to create the mutex (using the same name). When I try this I get access denied.
I have then tried to use the Win32 classes (as below) but still not working (same problem "access denied"). Any ideas?
namespace MyWin32API {
// Required SecurityAttributes Structure LPSECURITY_ATTRIBUTES [StructLayout(LayoutKind.Sequential)] public class SecurityAttributes { public int nLength = Marshal.SizeOf(typeof(SecurityAttributes)); public long lpSecurityDescriptor; public bool bInheritHandle; } public class CWin32 {
// Security Rights Constants - See Winnt.h public const UInt32 SYNCHRONIZE = 0x00100000; public const UInt32 STANDARD_RIGHTS_REQUIRED = 0x000F0000; public const UInt32 MUTANT_QUERY_STATE = 0x0001;
// Security Rights Constants - See winbase.h and winnt.h public static UInt32 MUTEX_ALL_ACCESS = (SYNCHRONIZE | STANDARD_RIGHTS_REQUIRED | MUTANT_QUERY_STATE); //CreateMutex [DllImport("kernel32.dll", SetLastError=true)] private static extern UInt32 CreateMutex(SecurityAttributes lpMutexAttributes, bool InitialOwner, string MutexName);
// Win 32 Masked Method - does not use return handle currently public UInt32 Win32CreateMutex(bool InitialOwner, string MutexName) { SecurityAttributes sa = new SecurityAttributes(); sa.bInheritHandle = false; sa.lpSecurityDescriptor = CWin32.MUTEX_ALL_ACCESS;
return CWin32.CreateMutex(sa,InitialOwner,MutexName); } }
Thank you,
Kris
You need to create a DACL containing an ACE's for all trustee's you want to
access the Mutex object, and set the DACL's address in the
SecurityAttributes lpSecurityDescriptor member.
Willy.
"Kris" <an*******@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com... I want to set a mutex in one windows account and allow another windows account to access this mutex.
For testing I have two forms that create a mutex using the C# mutex class. I am logging into Windows XP as "User1" and creating and locking the mutex from "User1" using the 1st form. I then use the "switch users" function to log in as "User2" and run the 2nd form and attempt to create the mutex (using the same name). When I try this I get access denied.
I have then tried to use the Win32 classes (as below) but still not working (same problem "access denied"). Any ideas?
namespace MyWin32API {
// Required SecurityAttributes Structure LPSECURITY_ATTRIBUTES [StructLayout(LayoutKind.Sequential)] public class SecurityAttributes { public int nLength = Marshal.SizeOf(typeof(SecurityAttributes)); public long lpSecurityDescriptor; public bool bInheritHandle; } public class CWin32 {
// Security Rights Constants - See Winnt.h public const UInt32 SYNCHRONIZE = 0x00100000; public const UInt32 STANDARD_RIGHTS_REQUIRED = 0x000F0000; public const UInt32 MUTANT_QUERY_STATE = 0x0001;
// Security Rights Constants - See winbase.h and winnt.h public static UInt32 MUTEX_ALL_ACCESS = (SYNCHRONIZE | STANDARD_RIGHTS_REQUIRED | MUTANT_QUERY_STATE); //CreateMutex [DllImport("kernel32.dll", SetLastError=true)] private static extern UInt32 CreateMutex(SecurityAttributes lpMutexAttributes, bool InitialOwner, string MutexName);
// Win 32 Masked Method - does not use return handle currently public UInt32 Win32CreateMutex(bool InitialOwner, string MutexName) { SecurityAttributes sa = new SecurityAttributes(); sa.bInheritHandle = false; sa.lpSecurityDescriptor = CWin32.MUTEX_ALL_ACCESS;
return CWin32.CreateMutex(sa,InitialOwner,MutexName); } }
Thank you,
Kris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Srijit Kumar Bhadra |
last post by:
Hello,
Here is some sample code with pywin32 build 203 and ctypes 0.9.6.
Best regards,
/Srijit
File: SharedMemCreate_Mutex_win32all.py
# This application should be used with...
|
by: Ken Varn |
last post by:
I have a named mutex object that is accessed by both an asp.net application
and a Windows executable .net application. The Windows executable runs
under the administrator logon, while the asp.net...
|
by: Martin Maat |
last post by:
Hi.
I want to use the same mutex in different classes (web pages in an ASP.NET
application). In global.asax.cs, the class that starts up first, I create a
Mutex like this:
static private...
|
by: Kris |
last post by:
I want to set a mutex in one windows account and allow another windows account to access this mutex.
For testing I have two forms that create a mutex using the C# mutex class. I am logging into...
|
by: Ed Sutton |
last post by:
I use a mutex to disallow starting a second application instance. This
did not work in a release build until I made it static member of my
MainForm class.
In a debug build, first instance got...
|
by: William LaMartin |
last post by:
This code:
Private Shared FileLockMutex As System.Threading.Mutex
Shared Sub New()
FileLockMutex = New System.Threading.Mutex(False,
"MyFileLockMutex")
End Sub
on an aspx page produces the...
|
by: William LaMartin |
last post by:
I posted this in the ASP.net newsgroup with no response, so I will try it
here:
What needs to be changes to make this work? It is on a Windows 2003 shared
server.
This code:
Private...
|
by: tony.newsgrps |
last post by:
Hi there,
I'm trying to understand the impact of killing a process that owns a
system mutex (used to ensure there is only 1 instance of my program
running)
Here is my code pretty much:
try...
|
by: NaeiKinDus |
last post by:
Hello, i'm trying to program a thread that would be locked (by a
mutex) and that would only be unlocked once that a function
(generating data) is done. The purpose is to generate data, and unlock...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |