I need to call one function using maximum privileges (NT AUTHORY\System) from other process (IIS7 module w开发者_如何学JAVAork process) running in same local computer in much less privileged mode (NT AUTHORY\Network service).
IIS module will call that function passing some text (user name) and that function need to return HADNLE type witch will be closed after process using CloseHandle function.
( function: LogonUser http://msdn.microsoft.com/en-us/library/aa378184(VS.85).aspx )
What is the best way to do this? COM+, shared memory, named pipes? I don't have any experience in this programming, so i need some help. I don't know how to pass handle type with named pipes? (i saw only examples that are passing only text based messages, not pointers or other data types).
Handles are not usable across the session boundary. And I'm not 100% sure it is usable across the process boundary for all types of handles.
It's better to for example use pipes to notify the other process who is running with elevated priveleges to get it's own handle and perform whatever operation you want.
As to what is the best method to do the communication, this really depends on your exact needs and your exact experience level in each way.
Just FYI, a HANDLE is just a 32-bit integer value in Windows. It is not a pointer to a memory location.
You can't pass a handle to another process, handles are process local. But you can use DuplicateHandle to create a clone of your handle for use by another process. Only the other process can use the duplicate. The other process is responsible for calling CloseHandle
on it.
精彩评论