1

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.

2 Answers2

1

Check out How to get Windows user name when identity impersonate="true" in asp.net? and IIS7: Setup Integrated Windows Authentication like in IIS6.

Basically, double-check to make sure your application is configured correctly, and double-check that you have Windows Authentication installed in IIS.

Community
  • 1
  • 1
0

For this to work the browser and server must be configured correctly. Note that Windows authentication is not a standard HTTP authentication method, it is someting specific for IE and IIS (Firefox can support it too with extra setting) so you have to make sure that your IE browser is configured to send the domain user credentials to the IIS server. your server configuration seems OK, imperonation is true. Check your IE browser and make sure that the http address you enter in IE is not part of the internet domain, it must be part of the intranet domain, only in the intranet domain the IE and IIS can support the Integrated Windows Authentication

Siraf
  • 1,133
  • 9
  • 24