Getting the UPN of the currently logged on user

From: Colm Smyth (Smyth_at_discussions.microsoft.com)
Date: 09/22/04

  • Next message: Carlos Galavis: "Re: Getting the UPN of the currently logged on user"
    Date: Wed, 22 Sep 2004 06:35:04 -0700
    
    

    I have a VB program which checks the currently logged on user against a table
    of usernames. The program acts accordingly dependant on whether it finds the
    username in the table.

    Up until now I have been using the environment variable "Username" to
    retrieve the username. This has been working fine.

    Recently our client has switched their logins to a UPN format i.e.
    <first>.<last>@<domain>. The problem is that this is not being stored in the
    environment variable, instead the old username is being stored there (that is
    the pre Win2k account name)

    The client is adamant that I must pick up the name typed into the windows
    login dialog and not the environment variable. I imagine that I need to get
    the UPN of the currently logged in user. Does anyone know how this can be
    done?

    I have tried the GetUserNameA function from the windows API but this still
    returns the pre Win2k username.

    Many thanks, Colm


  • Next message: Carlos Galavis: "Re: Getting the UPN of the currently logged on user"

    Relevant Pages

    • Re: Returning current user back to Access 2007
      ... suggested in the Access forum which was to use a Windows API call to get the ... The "AS UserName" may satisfy Access's ... SELECT UserName FROM DBUser ... built in function CurrentUser is only returns Admin which is from Access ...
      (microsoft.public.sqlserver.security)
    • Re: Getting the UPN of the currently logged on user
      ... though you can get the various name types with GetUserNameEx. ... Joe Richards Microsoft MVP Windows Server Directory Services ... > username in the table. ... > the pre Win2k account name) ...
      (microsoft.public.platformsdk.security)