0

How to get windows logged in user username using only Forms authentication in asp.net mvc application after deploy on iis I try with many methods but no one don't work correctly like this

var userName1 = System.Web.HttpContext.Current.User.Identity.Name;
var userName2 = WindowsIdentity.GetCurrent();
Cœur
  • 37,241
  • 25
  • 195
  • 267
user3721728
  • 187
  • 7
  • Possible Duplicate? [how to get currently loggedin windows account from an asp.net page](http://stackoverflow.com/questions/16184685/how-to-get-currently-loggedin-windows-account-from-an-asp-net-page) – Izzy Aug 15 '14 at 12:06
  • no I need only forms autentication I don't need windows autentication thank you for your answer – user3721728 Aug 15 '14 at 12:11
  • you cant - you must use Windows Authentication for that - the link provided by Izzy covers this. – ajg Aug 15 '14 at 12:27
  • but when I use windows autentication in my application administrator page everyone have access – user3721728 Aug 15 '14 at 12:32
  • 1
    then secure it by user or group - see the restrict access section of http://support.microsoft.com/kb/323176 – ajg Aug 15 '14 at 12:37
  • No, not *everyone* has access. Windows auth automatically "logs in" the user. It's actually using impersonation. It treats as the user for the site whatever user is logged into Windows. So, you may not have to log in, per se, but you will only have the access that the Windows user has for the site. – Chris Pratt Aug 15 '14 at 15:16
  • can you show me how can i do that?? – user3721728 Aug 18 '14 at 08:45

0 Answers0