1 CS 3870/CS 5870: Note 14
Prog5 Due 10 PM Wednesday, Oct 21 Authentication and Authorization 2
Prog6 Roles Management Sample Web Site 3
4 Prog 6 Create Folders Prog6, Admin, Member Copy files from Prog5 Modify Master Page and Content Pages Add Session Variables for Prog6 Make sure Prog6 is working before creating and assigning roles
5 Sub-Folders and Pages Member Default Shopping Checkout Admin Updating SetRoles CreateUser
Creating Roles Enabling RoleManager Web.config under the root folder Default is False 6
Roles Two Roles –Member –Admin 7
8 Role Management Users in role Admin can access pages in folder Admin User in role Member can access pages in folder Member One user can be assigned into multiple roles
New Users UserName: Windows Role: Member Password: your UWP Other: your choice 9
New Users UserName: WebProtocols Roles: Admin and Member Password: your UWP Other: your choice 10
11 Page SetRoles
12 Private Sub ListRolesBind() lstRoles.DataSource = Roles.GetAllRoles() lstRoles.DataBind() End Sub Protected Sub Button1_Click(...) Handles Button1.Click Roles.CreateRole(txtRole.Text) ListRolesBind() End Sub Protected Sub Button2_Click(...) Handles Button2.Click Roles.DeleteRole(txtRole.Text) ListRolesBind() End Sub Protected Sub Button3_Click(...) Handles Button3.Click Roles.AddUserToRole(lstUser.SelectedValue, lstRoles.SelectedValue) ListUsersBind() End Sub
13 Private Sub ListUsersBind() lstUsersInRole.DataSource = Roles.GetUsersInRole(lstRoles.SelectedValue) lstUsersInRole.DataBind() End Sub Protected Sub Button4_Click(...) Handles Button4.Click Roles.RemoveUserFromRole(lstUsersInRole.SelectedValue, lstRoles.SelectedValue) ListUsersBind() End Sub Protected Sub lstRoles_SelectedIndexChanged(...) Handles lstRoles.SelectedIndexChanged ListUsersBind() End Sub
Class Membership Handling Users lstUsers.DataSource = Membership.GetAllUsers() lstUsers.DataBind() 14
15 Web.Config Application Configuration File under the main web site
16 Setting Rights on Individual Pages Application Configuration File under the main web site
17 Sub-Folders and Pages Member Default Shopping Checkout Admin Updating SetRoles CreateUser
18 Authorization Configuration File under the folder Admin
19 Authorization Configuration File under the folder Member
20 Allow Multiple Roles (I) Configuration File under the folder Member
21 Allow Multiple Roles (II) Configuration File under the folder Member
Prog6 Each folder allows one role User WebPtotocols is in both roles 22
Allow and Deny Allow then Deny Deny then Allow will not work! 23
Prog6 24
Schedule Thursday: Lab 206 Do Prog5 and Project Lose 10 points if missing class 25
Test 2 Prog5 and Prog6 Authentication and Authorization Login Create User and Roles Assign users to roles Accessing Database Date: TBD 26