Get username even if Windows Authentication

The following is a script for a virtual directory following configuration in IIS

  • Enable anonymous access is disabled (unchecked).

  • Integrated Windows authentication is disabled (unchecked)

  • Basic authentication is enabled (checked)

In the web.config web application (for the same virtual directory above), the setting is as follows:

                   

When I browse the aspx page of the above web application, it asks for a username and password.

The user enters a username and password (in a dialog box that appears as part of Windows authentication).

I can get the username that the user entered if the login was successful.

Is there a way to get the username (this user has logged in), even if the login failed.

Regards, test_win

+3
source share
1 answer

I do not believe that authentication information was not stored in IIS in a way that was exposed to ASP.NET. If you do forms-based authentication, you can track the incorrect username / password, but since IIS handles authentication, I don't think you can get this information from the code.

The login error will be stored in the IIS log files, which you can handle later from a separate process. You would like to look for errors 401/403, where the username is indicated.

+1
source

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


All Articles