Get Username around UAC

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikeymike
    New Member
    • Jul 2009
    • 12

    Get Username around UAC

    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?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    What code are you using to get the username? There might be a different way.
    Are you using WindowsPrincipa l?

    Comment

    • mikeymike
      New Member
      • Jul 2009
      • 12

      #3
      I have been using WindowsIdentity .GetCurrent().N ame :)

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Originally posted by mikeymike
        I have been using WindowsIdentity .GetCurrent().N ame :)
        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 classes

        Comment

        Working...