1
votes

I have an asp.net application on my server that uses WindowsAuthentication to log in. The scenario is simple: users logged in, will use the same credentials to login the application.

Certainly, on IISExpress on my machine works great, but when I try to login the application on server, the current user returned is DefaultAppPool.

I guess it's a missing impersonate config on IIS. I tried to get the current user with:

string username = HttpContext.Current.Request.LogonUserIdentity.Name;
string username = WindowsIdentity.GetCurrent().Name;

... and all of above returns the current user loggedin but only works on IISExpress, but not on server IIS.

IIS Express config
DefaultAppPool
- Framework Version 4.0
- Application Pool Identity

Application Authentication Config
Application Authentication Config

Server Info
Windows 2008 R2 Enterprise
IIS 7.5

PD: Is not my best English

1
What are the settings on the iis server. Do you have Anonymous Access disabled? Also, if this is on an Intranet, in order for the credentials to be passed from the browser to the server I believe the site needs to be trusted.Trajan Unger
@TrajanUnger The IIS configuration is now on question. Now I need to get the user who begins the request, although still keeps the DefaultAppPool user.joisman

1 Answers

0
votes

I had a similar issues; as far as I can tell it is because the web.config file needs to have the following entries:

<authentication mode="Windows" />
    <identity impersonate="true" />

Also in your IIS/Authentication section in Internet Information Services (IIS) Manager, make sure only Anonymous Authentication and Windows Authentication is Enabled. I had ASP.NET Impersonation checked by mistake and it was giving me the same error you described in this post. Once I disabled that (along with the other modifications), it seems to be working fine.