SlideShare a Scribd company logo
Slide 1 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
In this session, you will learn to:
Describe the authentication methods for Web applications
Describe the authorization methods for Web applications
Describe the main components of a membership system
Describe how to build a security administration interface
Configure authentication and authorization for a Web
application
Implement a membership registration page
Implement a login page
Create a membership management administrative user
interface
Objectives
Slide 2 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Authentication is the process by which users prove their
identity.
This usually involves entering a user name and a password.
ASP.NET 2.0 provides three authentication mechanisms:
Windows authentication
Forms authentication
Passport authentication
Authentication for Web Applications
Slide 3 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Windows Authentication:
Application can be configured to use Microsoft Windows
authentication.
IIS identifies the user by comparing the credentials entered by
the user against the user’s Windows account.
Three possible login methods are provided:
Basic authentication
Digest authentication
Windows Integrated authentication
Authentication for Web Applications (Contd.)
Slide 4 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Forms Authentication:
Authentication is done on the basis of credentials entered by
the user in the login page.
Credentials can be stored in a Database (recommended) or in
a Web.Config file (if number of users are less).
By default, cookies are used to track the session of a user for
subsequent requests.
Query string can also be used in case cookie support is
disabled in the client browser.
The following example shows how to configure Forms
Authentication in the Web.config file :
<authentication mode="Forms">
<forms name=“FormName" loginUrl=“/LogonPage.aspx" />
</authentication>
Authentication for Web Applications (Contd.)
Slide 5 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
User accounts are typically stored in a database.
It is possible to keep a list of users in the Web.config file:
<authentication mode="Forms">
<forms name=“LogonPage" loginUrl=“/LogonPage.aspx">
<credentials passwordFormat="SHA1">
<user name="Kim“ password=
"07B7F3EE06F278DB966BE960E7CBBD103DF30CA6"/>
<user name="John“ password=
"BA56E5E0366D003E98EA1C7F04ABF8FCB3753889"/>
</credentials>
</forms>
</authentication>
Authentication for Web Applications (Contd.)
Slide 6 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Passport Authentication:
This is a centralized authentication service provided by
Microsoft.
Microsoft .NET Passport can be used to access services such
as Microsoft Hotmail and MSN Messenger.
Any site can be registered with the Passport service to use the
same Passport for accessing the site.
To use Passport authentication, following steps must be
completed:
1. Obtain the .NET Passport software development kit (SDK).
2. Configure Passport authentication by adding the following
element in the Web.config file :
<authentication mode="Passport">
3. Implement authentication and authorization by using the
functionality in the .NET Passport SDK.
Authentication for Web Applications (Contd.)
Slide 7 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Authorization is the process of determining the pages and
resources that the user has access to after authentication.
Authorization can be implemented using any of the following
methods:
File authorization
URL authorization
Authorization for Web Applications
Slide 8 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
File Authorization:
This is an authorization system provided by Windows.
Permissions can be set on any file or folder stored on a disk
formatted with the NTFS file system.
These permissions are stored in Access Control List (ACL),
which is stored with the file.
The permissions stored in the ACLs can be used to control the
access to the resources, pages, and folders in a Web
application.
To use File authorization:
1. Configure your application to use Windows authentication.
2. Assign permissions to the files and folders in the Web site.
Authorization for Web Applications (Contd.)
Slide 9 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
URL Authorization:
Can be used to control access to each virtual directory within a
Web site hierarchy.
Can be used with any of the authentication modules.
To establish permissions for a particular directory:
Create a Web.config file within that directory.
Add an <authorization> section to the file that contains <allow>
and <deny> tags for each user or role.
Two special values that can be used as wildcard identities in
<authorization> section:
“*” : applies to everyone who visits the directory.
“?” : applies to anonymous users.
Authorization for Web Applications (Contd.)
Slide 10 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
The following examples shows how to configure URL
Authorization in an ASP.NET application:
For a directory:
<authorization>
<allow users="Kim"/>
<allow roles="Admins"/>
<deny users="John"/>
<deny users="?"/>
</authorization>
For a Single file:
<location path=“SecuredFile.aspx”><system.web>
<authorization>
<allow users="Joe"/>
<deny users="*"/>
</authorization>
</system.web></location>
Authentication for Web Applications (Contd.)
Slide 11 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Microsoft ASP.NET membership gives a built-in way to
validate and store user credentials.
It can be used with ASP.NET Forms authentication or with
the ASP.NET login controls to create a complete system for
authenticating users.
It supports facilities for:
Creating new users and passwords
Storing membership information in a data store
Authenticating users
Managing passwords
Exposing a unique identification for authenticated users
Specifying a custom membership provider
Introduction to Membership
Slide 12 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
ASP.NET 2.0 includes a set of classes that enable you to
implement a membership system.
You can use the Membership class to configure a
membership system.
The Membership class provides a range of methods for
managing the members of a Web site:
CreateUser
DeleteUser
UpdateUser
ValidateUser
FindUserByEmail
FindUserByName
Introduction to Membership (Contd.)
Slide 13 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
To use membership, the site must be configured to use it by
performing the following steps:
1. Specify membership options as part of your website
configuration.
2. Configure the application to use Forms authentication.
3. Define user accounts for membership.
After configuring membership for your site, you must create
a login form.
Login form can be created by hand using TextBox controls
or by using Login controls.
How Membership Works
Slide 14 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Login controls are a set of Web server controls that provide
the common user interface elements of a membership
system.
Login controls automatically use the membership system to
validate a user.
The following controls are available in the Login group of the
Toolbox:
CreateUserWizard
Login
LoginStatus
LoginView
PasswordRecovery
ChangePassword
How Membership Works (Contd.)
Slide 15 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
In case login form is created by hand:
You need to prompt the user for a user name and password
and then call the ValidateUser method to perform the
validation.
You can call methods of the FormsAuthentication class
after authentication to create a cookie and write it to the user’s
computer.
After authentication is done, an object is created that
contains information about the current user.
This object can be used to retrieve information about the
user, such as user’s name, email address, date, and time of
last logon.
How Membership Works (Contd.)
Slide 16 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
The membership system allows your application to accept
and work with anonymous users.
Before using anonymous identification, it needs to be
enabled.
A temporary ID is assigned to unauthenticated users to
track their sessions.
The ID is stored in a cookie or embedded in the URL of
requested pages.
If an anonymous user logs in, the anonymous identification
information is discarded and the user is treated thereafter
as an authenticated user.
Anonymous Users in the Membership System
Slide 17 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Membership system can be configured in the application’s
Web.config file.
The easiest way to configure and manage memberships is
with the Web Site Administration tool.
Specifications of membership configuration include:
Membership provider to use
Password options
Users and passwords
Membership Configuration and Management
Slide 18 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Membership can be integrated with ASP.NET role
management to provide authorization services for your site.
Roles can be used to manage the permissions for large
numbers of users.
By grouping users into roles, permissions can be assigned
once for many users.
Roles and Authorization:
In URL authorization mode, access to a directory can be
configured by using the Web.config file in each directory.
Roles can be added to the <authorization> section as:
<authorization>
<allow roles="Admin"/>
<allow roles="PowerUsers" />
<deny users="?"/>
</authorization>
Web Site Security Administration Using the Roles Class
Slide 19 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Role Management Configuration:
Role management must be configured in the Web.config file in
the root folder of the Web application.
To enable role management, the following item can be
included in the Web.Config file:
<roleManager
enabled="true"
cacheRolesInCookie="true">
</roleManager>
Web Site Security Administration Using the Roles Class
(Contd.)
Slide 20 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
You can create and populate roles by:
Using the ASP.NET Web Site Administration Tool
Writing code by using the Roles class
Example of creating and populating roles by using the
Roles class:
Roles.CreateRole("Subscribers");
Roles.AddUsersToRole("Anatoly Sabantsev",
"Subscribers");
Roles.AddUsersToRole("Bobby Moore",
"Subscribers");
You can use the User object to check whether the current
user is a member of a particular role:
if (! User.IsInRole("Subscribers"))
btnDownloadFile.Visible = false;
Web Site Security Administration Using the Roles Class
(Contd.)
Slide 21 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Problem Statement:
You are a developer in the Adventure Works organization, a
fictitious bicycle manufacturer. You have been asked to assist
in the development of the Business-to-Consumer (B2C) Web
application and a related Business-to-Employee (B2E) extranet
portal.
Decisions on the design of the application have already been
made. You have been asked to carry out a number of specific
tasks in order to implement various elements of this design.
Demo: Controlling Access to a Web Application
Slide 22 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
As part of the first phase of the B2C development, you have
been asked to complete the prototypes for the following pages:
• MembersLogin.aspx. This page collects and checks credentials to
identify the user.
• Register.aspx. This page enables users to become members of
the site.
• Employees.aspx. This page shows sales figures for the
Adventure Works staff, and it should be viewable only by
employees.
• MemberUpdate.aspx. This page enables users to change the e-
mail address and password stored for their account.
• Admin.aspx. This page enables site administrators to change the
role membership on the site.
You will also ensure that several pages are secured properly.
Demo: Controlling Access to a Web Application (Contd.)
Slide 23 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Solution:
You need to perform following tasks:
1. Configuring Authentication and Authorization for a Web Application
a. Open the Adventure Works Web site for editing in Visual Studio.
b. Implement Forms authentication for the Web application.
c. Configure authorization for anonymous users and members.
d. Configure IIS.
e. Implement Windows authentication for the Employees page.
2. Implementing a Membership Registration Page
a. Install the SQL Server provider database.
b. Configure the ASP.NET SQL Server membership provider.
c. Create the membership registration page.
d. Create the membership update page.
Demo: Controlling Access to a Web Application (Contd.)
Slide 24 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
3. Implementing a Login Page and Adding Login Controls
a. Create the login page and add the Login control.
b. Add a PasswordRecovery Web server control to the login page.
c. Add login controls to other pages.
d. Test the login and membership features.
3. Creating a Membership Management Administrative User Interface
a. Configure the Web application to use the SQL Roles provider.
b. Complete the Admin.aspx page.
c. Secure the Administration page.
Demo: Controlling Access to a Web Application (Contd.)
Slide 25 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Summary
In this session, you learned that:
Authentication is the process by which users prove their
identity.
In Microsoft Windows authentication, IIS identifies the user by
comparing the credentials entered by the user against the
user’s Windows account.
In Form authentication, credentials entered by the user in the
login page are checked with credentials stored in the database
or Web.config file for authentication.
Passport authentication is a centralized authentication service
provided by Microsoft.
Authorization is a process in which after authentication, the
application determines the pages and resources that the user
can access.
Slide 26 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Summary (Contd.)
In File Authorization, access permissions can be set on any file
or folder stored on a disk formatted with the NTFS file system.
In URL authorization, access to each virtual directory can be
controlled within the website hierarchy.
The Membership class provides methods for creating, deleting,
and updating user accounts, authenticating users, and
managing passwords.
Roles can be created to reduce the administrative overhead of
managing permissions for large numbers of users.

