tags:

views:

190

answers:

1

On my local machine I am running an administrative c# service as LocalSystem called Serv.exe which performs various tasks. One of the tasks it needs to perform is to launch an application under the USER account (currently logged on), not as admin - as this violates security.

The obvious solution would be simple impersonation when launching the application - however I run into a small problem whereas I am not priviledged to the user account credentials (Username & Password) and therefore am unable to impersonate in the conventional way.

So, using a C# service running as LocalSystem when logged on to a User account - is there anyway I can launch an application as that User?

From the comments:
what happens is that the Application itself asks the Service to do a job and then terminates. when the job is funished the application must restart itself - I thought the best way would be to have the service restart it when it was done ...

Any help would be greatly appreciated. Thanks,

A: 

Instead of breaching security this way you can make the application wait and then restart itself. See this SO question and this one.

Henk Holterman
I get the idea - but not sure if this will work for me - I have a service which does a job, while the job is being performed the application must be closed, when the job is done the application must start.So, using a second application means that somehow my Service musr communicate back to it in order to restart the primary application - seems like a big amount of overhead ... but if this is the standard approach I'll investigate.
Shaitan00
You can make the original app a 2-stage affair where the first stage waits if the server is busy.
Henk Holterman
Sadly I cannot make any fundamental changes to the original app as it is legacy software running old C++ which I do not have access to ...
Shaitan00
Then you will need a monitoring app. Could make it more robust too.
Henk Holterman
What about:•by duplicating an existing token with CreateRestrictedToken, DuplicateToken, or DuplicateTokenEx.•by opening the token from another process or thread, that already is loggen on as the user, with OpenProcessToken or OpenThreadToken
Shaitan00