User Authentication - LogonUserIdentity

Discussion in 'ASP .Net' started by mario.colorado@gmail.com, Nov 29, 2006.

  1. Guest

    Hi!

    Does anyone know why it is that when I use:

    Request.LogonUserIdentity.User.ToString()

    I get something like:

    S-1-5-21-2268419..........

    I was expecting to get the username of the person looking at the page.
    Is it possible to convert the output I get to the username such as
    john_smith



    Thanks!

    MC
     
    , Nov 29, 2006
    #1
    1. Advertising

  2. LogonUserIdentity only returns a true user name if Windows Authentication is used.

    http://msdn2.microsoft.com/en-us/library/system.web.httprequest.logonuseridentity.aspx



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    <> wrote in message
    news:...
    > Hi!
    >
    > Does anyone know why it is that when I use:
    >
    > Request.LogonUserIdentity.User.ToString()
    >
    > I get something like:
    >
    > S-1-5-21-2268419..........
    >
    > I was expecting to get the username of the person looking at the page.
    > Is it possible to convert the output I get to the username such as
    > john_smith
    >
    >
    >
    > Thanks!
    >
    > MC
    >
     
    Juan T. Llibre, Nov 29, 2006
    #2
    1. Advertising

  3. Guest

    Thanks! I tried it and now I get the machinename/defaultusername for
    the PC I'm running the IIS in. Is this normal?

    I thought I would get my domain/username, since i'm viewing the page
    from a different PC.


    Juan T. Llibre wrote:
    > LogonUserIdentity only returns a true user name if Windows Authentication is used.
    >
    > http://msdn2.microsoft.com/en-us/library/system.web.httprequest.logonuseridentity.aspx
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > <> wrote in message
    > news:...
    > > Hi!
    > >
    > > Does anyone know why it is that when I use:
    > >
    > > Request.LogonUserIdentity.User.ToString()
    > >
    > > I get something like:
    > >
    > > S-1-5-21-2268419..........
    > >
    > > I was expecting to get the username of the person looking at the page.
    > > Is it possible to convert the output I get to the username such as
    > > john_smith
    > >
    > >
    > >
    > > Thanks!
    > >
    > > MC
    > >
     
    , Nov 29, 2006
    #3
  4. re:
    > now I get the machinename/defaultusername for the PC I'm running the IIS in.
    > Is this normal?


    Are you sure you enabled Windows Authentication ?

    http://aspnet.4guysfromrolla.com/articles/031204-1.aspx

    The method of authentication to use is specified in the Web application's Web.config file:

    <!-- For Windows Authentication... -->
    <authentication mode="windows">

    <!-- For Forms Authentication... -->
    <authentication mode="forms">

    The only form of authentication which will return individual user names is Windows Authentication.

    More info on Windows Authentication is found here:
    http://msdn.microsoft.com/library/d...tml/cpconthewindowsauthenticationprovider.asp

    If you are getting "machinename/defaultusername", you are impersonating that identity.

    For code examples showing how to implement impersonation in an ASP.NET application, see:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q306158

    General info on ASP.NET Authenticatoin is at :
    http://msdn.microsoft.com/library/d...tml/cpconthewindowsauthenticationprovider.asp

    There's a step-by-step guide to ASP.NET Web Application Security at :
    http://msdn.microsoft.com/library/d...de/html/cpconaspnetwebapplicationsecurity.asp

    re:
    > I thought I would get my domain/username


    The only way you could get "domain/anyusername"
    is if users of your app are challenged for credentials.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    <> wrote in message
    news:...
    Thanks! I tried it and now I get the machinename/defaultusername for
    the PC I'm running the IIS in. Is this normal?

    I thought I would get my domain/username, since i'm viewing the page
    from a different PC.


    Juan T. Llibre wrote:
    > LogonUserIdentity only returns a true user name if Windows Authentication is used.
    >
    > http://msdn2.microsoft.com/en-us/library/system.web.httprequest.logonuseridentity.aspx
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > <> wrote in message
    > news:...
    > > Hi!
    > >
    > > Does anyone know why it is that when I use:
    > >
    > > Request.LogonUserIdentity.User.ToString()
    > >
    > > I get something like:
    > >
    > > S-1-5-21-2268419..........
    > >
    > > I was expecting to get the username of the person looking at the page.
    > > Is it possible to convert the output I get to the username such as
    > > john_smith
    > >
    > >
    > >
    > > Thanks!
    > >
    > > MC
    > >
     
    Juan T. Llibre, Nov 29, 2006
    #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. Andrew Connell
    Replies:
    1
    Views:
    553
    Natty Gur
    Oct 21, 2003
  2. raj mandadi
    Replies:
    0
    Views:
    437
    raj mandadi
    Dec 22, 2003
  3. Brett Porter
    Replies:
    2
    Views:
    781
    Andrea D'Onofrio [MSFT]
    Jan 20, 2004
  4. Mark
    Replies:
    0
    Views:
    682
  5. Scott_A

    Incorrect LogonUserIdentity.Name

    Scott_A, Jul 9, 2008, in forum: ASP .Net Security
    Replies:
    6
    Views:
    997
    Joseph Sedlar
    Aug 23, 2010
Loading...

Share This Page