I'm developing an application to run some default steps my co workers have to do, but i'm the only one which have the admin's password and my app need admin privileges, but i can't log in everytime for them...

I though in create a function to self elevate my program or launch it with the admin credential, but i can't find anything about without passing the user and password as parameters to third part applications, and this can easily tracked.

Does anyone know how to deal with this?

有帮助吗?

解决方案

You can either:

  1. use LogonUser() to login to the desired user account, then ImpersonateLoggedOnUser() to have the calling thread impersonate that user before performing the desired tasks, and then RevertToSelf() when finished to stop impersonating.

  2. move the admin tasks to a separate process, and then use LogonUser() and CreateProcessAsUser(), or alternatively CreateProcessWithLogonW(), to launch that process using the user credentials when needed.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top