How to find Current User Name

Discussion in 'ASP .Net Security' started by Herb, Jul 23, 2007.

  1. Herb

    Herb Guest

    When I run my ASP.NET application from my development PC,
    Me.User.Identity.Name works. When I run it from my Intranet site, it does
    not. Any suggestions?
     
    Herb, Jul 23, 2007
    #1
    1. Advertising

  2. Dominick Baier, Jul 23, 2007
    #2
    1. Advertising

  3. Herb

    Herb Guest

    No luck. This yields a blank string.
    These are my three lines of code:
    Response.Write(">" & Me.User.Identity.Name & "<<BR>")
    Response.Write(">" & System.Security.Principal.WindowsIdentity.
    GetCurrent().Name & "<<BR>")
    Response.Write(">" & Context.User.Identity.Name & "<")

    When run locally yields:
    >DOMAIN\USERNAME<
    >DOMAIN\USERNAME<
    >DOMAIN\USERNAME<


    When run on the Intranet yields:
    ><
    >WEBSERVERNAME\ASPNET<
    ><



    From

    "Dominick Baier" wrote:

    > Use
    >
    > Context.User.Identity.Name
    >
    >
    > -----
    > Dominick Baier (http://www.leastprivilege.com)
    >
    > Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
    >
    > > When I run my ASP.NET application from my development PC,
    > > Me.User.Identity.Name works. When I run it from my Intranet site, it
    > > does not. Any suggestions?
    > >

    >
    >
    >
     
    Herb, Jul 23, 2007
    #3
  4. Then i guess you have'nt disabled anonymous auth on your intranet server
    (in IIS)...
    -----
    Dominick Baier (http://www.leastprivilege.com)

    Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

    > No luck. This yields a blank string.
    > These are my three lines of code:
    > Response.Write(">" & Me.User.Identity.Name & "<<BR>")
    > Response.Write(">" & System.Security.Principal.WindowsIdentity.
    > GetCurrent().Name & "<<BR>")
    > Response.Write(">" & Context.User.Identity.Name & "<")
    > When run locally yields:
    >
    >> DOMAIN\USERNAME<
    >> DOMAIN\USERNAME<
    >> DOMAIN\USERNAME<

    > When run on the Intranet yields:
    >
    >> <
    >> WEBSERVERNAME\ASPNET<
    >> <

    > From
    >
    > "Dominick Baier" wrote:
    >
    >> Use
    >>
    >> Context.User.Identity.Name
    >>
    >> -----
    >> Dominick Baier (http://www.leastprivilege.com)
    >> Developing More Secure Microsoft ASP.NET 2.0 Applications
    >> (http://www.microsoft.com/mspress/books/9989.asp)
    >>
    >>> When I run my ASP.NET application from my development PC,
    >>> Me.User.Identity.Name works. When I run it from my Intranet site, it
    >>> does not. Any suggestions?
    >>>
     
    Dominick Baier, Jul 23, 2007
    #4
  5. Herb

    Herb Guest

    oops! it's always the simple things, isn't it? Incidentally,
    Me.User.Identity.Name also works. Is there a preferred method?

    "Dominick Baier" wrote:

    > Then i guess you have'nt disabled anonymous auth on your intranet server
    > (in IIS)...
    > -----
    > Dominick Baier (http://www.leastprivilege.com)
    >
    > Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
    >
    > > No luck. This yields a blank string.
    > > These are my three lines of code:
    > > Response.Write(">" & Me.User.Identity.Name & "<<BR>")
    > > Response.Write(">" & System.Security.Principal.WindowsIdentity.
    > > GetCurrent().Name & "<<BR>")
    > > Response.Write(">" & Context.User.Identity.Name & "<")
    > > When run locally yields:
    > >
    > >> DOMAIN\USERNAME<
    > >> DOMAIN\USERNAME<
    > >> DOMAIN\USERNAME<

    > > When run on the Intranet yields:
    > >
    > >> <
    > >> WEBSERVERNAME\ASPNET<
    > >> <

    > > From
    > >
    > > "Dominick Baier" wrote:
    > >
    > >> Use
    > >>
    > >> Context.User.Identity.Name
    > >>
    > >> -----
    > >> Dominick Baier (http://www.leastprivilege.com)
    > >> Developing More Secure Microsoft ASP.NET 2.0 Applications
    > >> (http://www.microsoft.com/mspress/books/9989.asp)
    > >>
    > >>> When I run my ASP.NET application from my development PC,
    > >>> Me.User.Identity.Name works. When I run it from my Intranet site, it
    > >>> does not. Any suggestions?
    > >>>

    >
    >
    >
     
    Herb, Jul 23, 2007
    #5
  6. Me implies that you are on a page - Context works everywhere...
    -----
    Dominick Baier (http://www.leastprivilege.com)

    Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

    > oops! it's always the simple things, isn't it? Incidentally,
    > Me.User.Identity.Name also works. Is there a preferred method?
    >
    > "Dominick Baier" wrote:
    >
    >> Then i guess you have'nt disabled anonymous auth on your intranet
    >> server
    >> (in IIS)...
    >> -----
    >> Dominick Baier (http://www.leastprivilege.com)
    >> Developing More Secure Microsoft ASP.NET 2.0 Applications
    >> (http://www.microsoft.com/mspress/books/9989.asp)
    >>
    >>> No luck. This yields a blank string.
    >>> These are my three lines of code:
    >>> Response.Write(">" & Me.User.Identity.Name & "<<BR>")
    >>> Response.Write(">" & System.Security.Principal.WindowsIdentity.
    >>> GetCurrent().Name & "<<BR>")
    >>> Response.Write(">" & Context.User.Identity.Name & "<")
    >>> When run locally yields:
    >>>> DOMAIN\USERNAME<
    >>>> DOMAIN\USERNAME<
    >>>> DOMAIN\USERNAME<
    >>> When run on the Intranet yields:
    >>>
    >>>> <
    >>>> WEBSERVERNAME\ASPNET<
    >>>> <
    >>> From
    >>>
    >>> "Dominick Baier" wrote:
    >>>
    >>>> Use
    >>>>
    >>>> Context.User.Identity.Name
    >>>>
    >>>> -----
    >>>> Dominick Baier (http://www.leastprivilege.com)
    >>>> Developing More Secure Microsoft ASP.NET 2.0 Applications
    >>>> (http://www.microsoft.com/mspress/books/9989.asp)
    >>>>> When I run my ASP.NET application from my development PC,
    >>>>> Me.User.Identity.Name works. When I run it from my Intranet site,
    >>>>> it does not. Any suggestions?
    >>>>>
     
    Dominick Baier, Jul 23, 2007
    #6
    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. Mike Newton
    Replies:
    0
    Views:
    2,964
    Mike Newton
    Jul 23, 2004
  2. Steve C. Orr [MVP, MCSD]
    Replies:
    0
    Views:
    1,671
    Steve C. Orr [MVP, MCSD]
    Jul 23, 2004
  3. nalbayo
    Replies:
    2
    Views:
    5,586
    Bruce Barker
    Nov 11, 2005
  4. Sam Roberts
    Replies:
    4
    Views:
    129
    Charles Mills
    Apr 3, 2005
  5. Matthew Heidemann
    Replies:
    14
    Views:
    268
    eT Ma
    Mar 22, 2011
Loading...

Share This Page