Cs-username not displayed in IIS logs in classic IIS7 mode

I am running an asp.net application with forms authentication on IIS 7 in classic mode. Logging is enabled and the cs-username field is currently selected for registration. However, the cs username is always empty in the logs. Anyone have any tips on how to determine the cause?

+3
source share
4 answers

What Brian says is true. In classic mode, you perform double authentication procedures. This way, IIS authenticates you first, and then ASP.NET authenticates you. In classic mode, IIS authentication will most likely be anonymous, in which case IIS will not register anything in this field. If you enable the integrated pipeline, authentication will happen only once - and in the IIS pipeline. This means that IIS can write data to the cs-username field.

+1
source

cs-username knows nothing about ASP.NET/form authentication and vice versa ... Do you have anonymous access in IIS, right? Therefore, there is no cs-username output.

+5
source

I think you need to save asp.net LOGGIN in the HEADER variable and use the ISAPI filter to get this information and save it in IIS_LOG.

0
source

You can do the following and it will be installed in the IISlogs cs-username.

public WebApiApplication()
{
    this.AuthenticateRequest += WebApiApplication_AuthenticateRequest;
}

void WebApiApplication_AuthenticateRequest(object sender, EventArgs e)
{
    HttpContext.Current.User = new GenericPrincipal(new GenericIdentity("SET THE USER INFO HERE"), null);
}
0
source

Source: https://habr.com/ru/post/1721903/


All Articles