ASP.NET MVC - Windows Authentication - Browser Authentication Form

1

I'm developing an ASP.NET MVC application whose access permissions will be managed from the parameters defined for users in Active Directory (AD) .

In order to search for this data from AD I have developed methods that send the UserName of the user (in our case a registration) and returns the complete data (department, full name, etc.). >

Authentication is performed through Windows Authentication , and UserName searches through the following code in the Session_Start method of the Global.asax :

var matricula = (Request.IsLocal && HttpContext.Current.IsDebuggingEnabled) ? Environment.UserName : User.Identity.Name.Split('\')[1];

My web.config is configured as follows:

<system.web>
  <compilation debug="true" targetFramework="4.5" />
  <httpRuntime targetFramework="4.5" />
  <authentication mode="Windows" />
  <authorization>
    <deny users="?" />
  </authorization>
</system.web>

The point is that even using Windows Authentication the system opens a browser-generated authentication form in which the user enters their user and password for re-authentication to occur. company network.

Note: In the company we basically use Mozilla Firefox and IE (Chrome is used in only a few units / branches). We need the authentication rule for both browsers. The tests I did were on Firefox .

However, considering whether you are dealing with an application on the company intranet, the business rules and the fact that the user has already logged in to the station and is authenticated in the domain of the company, authentication should not be necessary.

Considering this situation, I ask for help to clarify if there is any configuration error in the project that is causing this sporadic opening of the browser authentication form or if there is a lack of configuration.

    
asked by anonymous 27.10.2017 / 17:45

1 answer

1

As you do not need a login screen, you just need to create an ASP.NET MVC project and change the type of authentication to Windows Authentication :

When you run the Code, you will have the domain / user through the code below in the View created by ASP.NET:

@User.Identity.Name

Access User on Controller

Just use the code below, you will have the user logged in:

var User = HttpContext.User.Identity.Name

[Edit]

Based on the issue of your question, as you just want to remove the login pop-up, you should do some settings in IIS:

  • Disable anonymous authentication (when you open your site's settings, you are in Authentication).
  • And still in authentication, you must enable windows authentication
  • And the IIS server and client must be in the same domain.

The rest is ok.

    
13.01.2018 / 01:11