i’m developing a windows service. one of this step is to run an external process, using username and password of an account.
In order to do this, i use windows API:
- LogonUserA: i provide username and password, and i get back a token
- CreateProcessAsUserA: i provide application path and of course the token.
Even if the given account is an admin account, the application doesn’t start “as administrator”.
I need to accomplish with task, considering that i’m inside a windows service, than UAC should not be involved.
i also tried to use DuplicateTokenEx in this way:
DuplicateTokenEx(currentProcessToken, WinNT.TOKEN_ALL_ACCESS, null, SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation,
WinNT.TOKEN_TYPE.TokenPrimary, pExecutionToken)
but without success.
Please could anyone help me?
DuplicateTokenEx(currentProcessToken, WinNT.TOKEN_ALL_ACCESS, null, SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation,
WinNT.TOKEN_TYPE.TokenPrimary, pExecutionToken)
Stefano Manni stefanomnn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.