Re: Getting the UPN of the currently logged on user

From: Joe Richards [MVP] (humorexpress_at_hotmail.com)
Date: 09/23/04


Date: Thu, 23 Sep 2004 10:43:24 -0400

You can't get the name typed into the logon box without getting into GINA
programming, though you can get the various name types with GetUserNameEx. See
my free tool UserName on the www.joeware.net website, it shows you what that
function will return for you.

   joe

--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net
Colm Smyth wrote:
> 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


Relevant Pages

  • Re: getusernameex and namesamcompatible
    ... if my program is running as user jdoe on the active directory domain ... mydomain.com with the netbiosname mynetname and i running the following ... GetUserNameEx ...
    (microsoft.public.win32.programmer.networks)
  • Re: What is the maximal length of usernames on Solaris?
    ... > system to accommodate 4096 character user ID's. ... > 8 characters is to short in many circumstances. ... >>People who whine about petty shit such as how long a username can be ... but Windows uses a backward slash. ...
    (comp.sys.sun.admin)
  • RE: Adding a virtual FTP folder to IIS
    ... I think we can follow the Form Authentication modal. ... application will use the ASPNET account. ... If we change the username ... Windows identity different from that of the default process identity. ...
    (microsoft.public.dotnet.framework)
  • Re: Network shares and printing
    ... Windows cannot obtain the domain controller name for your computer network. ... shared drive and entering proper username and password. ...
    (microsoft.public.windowsxp.network_web)
  • Re: Locked out of my computer - please help
    ... > the bottom of the screen to use a Workgroup name. ... > says that either my username or password is incorrect. ... > latest Windows settings that worked. ... > I still do not have a recent backup. ...
    (microsoft.public.windowsxp.security_admin)