More Related Content

PPSX
08 asp.net session11
PPS
08 asp.net session11
PPTX
PPTX
ASP.NET Lecture 5
PDF
Claims based authentication in share point 2010 .new
DOCX
Authorization in asp
PDF
Obiee 11g security creating users groups and catalog permissions
PDF
Bulletin Boards - Quick Start Guide To User Management
08 asp.net session11
08 asp.net session11
ASP.NET Lecture 5
Claims based authentication in share point 2010 .new
Authorization in asp
Obiee 11g security creating users groups and catalog permissions
Bulletin Boards - Quick Start Guide To User Management

What's hot (16)

PDF
Windows Server 2008 Active Directory ADFS Claims-base Idm for Windows Part 2
DOCX
Asp interview Question and Answer
PPT
Ch21 system administration
PPTX
Lecture 20101124
PPTX
Understanding Office 365’s Identity Solutions: Deep Dive - EPC Group
PPTX
User Access Manager for IBM Connections (UAM)
PPTX
Mobile application
PPTX
SharePoint 2013 and ADFS
PDF
How to -_implement_clientless_single_sign_on_authentication_in_single_active_...
PDF
Graph api
PPTX
Luminis Iv Sso 2010
PPT
Forms authentication
DOCX
Combined
PDF
A Detailed Guide to Securing React applications with Keycloak - WalkingTree ...
PDF
Difference between authentication and authorization in asp.net
PDF
James Allardice - "Building a better login with the credential management API"
Windows Server 2008 Active Directory ADFS Claims-base Idm for Windows Part 2
Asp interview Question and Answer
Ch21 system administration
Lecture 20101124
Understanding Office 365’s Identity Solutions: Deep Dive - EPC Group
User Access Manager for IBM Connections (UAM)
Mobile application
SharePoint 2013 and ADFS
How to -_implement_clientless_single_sign_on_authentication_in_single_active_...
Graph api
Luminis Iv Sso 2010
Forms authentication
Combined
A Detailed Guide to Securing React applications with Keycloak - WalkingTree ...
Difference between authentication and authorization in asp.net
James Allardice - "Building a better login with the credential management API"
Ad

