I have an application that needs to be elevated if being run by a standard user. My problem is that when I get the username it will get the Username of the admin who elevated the program. I can not seem to find a way around this, any ideas?
Get Username around UAC
Collapse
X
-
Hmm, thats the one I thought would have been the actual user.
So Environment.Use rName probably has the wrong user as well?
You can try playing around with WMI (check out the WMICodeCreator) .
Win32_LoggedOnU ser might prove useful, or possibly even Win32_Desktop?
For my situation, the loggedonuser showed a number of users (myself, and various system accounts), when I check Win32_LogonSess ionMappedDisk (since I have drives mapped) I find the mapped drives point to an ID number that points to my actual loggedonuser instance.
In Win32_LogonSess ion my loggedonuserid is the only one using kerberos authentication.
There is bound to be a way to get what you want out of some combination of those classesComment
Comment