Is it possible to detect if an application is opened with the runas command?
And how can I detect which user is used?
runas /netonly /user:DOM\usr "C:\App.exe"
Is it possible to detect if an application is opened with the runas command?
And how can I detect which user is used?
runas /netonly /user:DOM\usr "C:\App.exe"
You can check for the user that is running the application, using
System.Security.Principal.WindowsIdentity.GetCurrent()
Note that using /netonly, there is no way to get the supplied credentials on a local process. The LSA takes care of that, and as far as I know, you just can't do it from your local process.
There are some good explanations on why on this link , but the why basically comes down to: while the credentials you supply are stored, they are not even checked until you do any kind of remote authentication (using SSPI), and those are checked only on the actual remote computer.
You can even do:
runas /netonly /user:FAKE\fake something.exe
And the credentials will not even be checked... so you basically don't get an auth token till you do the remote auth
Only solution I can see is trying to run a remote process which will return the user credentials.