locked
Logged on User name RRS feed

  • Question

  • User1284648741 posted

    Hi,

    Is it possible to return the current logged user name as held in the system.web.UI.webcontrols.LoginName? I wish to write user activity back to a database and the loginname would be useful as a varable. If this is not possible how would I construct a application wide varable to write the name to at login?

    Regards,

    JoeBo

    Monday, July 21, 2008 12:13 PM

Answers

  • User-1995538749 posted

    The currently logged-in user's username can be accessed like so:

    string userName = User.Identity.Name;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 21, 2008 12:20 PM

All replies

  • User-1995538749 posted

    The currently logged-in user's username can be accessed like so:

    string userName = User.Identity.Name;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 21, 2008 12:20 PM
  • User1284648741 posted

    Thanks ed

    Monday, July 21, 2008 12:56 PM
  • User-833674741 posted

    In Vista you have to run in the context of an administrator.  Since that is not the same as the user's log in account, 

    string userName = User.Identity.Name;

     does not return the user's logged in name.  It returns the administrator's name. 

     So the question remains, "How do you return the logged on username?"

    Wednesday, January 21, 2009 6:13 PM