It should be noted that this doesn't necessarily represent the user that
is currently logged into the machine. For most cases, this will be the
case, because the current principal will be the windows principal.
However, the principal can be changed to any implementation of
IPrincipal depending on the nature of the application.
For ASP.NET, the principal is set according how access/membership is set
up. If you are using windows authentication, then the principal will be the
WindowsPrincipal representing the logged in user. If you are using forms
based authentication/authorization, then the principal is representative of
that user which is logged in (ASP.NET 2.0 has a much more detailed
architecture for setting this up, using SQL Server to store principal and
role information, or access).
In the end, if you want to get the windows account name associated with
the current thread, you can use the static UserName property on the
Environment class. This will work regardless of what the principal is set
to for the application.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Jim Heavey wrote: When working in the Web, I automatically have access to the
User.Identity.Name property. How do I find the same information in a
console
application?
Thanks in advance for your assistance!
Is Thread.CurrentPrincipal.Identity.Name what you're looking for?
Jon