Re: Getting the UPN of the currently logged on user

From: Carlos Galavis (cgalavis)
Date: 09/22/04


Date: Wed, 22 Sep 2004 11:02:55 -0400

The function GetUserNameEx allows you to specify the format in which you
want the user name (pass "NameUserPrincipal " in the "NameFormat"
parameter). This API is only included in Windows 2000 and up.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getusernameex.asp

-Carlos

"Colm Smyth" <Colm Smyth@discussions.microsoft.com> wrote in message
news:355520C4-4625-4760-A560-039E86C93071@microsoft.com...
> 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

  • Weird 2000 authentication problem
    ... Hope somebody can help with this Weird windows 2000 problem. ... The NT username entered (we have a system that user name starts with F then ... the details are fed to the Oracle app, but it appears that this app can only ... then the API and the username variable see the user as f000 (note lowercase ...
    (microsoft.public.win2000.security)
  • Re: New Form
    ... What is the Network O/S? ... There's an API call in Windows that picks up the NT UserName. ...
    (microsoft.public.access.forms)
  • Windows Takes Ages to Logon
    ... Last night i restarted my pc and now it takes about 15 mins for windows to ... logon once i select a username. ... night for me to format but his graphic cards broke and i keepg etting blue ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: newbe about API
    ... Emne: Re: newbe about API ... > I found all these API-CALL strings are finally compiled to ... more than that...and Windows simply takes this to an extreme that this ... DLL, when a weak point is found (which, with Microsoft, is something ...
    (alt.lang.asm)
  • Re: In the Shallow End
    ... When a document claims how an API is supposed to be used and then gives the user examples that actually work, ... Vague in your instance means you have no context to VMS or UNIX of that era. ... Windows offers lots of this stuff. ... That's why Apple had to dump a whole paradigm to plunge ahead and take the lead. ...
    (comp.sys.mac.advocacy)