Kentico CMS 6.0 Developer's Guide

Securing a website section using Windows authentication

Securing a website section using Windows authentication

Previous topic Next topic Mail us feedback on this topic!  

Securing a website section using Windows authentication

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

It is also possible to secure only a certain section of your website using Windows authentication. In the following example, you will learn how to set the Products section of  the sample Corporate site to be secured by the Windows authentication:

 

1. Locate your web project on the disk (typically c:\Inetpub\wwwroot\<web project>). Create a new directory in your web project's folder and give it the same name as the filename in the document's URL. In this case, the filename is Products.aspx, so we will create a folder named Products.

 

2. Open the IIS and locate the folder in the tree. Select it and open the Authentication configuration on the right.

 

devguide_clip1103

 

3. Right-click Anonymous Authentication and choose to Disable it.

 

devguide_clip1104

 

4. Open the web.config file of your web project and change value of the mode attribute of the authentication tag to Windows. Also find the section marked with Windows authentication BEGIN and change the path parameter of the location tag to the name of the created directory, which will be Products in our case:

 

...

<authentication mode="Windows">

 

...

 

<!-- Windows authentication BEGIN -->

<location path="Products">

 <system.web>

   <authorization>

     <deny users="?"/>

     <allow users="*"/>

   </authorization>

 </system.web>

</location>

<!-- Windows authentication END -->

 

5. The authentication is now configured. If you try to access any of the menu items placed under the Products section, Windows authentication will be required. However, if you also want the authentication to be required for the Products main page (which is obviously not located under itself, hence requires no authentication now), you will have to use the following workaround.

 

Create a new page under the Products section, give it the same content as the main page has got and redirect the Products link in the menu to this new page. Because the new page is located under the Products section, windows authentication will be required for it.

 

devguide_clip0888