Thursday, February 10, 2011

capture windows username in asp.net mvc request

i have an intranet app asp.net mvc site. is there anyway to capture the windows nt login from the user wihtout having a full login system in the site. i dont want permissioning but i would like to do some logging on the server to track requests, etc . .

  • If you set IIS to use Windows Authentication and the site is in the Intranet Zone for your clients then the logins will automatically happen without any prompts at all.

    From blowdart
  • What version of Windows is this mvc app running on?

    You could try the following:

    • Use IIS Manager to disable anonymous access to the site, and make sure digest and/or windows authentication is enabled.
    • Change the mvc app's web.config to use Windows Authentication
    • Access the login name in the controller using User.Identity.Name.

    Would that do?

    From IanT8
  • You can use HttpContext.Current.User.Identity.Name if you set up the site to use Windows Authentication. Many browsers will pass the username on transparently.

    ooo : it seems with firefox, it prompts for a user name / pwd even though IE seems to not require it . . any ideas on why this is happenning
    ooo : Dan Diplo - any ideas ?
    Dan Diplo : FireFox, by default, doesn't pass on the username. However, it can be made to work - see http://markmonica.com/2007/11/20/firefox-and-integrated-windows-authentication/
    From Dan Diplo

0 comments:

Post a Comment