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

Discussion in 'ASP .Net Security' started by Shary, Dec 11, 2004.

  1. Shary

    Shary Guest

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

    In what scenarios would I use one or the other?
    Shary, Dec 11, 2004
    #1
    1. Advertising

  2. Hi Shary

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

    --
    Daniel Fisher(lennybacon)
    MCP ASP.NET C#
    Blog: http://www.lennybacon.com/


    "Shary" <> wrote in message
    news:...
    > What is the difference between
    > Page.User.Identity.Name
    > and
    > WindowsIdentity.GetCurrent().Name
    >
    > In what scenarios would I use one or the other?
    Daniel Fisher\(lennybacon\), Dec 13, 2004
    #2
    1. Advertising

  3. 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.

    "Shary" <> wrote in message
    news:...
    > What is the difference between
    > Page.User.Identity.Name
    > and
    > WindowsIdentity.GetCurrent().Name
    >
    > In what scenarios would I use one or the other?
    Joe Kaplan \(MVP - ADSI\), Dec 13, 2004
    #3
  4. You might want to take a look at
    http://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetAP05.asp. It
    contains descriptions of the principal and identity objects used by ASP.NET,
    as well as their expected values under various combinations of IIS and
    ASP.NET authentication schemes.

    HTH,
    Nicole


    "Shary" <> wrote in message
    news:...
    > What is the difference between
    > Page.User.Identity.Name
    > and
    > WindowsIdentity.GetCurrent().Name
    >
    > In what scenarios would I use one or the other?
    Nicole Calinoiu, Dec 14, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Um9nZXI=?=

    WindowsIdentity.GetCurrent()

    =?Utf-8?B?Um9nZXI=?=, Apr 13, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    804
    =?Utf-8?B?Um9nZXI=?=
    Apr 13, 2006
  2. Replies:
    0
    Views:
    540
  3. Robert Phillips

    Access is denied in WindowsIdentity.GetCurrent

    Robert Phillips, Jan 13, 2005, in forum: ASP .Net Security
    Replies:
    0
    Views:
    153
    Robert Phillips
    Jan 13, 2005
  4. Marco Herrn

    Access Denied on WindowsIdentity.GetCurrent()

    Marco Herrn, Mar 7, 2005, in forum: ASP .Net Security
    Replies:
    1
    Views:
    181
    Paul Clement
    Mar 7, 2005
  5. Jeremy Chapman

    System.Security.Principal.WindowsIdentity.GetCurre nt()

    Jeremy Chapman, Sep 9, 2005, in forum: ASP .Net Security
    Replies:
    3
    Views:
    197
    Nicole Calinoiu
    Sep 10, 2005
Loading...

Share This Page