Starting a process as a different user

  • Thread starter Thread starter Cyron
  • Start date Start date
C

Cyron

Hello Friends,

I am using .NET 2.0 with Visual C#. I see that the Process.Start()
method permits one to launch a new process as another user by
specifying the additional username, password and domain parameters. I
have a service (which runs as SYSTEM) and would like it to launch a
process using the account for the currently logged on user (let us call
this account "User"). Unfortunately, this is not working and I receive
an "Access Denied" exception.

I've googled and found others with the same problem but haven't seen
any solutions. Has anyone been successful with this?

Thanks,

Mike
 
Hello, Cyron!

C> I've googled and found others with the same problem but haven't seen
C> any solutions. Has anyone been successful with this?

Process.Start with UserName specified calls native CreateProcessWithLogonW API.

This win32 api has a limitation under WinXP and Win2003, docs say

"You cannot call CreateProcessWithLogonW from a process that is
running under the LocalSystem account, because the function uses the logon
SID in the caller token, and the token for the LocalSystem account does not
contain this SID. As an alternative, use the CreateProcessAsUser
and LogonUser functions.
"
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top