locked
Internet Explorer Get Current User RRS feed

  • Question

  • User900934948 posted

    I am trying to get Internet Explorer's "sign in as different user" and then get the username of the logged in user (not computer user). For example, i sign in as different user "LLL" and when i start a page with that page it would display "LLL" Can anyone help? i tried identity, httpwebrequest

    Monday, April 14, 2014 6:49 AM

Answers

All replies

  • User753101303 posted

    Hi,

    And what happens with what you tried ? Do you see no user name at all or do you see the user who opened the session ? If using Windows authentication and User.Identity.Name, it should work.

    Else show User.Identity.IsAuthenticated and User.Identity.AuthenticationType, as long as you don't have proper values here, User.Identity.Name won't work either.

    Finally make sure to close all other IE instances before launcing IE using "Run as another user"...

    Monday, April 14, 2014 7:06 AM
  • User900934948 posted

    User.Identity.Name bears no result
    IsAuthenticated shows false, AuthenticationType shows nothing
    HTTPContext.Current.User.Identity.Name shows no result either

    Monday, April 14, 2014 7:42 AM
  • User465171450 posted

    The current user functionality only works if you are using an asp.net authentication system such as windows, forms, etc.. IE itself doesn't have a built in "sign in as a different user". That would either a) be a function of the website where you sign into or b) some sort of plug-in designed to remember passwords for a website.

    Monday, April 14, 2014 8:34 AM
  • User281315223 posted

    How are you currently handling authentication within your application?

    The previously suggested properties of User.Identity.Name should reveal the name of the user that is currently logged in. If it is not returning anything, then it's likely that your authentication may not be working as you intended.

    Could you provide any details as to how you are currently authentication your user? Are you using Forms Authentication? Or are you attempting to manually handle this through your own logic?

    Monday, April 14, 2014 8:34 AM
  • User753101303 posted

    So for now your website doesn't use any authentication. You have to enable authentication. See http://msdn.microsoft.com/en-us/library/aa292114(v=vs.71).aspx for possible choices. It looks like you want Windows authentication.

    As long as IsAuthenticated is false, you won't have any way to know who is connected.

    How can it be that you seems to be able to sign as a particular user and still you don't know anything about the connected user ? Could it be that you tried to create your own authentication mechanism rather than reusing what is provided by ASP.NET/IIS ?

    Which authentication method do you tried to use ?

     

     

    Monday, April 14, 2014 8:55 AM
  • User900934948 posted

    I tried windows and forms but still false

    Tuesday, April 15, 2014 12:35 AM
  • User900934948 posted

    Please teach me. Its my first time doing such thing.... I just want to get the user logged into the website

    Tuesday, April 15, 2014 3:58 AM
  • User-933407369 posted

    i would  suggest you check out the links below for details:

    HttpContext.User Property

    http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx

    Why does HttpContext.Current.User.Identity.Name return blank

    Getting A Users Username in ASP.NET

    http://richhewlett.com/2011/02/15/getting-a-users-username-in-asp-net/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 17, 2014 3:23 AM
  • User753101303 posted

    Do you have disabled user authentication ? Which version of IIS or IISExpress ? If you are at the dev step and testing on your own box see :

    http://www.codeproject.com/Articles/396569/Make-Web-Development-Easier-with-IIS-Express

    (last screenshot in the SSL section, you have the "Anonymous" and "Windows" authentication (disable the first and enable the later))...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 17, 2014 3:44 AM