Page.User.Identity.Name vs. WindowsIdentity.GetCurrent().Name

S

Shary

What is the difference between
Page.User.Identity.Name
and
WindowsIdentity.GetCurrent().Name

In what scenarios would I use one or the other?
 
D

Daniel Fisher\(lennybacon\)

Hi Shary

Page.User.Identity.Name can also return the name of a user logged in with
FormsAuthentication or Passport.
 
J

Joe Kaplan \(MVP - ADSI\)

Page.User.Identity.Name will be the name of the user who authenticated with
the site, assuming they used one of the supported authentication mechanisms
(Windows, Forms, Passport). Note that this use can be a Windows user
(WindowsPrincipal/WindowsIdentity), but it could also be any other
IPrincipal as well.

WindowsIdentity.GetCurrent().Name is the WindowsIdentity that the current
thread is executing under. It controls what security context is used by
unmanaged code, such as accessing files, SQL or AD. It will either be the
process account or an impersonated account.

The two will be the same thing if you are using impersonation with ASP.NET
and are using Windows authentication. Otherwise, they can be different.

HTH,

Joe K.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top