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.