Viewers also liked (8)

PDF
福井県敦賀市でのシンポジウム
PDF
年賀状 2015
PPS
01 asp.net session01
PDF
Collaboration of Libraries, Archives and Museums: A Perspective from Japan
PPTX
図書館情報学の研究・教育の国際動向:iSchoolを中心に(古賀崇)
PDF
有声阻害重子音の音声実現における地域差に関する予備的分析
PDF
占領期前後における城戸幡太郎の学校図書館に関する関与
PDF
【佐賀大学】平成20年環境報告書
福井県敦賀市でのシンポジウム
年賀状 2015
01 asp.net session01
Collaboration of Libraries, Archives and Museums: A Perspective from Japan
図書館情報学の研究・教育の国際動向:iSchoolを中心に(古賀崇)
有声阻害重子音の音声実現における地域差に関する予備的分析
占領期前後における城戸幡太郎の学校図書館に関する関与
【佐賀大学】平成20年環境報告書
Ad

Similar to 08 asp.net session11 (20)

DOCX
Documentation
PPTX
Security asp.net application
PPTX
Profile
DOCX
Microsoft identity platform and device authorization flow to use azure servic...
DOCX
Mc0081 .(dot)net technologies
DOC
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
PPT
ASP.NET 13 - Security
PPS
SharePoint 2007 Security
PPSX
12 asp.net session17
PPS
03 asp.net session04
PPS
05 asp.net session07
PPTX
Microsoft identity manoj mittal
PPTX
MembershipReboot & Thinktecture: The Paradigms in Authentication &Authorizati...
PPTX
2009 - NRW Conf: (ASP).NET Membership
PPTX
Azure from scratch part 2 By Girish Kalamati
PPSX
16 asp.net session23
PPSX
05 asp.net session07
PPTX
Simplify user application authentication using Microsoft Identity Platform
PDF
Distributed and Cloud Computing 1st Edition Hwang Solutions Manual
Documentation
Security asp.net application
Profile
Microsoft identity platform and device authorization flow to use azure servic...
Mc0081 .(dot)net technologies
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
ASP.NET 13 - Security
SharePoint 2007 Security
12 asp.net session17
03 asp.net session04
05 asp.net session07
Microsoft identity manoj mittal
MembershipReboot & Thinktecture: The Paradigms in Authentication &Authorizati...
2009 - NRW Conf: (ASP).NET Membership
Azure from scratch part 2 By Girish Kalamati
16 asp.net session23
05 asp.net session07
Simplify user application authentication using Microsoft Identity Platform
Distributed and Cloud Computing 1st Edition Hwang Solutions Manual

