Translate

Windows Authentication.

Implementation of Windows Authentication is simple. First we need to enable Windows Authentication for the web application. To enable this setting, we need to create a new ASP.NET MVC 4 application using the Intranet Application project template. Following steps will guide us through the process:

1. Open Visual Studio.

2. Create new ASP.NET MVC 4 application.

3. Select Intranet Application project template. We can omit the creation of a test project.

4. Open Web.config file at root of the application.

5. Authentication method is defined under the <authentication> section. Add the
<authentication> section with property as follows:

<configuration>
<system.web>
<authentication mode="Windows" />
</system.web>
</configuration>

When the web site will be developed, we would normally use IIS to run and test the functionality. IIS can also be configured to run the Windows Authentication. We need to do following steps:

1. Right click on the web application in Visual Studio and choose “Properties” option at the
bottom of context menu.

2. In Properties window, scroll down until we see the Windows Authentication option.

3. Select “Enabled” in the drop down list as shown in Figure 1.


Figure 1. Enabling Windows Authentication in IIS


When we run the application then IIS will identify the currently logged in user of the computer. In the example shown in Figure 2, it is a Windows user. In a corporate environment where Active Directory domain used, it will be the domain account of the user.


 
Figure 2. Web application with Windows Authentication enabled

We need to modify configuration of IIS for Windows Authentication. To make this modification, we need to either open the IIS Manager located in the Administrative Tools folder of the Control Panel or execute INETMGR from the command window (which we access by pressing Windows + R key).

IIS Manager is a tool which is used by administer IIS. We can create web sites or create application pools or configure all aspects of IIS in a graphical user interface. IIS Manager is composed by three panes. Left pane is the navigation tree for all options that can be managed. Center pane having all the configuration options located. For web sites, we can find in the center pane options for ASP.NET applications such as version of .NET Framework, connection strings and application settings. The center pane also includes IIS configuration settings such as authentication options and error messages. In right pane we see the available actions when an option is selected in center pane. To enable Windows Authentication in IIS using IIS Manager use below steps:

1. In left pane of the IIS Manager window, expand the [Server Name] => Sites node to
display the available web sites.

2. Select “Default Web Site.”

3. In the home pane in the middle of window, double click “Authentication” under IIS.

The options are shown in Figure 3. Please note that these options are available only if they are installed when IIS was configured.

 
4. By default, Windows Authentication option at bottom is disabled. To enable it,
select it and click “Enable” in Actions pane to right of the window as shown in Figure 4.


 
5. Disable Anonymous Authentication by selecting it and clicking “Disable” in the
Actions pane.

Anonymous authentication is form of authentication used to allow users for visiting the web site without identifying themselves. If a users visit the web site then by default that user is an anonymous user as no credentials have been sent to server. If we did not disabled anonymous authentication in preceding step then web site would be open for all users.

No comments:

Post a Comment