You should be able to pass the handle value as an int32 and then create an
IntPtr based on that to create the WindowsIdentity. However, if you don't
want the client doing the work, you probably need to use an approach like
what you are doing.
Just out of curiosity, what does WindowsIdentity.GetCurrent() say after you
do SetThreadToken?
Also, would it be possible instead to have the client invoke a method on the
server that performs the privileged operation? That seems cleaner to me...
Joe K.
> The IPC mechanism is currently either COM or the IPC Remoting channel,
> neither of which seem to be able to pass the token handle (or at least I
> cant figure it out). In any case, the primary reason I want the server to
> change the clients thread, is that I don't want the account the client is
> operating under to have impersonation privilidges.
Robert Ginsburg - 23 Jan 2006 11:27 GMT
Currently I pass in the treadid from GetCurrentThreadID() and the server
successfully calls duplicate token,
then SetThreadToken() on the client thread, however the client thread always
reports the same current user/identity.
There are two problems with calling all of the functions on the server. the
first is interactive UI (the server is running as a service)
, the second is that one of the functions is to evaluate and execute a bunch
of local code that the client has created, some of which should execute in
the callers context, some of which should execute in the context sent to the
caller from the system. The "application logic" works fine if I pass user
names and passwords back and forth instead of access tokena, but it it
tantalizing close (at least no API errors) to working using this technique.
-Robert
> You should be able to pass the handle value as an int32 and then create an
> IntPtr based on that to create the WindowsIdentity. However, if you don't
[quoted text clipped - 15 lines]
>> change the clients thread, is that I don't want the account the client is
>> operating under to have impersonation privilidges.