08 asp.net session11

  • 1. Slide 1 of 26Ver. 1.0 Developing Web Applications Using ASP.NET In this session, you will learn to: Describe the authentication methods for Web applications Describe the authorization methods for Web applications Describe the main components of a membership system Describe how to build a security administration interface Configure authentication and authorization for a Web application Implement a membership registration page Implement a login page Create a membership management administrative user interface Objectives
  • 2. Slide 2 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Authentication is the process by which users prove their identity. This usually involves entering a user name and a password. ASP.NET 2.0 provides three authentication mechanisms: Windows authentication Forms authentication Passport authentication Authentication for Web Applications
  • 3. Slide 3 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Windows Authentication: Application can be configured to use Microsoft Windows authentication. IIS identifies the user by comparing the credentials entered by the user against the user’s Windows account. Three possible login methods are provided: Basic authentication Digest authentication Windows Integrated authentication Authentication for Web Applications (Contd.)
  • 4. Slide 4 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Forms Authentication: Authentication is done on the basis of credentials entered by the user in the login page. Credentials can be stored in a Database (recommended) or in a Web.Config file (if number of users are less). By default, cookies are used to track the session of a user for subsequent requests. Query string can also be used in case cookie support is disabled in the client browser. The following example shows how to configure Forms Authentication in the Web.config file : <authentication mode="Forms"> <forms name=“FormName" loginUrl=“/LogonPage.aspx" /> </authentication> Authentication for Web Applications (Contd.)
  • 5. Slide 5 of 26Ver. 1.0 Developing Web Applications Using ASP.NET User accounts are typically stored in a database. It is possible to keep a list of users in the Web.config file: <authentication mode="Forms"> <forms name=“LogonPage" loginUrl=“/LogonPage.aspx"> <credentials passwordFormat="SHA1"> <user name="Kim“ password= "07B7F3EE06F278DB966BE960E7CBBD103DF30CA6"/> <user name="John“ password= "BA56E5E0366D003E98EA1C7F04ABF8FCB3753889"/> </credentials> </forms> </authentication> Authentication for Web Applications (Contd.)
  • 6. Slide 6 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Passport Authentication: This is a centralized authentication service provided by Microsoft. Microsoft .NET Passport can be used to access services such as Microsoft Hotmail and MSN Messenger. Any site can be registered with the Passport service to use the same Passport for accessing the site. To use Passport authentication, following steps must be completed: 1. Obtain the .NET Passport software development kit (SDK). 2. Configure Passport authentication by adding the following element in the Web.config file : <authentication mode="Passport"> 3. Implement authentication and authorization by using the functionality in the .NET Passport SDK. Authentication for Web Applications (Contd.)
  • 7. Slide 7 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Authorization is the process of determining the pages and resources that the user has access to after authentication. Authorization can be implemented using any of the following methods: File authorization URL authorization Authorization for Web Applications
  • 8. Slide 8 of 26Ver. 1.0 Developing Web Applications Using ASP.NET File Authorization: This is an authorization system provided by Windows. Permissions can be set on any file or folder stored on a disk formatted with the NTFS file system. These permissions are stored in Access Control List (ACL), which is stored with the file. The permissions stored in the ACLs can be used to control the access to the resources, pages, and folders in a Web application. To use File authorization: 1. Configure your application to use Windows authentication. 2. Assign permissions to the files and folders in the Web site. Authorization for Web Applications (Contd.)
  • 9. Slide 9 of 26Ver. 1.0 Developing Web Applications Using ASP.NET URL Authorization: Can be used to control access to each virtual directory within a Web site hierarchy. Can be used with any of the authentication modules. To establish permissions for a particular directory: Create a Web.config file within that directory. Add an <authorization> section to the file that contains <allow> and <deny> tags for each user or role. Two special values that can be used as wildcard identities in <authorization> section: “*” : applies to everyone who visits the directory. “?” : applies to anonymous users. Authorization for Web Applications (Contd.)
  • 10. Slide 10 of 26Ver. 1.0 Developing Web Applications Using ASP.NET The following examples shows how to configure URL Authorization in an ASP.NET application: For a directory: <authorization> <allow users="Kim"/> <allow roles="Admins"/> <deny users="John"/> <deny users="?"/> </authorization> For a Single file: <location path=“SecuredFile.aspx”><system.web> <authorization> <allow users="Joe"/> <deny users="*"/> </authorization> </system.web></location> Authentication for Web Applications (Contd.)
  • 11. Slide 11 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Microsoft ASP.NET membership gives a built-in way to validate and store user credentials. It can be used with ASP.NET Forms authentication or with the ASP.NET login controls to create a complete system for authenticating users. It supports facilities for: Creating new users and passwords Storing membership information in a data store Authenticating users Managing passwords Exposing a unique identification for authenticated users Specifying a custom membership provider Introduction to Membership
  • 12. Slide 12 of 26Ver. 1.0 Developing Web Applications Using ASP.NET ASP.NET 2.0 includes a set of classes that enable you to implement a membership system. You can use the Membership class to configure a membership system. The Membership class provides a range of methods for managing the members of a Web site: CreateUser DeleteUser UpdateUser ValidateUser FindUserByEmail FindUserByName Introduction to Membership (Contd.)
  • 13. Slide 13 of 26Ver. 1.0 Developing Web Applications Using ASP.NET To use membership, the site must be configured to use it by performing the following steps: 1. Specify membership options as part of your website configuration. 2. Configure the application to use Forms authentication. 3. Define user accounts for membership. After configuring membership for your site, you must create a login form. Login form can be created by hand using TextBox controls or by using Login controls. How Membership Works
  • 14. Slide 14 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Login controls are a set of Web server controls that provide the common user interface elements of a membership system. Login controls automatically use the membership system to validate a user. The following controls are available in the Login group of the Toolbox: CreateUserWizard Login LoginStatus LoginView PasswordRecovery ChangePassword How Membership Works (Contd.)
  • 15. Slide 15 of 26Ver. 1.0 Developing Web Applications Using ASP.NET In case login form is created by hand: You need to prompt the user for a user name and password and then call the ValidateUser method to perform the validation. You can call methods of the FormsAuthentication class after authentication to create a cookie and write it to the user’s computer. After authentication is done, an object is created that contains information about the current user. This object can be used to retrieve information about the user, such as user’s name, email address, date, and time of last logon. How Membership Works (Contd.)
  • 16. Slide 16 of 26Ver. 1.0 Developing Web Applications Using ASP.NET The membership system allows your application to accept and work with anonymous users. Before using anonymous identification, it needs to be enabled. A temporary ID is assigned to unauthenticated users to track their sessions. The ID is stored in a cookie or embedded in the URL of requested pages. If an anonymous user logs in, the anonymous identification information is discarded and the user is treated thereafter as an authenticated user. Anonymous Users in the Membership System
  • 17. Slide 17 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Membership system can be configured in the application’s Web.config file. The easiest way to configure and manage memberships is with the Web Site Administration tool. Specifications of membership configuration include: Membership provider to use Password options Users and passwords Membership Configuration and Management
  • 18. Slide 18 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Membership can be integrated with ASP.NET role management to provide authorization services for your site. Roles can be used to manage the permissions for large numbers of users. By grouping users into roles, permissions can be assigned once for many users. Roles and Authorization: In URL authorization mode, access to a directory can be configured by using the Web.config file in each directory. Roles can be added to the <authorization> section as: <authorization> <allow roles="Admin"/> <allow roles="PowerUsers" /> <deny users="?"/> </authorization> Web Site Security Administration Using the Roles Class
  • 19. Slide 19 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Role Management Configuration: Role management must be configured in the Web.config file in the root folder of the Web application. To enable role management, the following item can be included in the Web.Config file: <roleManager enabled="true" cacheRolesInCookie="true"> </roleManager> Web Site Security Administration Using the Roles Class (Contd.)
  • 20. Slide 20 of 26Ver. 1.0 Developing Web Applications Using ASP.NET You can create and populate roles by: Using the ASP.NET Web Site Administration Tool Writing code by using the Roles class Example of creating and populating roles by using the Roles class: Roles.CreateRole("Subscribers"); Roles.AddUsersToRole("Anatoly Sabantsev", "Subscribers"); Roles.AddUsersToRole("Bobby Moore", "Subscribers"); You can use the User object to check whether the current user is a member of a particular role: if (! User.IsInRole("Subscribers")) btnDownloadFile.Visible = false; Web Site Security Administration Using the Roles Class (Contd.)
  • 21. Slide 21 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Problem Statement: You are a developer in the Adventure Works organization, a fictitious bicycle manufacturer. You have been asked to assist in the development of the Business-to-Consumer (B2C) Web application and a related Business-to-Employee (B2E) extranet portal. Decisions on the design of the application have already been made. You have been asked to carry out a number of specific tasks in order to implement various elements of this design. Demo: Controlling Access to a Web Application
  • 22. Slide 22 of 26Ver. 1.0 Developing Web Applications Using ASP.NET As part of the first phase of the B2C development, you have been asked to complete the prototypes for the following pages: • MembersLogin.aspx. This page collects and checks credentials to identify the user. • Register.aspx. This page enables users to become members of the site. • Employees.aspx. This page shows sales figures for the Adventure Works staff, and it should be viewable only by employees. • MemberUpdate.aspx. This page enables users to change the e- mail address and password stored for their account. • Admin.aspx. This page enables site administrators to change the role membership on the site. You will also ensure that several pages are secured properly. Demo: Controlling Access to a Web Application (Contd.)
  • 23. Slide 23 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Solution: You need to perform following tasks: 1. Configuring Authentication and Authorization for a Web Application a. Open the Adventure Works Web site for editing in Visual Studio. b. Implement Forms authentication for the Web application. c. Configure authorization for anonymous users and members. d. Configure IIS. e. Implement Windows authentication for the Employees page. 2. Implementing a Membership Registration Page a. Install the SQL Server provider database. b. Configure the ASP.NET SQL Server membership provider. c. Create the membership registration page. d. Create the membership update page. Demo: Controlling Access to a Web Application (Contd.)
  • 24. Slide 24 of 26Ver. 1.0 Developing Web Applications Using ASP.NET 3. Implementing a Login Page and Adding Login Controls a. Create the login page and add the Login control. b. Add a PasswordRecovery Web server control to the login page. c. Add login controls to other pages. d. Test the login and membership features. 3. Creating a Membership Management Administrative User Interface a. Configure the Web application to use the SQL Roles provider. b. Complete the Admin.aspx page. c. Secure the Administration page. Demo: Controlling Access to a Web Application (Contd.)
  • 25. Slide 25 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Summary In this session, you learned that: Authentication is the process by which users prove their identity. In Microsoft Windows authentication, IIS identifies the user by comparing the credentials entered by the user against the user’s Windows account. In Form authentication, credentials entered by the user in the login page are checked with credentials stored in the database or Web.config file for authentication. Passport authentication is a centralized authentication service provided by Microsoft. Authorization is a process in which after authentication, the application determines the pages and resources that the user can access.
  • 26. Slide 26 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Summary (Contd.) In File Authorization, access permissions can be set on any file or folder stored on a disk formatted with the NTFS file system. In URL authorization, access to each virtual directory can be controlled within the website hierarchy. The Membership class provides methods for creating, deleting, and updating user accounts, authenticating users, and managing passwords. Roles can be created to reduce the administrative overhead of managing permissions for large numbers of users.