You can either:
use
LogonUser()
to login to the desired user account, thenImpersonateLoggedOnUser()
to have the calling thread impersonate that user before performing the desired tasks, and thenRevertToSelf()
when finished to stop impersonating.move the admin tasks to a separate process, and then use
LogonUser()
andCreateProcessAsUser()
, or alternativelyCreateProcessWithLogonW()
, to launch that process using the user credentials when needed.