{"action":"created","issue":{"url":"https://api.github.com/repos/mj1856/SimpleImpersonation/issues/31","repository_url":"https://api.github.com/repos/mj1856/SimpleImpersonation","labels_url":"https://api.github.com/repos/mj1856/SimpleImpersonation/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/mj1856/SimpleImpersonation/issues/31/comments","events_url":"https://api.github.com/repos/mj1856/SimpleImpersonation/issues/31/events","html_url":"https://github.com/mj1856/SimpleImpersonation/issues/31","id":358503645,"node_id":"MDU6SXNzdWUzNTg1MDM2NDU=","number":31,"title":"Strategy for Process.Start and Impersonation","user":{"login":"SearchForTheCode","id":9859622,"node_id":"MDQ6VXNlcjk4NTk2MjI=","avatar_url":"https://avatars3.githubusercontent.com/u/9859622?v=4","gravatar_id":"","url":"https://api.github.com/users/SearchForTheCode","html_url":"https://github.com/SearchForTheCode","followers_url":"https://api.github.com/users/SearchForTheCode/followers","following_url":"https://api.github.com/users/SearchForTheCode/following{/other_user}","gists_url":"https://api.github.com/users/SearchForTheCode/gists{/gist_id}","starred_url":"https://api.github.com/users/SearchForTheCode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SearchForTheCode/subscriptions","organizations_url":"https://api.github.com/users/SearchForTheCode/orgs","repos_url":"https://api.github.com/users/SearchForTheCode/repos","events_url":"https://api.github.com/users/SearchForTheCode/events{/privacy}","received_events_url":"https://api.github.com/users/SearchForTheCode/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-10T07:41:58Z","updated_at":"2018-09-13T21:37:06Z","closed_at":null,"author_association":"NONE","body":"Hello :)\r\n\r\nI am trying to start a process with different rights from the inside of an windows service.\r\n\r\nIf i impersonate like this:\r\n\r\n```csharp\r\nImpersonation.RunAsUser(credentials, LogonType.Interactive, () => {\r\n                      ProcessStartInfo info = new ProcessStartInfo(cmd_name, parameters);\r\n\r\n                    info.UseShellExecute = false;\r\n                    info.CreateNoWindow = true;\r\n                    info.RedirectStandardOutput = true;\r\n                    console.StartInfo = info;\r\n                    console.Start();\r\n\r\n                    message = console.StandardOutput.ReadToEnd();\r\n                    });\r\n```\r\nthe process will still run as local system. If i set the Credentials also in the ProcessStartInfo Class, i get an Access Denied. \r\n\r\nCurrently i am using an implementation of the native call \"CreateProcessAsUserW\" but i was looking for an working solution with the Process Class of .NET \r\n\r\nThank you :)"},"comment":{"url":"https://api.github.com/repos/mj1856/SimpleImpersonation/issues/comments/421161418","html_url":"https://github.com/mj1856/SimpleImpersonation/issues/31#issuecomment-421161418","issue_url":"https://api.github.com/repos/mj1856/SimpleImpersonation/issues/31","id":421161418,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTE2MTQxOA==","user":{"login":"mj1856","id":1396388,"node_id":"MDQ6VXNlcjEzOTYzODg=","avatar_url":"https://avatars1.githubusercontent.com/u/1396388?v=4","gravatar_id":"","url":"https://api.github.com/users/mj1856","html_url":"https://github.com/mj1856","followers_url":"https://api.github.com/users/mj1856/followers","following_url":"https://api.github.com/users/mj1856/following{/other_user}","gists_url":"https://api.github.com/users/mj1856/gists{/gist_id}","starred_url":"https://api.github.com/users/mj1856/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mj1856/subscriptions","organizations_url":"https://api.github.com/users/mj1856/orgs","repos_url":"https://api.github.com/users/mj1856/repos","events_url":"https://api.github.com/users/mj1856/events{/privacy}","received_events_url":"https://api.github.com/users/mj1856/received_events","type":"User","site_admin":false},"created_at":"2018-09-13T21:37:06Z","updated_at":"2018-09-13T21:37:06Z","author_association":"OWNER","body":"I did some research on this, and I believe that the `ProcessStartInfo` approach will not work in any case - regardless of the execution context - because you are running inside a Windows Service.   All docs and blogs point at `CreateProcessAsUser`, so I would continue that approach.\r\n\r\nI may consider adding another method to this library in the future, such as `Impersonation.StartProcessAsUser` which would make the appropriate calls (either through `ProcessStartInfo` or `CreateProcessAsUser` depending on environment).  I'll leave this issue open to remind me."}}
{"actor":{"display_login":"mj1856"}}