Jesse Liberty [mailto:[EMAIL PROTECTED]] wrote:

> In an ASP.NET application, what is the difference between
>
>         User.Identity.Name
>
> and
>
>         WindowsPrincipal wp = new
> WindowsPrincipal(WindowsIdentity.GetCurrent())
>         wp.Identity.Name
>
> When I try this (with anonymous user off) I get the correct
> user name from the former, and NT\AUTHORITY\SYSTEM with the latter.

Assuming you're using Windows authentication, there is no difference.
However, ASP.NET allows for custom authentication protocols to be used, such
as Forms authentication. In this case the HttpContext::User property would
be a custom IPrincipal type and WindowsIdentity::GetCurrent would return the
Windows account that the custom authentication chose to impersonate. A
perfect example of this is the built forms authentication, but obviously you
can roll your own authentication scheme as well.

HTH,
Drew
.NET MVP

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to