I have a question regarding to authentication with IIS 7. I want my application to display the windows username. Is it possible? if it is how can I achieve this?
<identity impersonate="false"/>
<authorization>
<deny users="?"/>
</authorization>
<authentication mode="Windows"/>
To display the username I used:
Label1.Text = (Environment.UserName);
Label2.Text = (Page.User.Identity.Name);
Label3.Text =(Request.LogonUserIdentity.Name.Substring(Request.LogonUserIdentity.Name.LastIndexOf(@"\") + 1));
Label4.Text = (System.Security.Principal.WindowsIdentity.GetCurrent().Name);
Label5.Text = (System.Web.HttpContext.Current.User.Identity.Name);
Label6.Text = Request.ServerVariables["LOGON_USER"];
None of the above would work...
My IIS settings: Asp.net impersonation enabled, Windows auth enabled...
Anyone see the problem?
Many thanks and regards!
Edited: I forgot to add that I don't want the user to be prompt to enter any credentials. I want the username to be displayed automatically.