0

I have a windows service running under a user account other than LocalSystem, let's assume the user mydomain\svcUser.

The service spawns a new process P using Process.Start(...). The process P makes usage of the default Outlook Profile defined under user mydomain\procUser. Works fine.

Now, I need to spawn the same process P under a new user: mydomain\procUser that basically has the same priviledges as mydomain\svcUser.

I tried to use CreateProcessAsUser in many ways after obtaining the token with LogonUser but it just won't work.

Now, if I change the Log On user of my process to mydomain\procUser then the spawned process P has all the required rights and environment stuff to work properly.

I am pretty lost on how to combine the parameters to be passed to LogonUser and CreateProcessAsUser so that I can be able to keep the service running under mydomain\svcUser but the spawned process P to work properly under mydomain\procUser.

This link is very helpful, but it's only a great guideline article, the success depends on how to use the flags and other stuff when calling LogonUser and CreateProcessAsUser.

Adi
  • 5,113
  • 6
  • 46
  • 59

1 Answers1

0

Use the overload of Process.Start that takes in user credentials

public static Process Start(
string fileName,
string userName,
SecureString password,
string domain
)

See here

Allan Elder
  • 4,052
  • 17
  • 19
  • this was my first try, of course, and it didn't work... something is different on how the windows service is started under the Log On account comparing on various methods of launching the process and I cannot figure exactly what – Adi Oct 14 '14 at 14:03