Authentication កនុង ASP.NET
ហោសូ ហនឿនWeb Form Security3
Name Description
FormsAuthentication
Authentication is performed using a form, and the identity is
stored in a cookie or in the URL. This authentication type is
the most common.
WindowsAuthentication
This option is used in intranets because it requires Windows
credentials to be sent by the browser.
UrlAuthorization
Authorization is performed using UrlAuthorizationModule,
which checks web.config for authorized users and checks
roles against a specified set of URLs.
FileAuthorization
Authorization is performed using the
FileAuthorizationModule, by checking the file ACLs of the
requested file.
Login ធោយធ្បើ CredentialUser Account
ហោ សូ ហនឿនWeb Form Security11
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
If (FormsAuthentication.Authenticate(txtUserName.Text, txtPassw.Text)) Then
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False)
End If
End Sub
12.
Membership API
ហោ សូហនឿនWeb Form Security12
The Membership API សាំណុាំ នន programming APIs
ដដល្ត្ូវបានធ្បើ្បាស់ធដើមបី interact ជាមួយ
membership features កនុង ASP.NET application។
ASP.NET ផ្តល់នូវ SQL Database មួយជាធរសចធៅកនុង
ASP.NET Application ស្មាប់រកាទ្ុក user របស់
Membership API ធឈ្លម ោះ “App_Data”។
13.
ការបធងកើត្ Membership API
ហោសូ ហនឿនWeb Form Security13
Web Application Developer អាចបធងកើត្ login account
(user) របស់ membership API ធោយការធ្បើ ASP.Net
Configuration។
Website មួយអ្នុញ្ញា ត្ឲ្យ users បធងកើត្ login account
(user) របស់ membership API ធោយការធ្បើ
CreateUserWizards Control។
14.
ការបធងកើត្ Membership APIធោយធ្បើ ASP.NET Configuration
ហោ សូ ហនឿនWeb Form Security14
1. ចូលធៅ Website => ASP.Net Configuration
ASP.Net
Configuration
15.
ការបធងកើត្ Membership APIធោយធ្បើ ASP.NET Configuration
ហោ សូ ហនឿនWeb Form Security15
2. ចូលធៅ Security
3. ចូលធៅ Create User
16.
ការបធងកើត្ Membership APIធោយធ្បើ ASP.NET Configuration
ហោ សូ ហនឿនWeb Form Security16
កនុងករណី Security មិនមាន Create User tab ធយើង្ត្ូវកាំណត្់
Authentication របស់ Website ធោយកាំណត្់យក “From the Internet”
=> Select Authentication Type => From The Internet
Select Authentication Type
From the Internet
ការធ្វើ Web Configurationស្មាប់ SQL Membership APIs
ហោ សូ ហនឿនWeb Form Security18
1. ដាំធណើ រការ “aspnet_regsql.exe” ធៅកនុង
(C:WindowsMicrosoft.NETFrameworkv2.0)។
Server Name
Database Name
Role Manager
ហោ សូហនឿនWeb Form Security20
ចាំបាច់ណាស់ដដលធយើង្ត្ូវធរៀបចាំ users របស់
Website ធៅតាម្កុមនីមួយ ធដើមបីងាយរសួលស្មាប់
ការារកាំណត្់សិទ្ធិ និង្គប់្គង users។
Role Manager គឺជាដផ្នកមួយរបស់ WSAT (Webs Site
Administration Tools) ដដលអ្នុញ្ញា ត្ឲ្យ Web
Developers ធរៀបចាំ users ោក់ចូលតាម Role នីមួយៗ
បាន។
21.
ការបធងកើត្ Roles
ហោ សូហនឿនWeb Form Security21
ធៅកនុង Security=>Select ធលើ Enable Roles=>Select ធលើ Create or Manage Roles
22.
ការធរៀបចាំ Users តាមRoles នីមួយៗ
ហោ សូ ហនឿនWeb Form Security22
ចូលធៅ
Manage Users
ចុច Edit roles ធដើមបី
Add user ចូលកនុង Role
23.
Login Control
ហោ សូហនឿនWeb Form Security23
Login Control មានភាា ប់មកជាមួយនូវ
Username TextBox
Password TextBox
Error Message (Validation)
Remember for login next time
និង Log In Button
Login control ធ្បើ្បាស់ authentication ដដលបានកាំណត្់
ធៅកនុង “web.config” (FormAuthentication)។
24.
Login Control
ហោ សូហនឿនWeb Form Security24
ធយើងអាចបតូរទ្ាំរង់របស់ Login Control ធោយចូលធៅ Auto Format
Auto Format
25.
Login Control ជាមួយCredential User Account
ហោ សូ ហនឿនWeb Form Security25
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.AuthenticateEventArgs) Handles
Login1.Authenticate
If (FormsAuthentication.Authenticate(Login1.UserName, Login1.Password)) Then
FormsAuthentication.RedirectFromLoginPage(Login1.UserName, False)
End If
End Sub
26.
LoginName និង LoginStatusControls
ហោ សូ ហនឿនWeb Form Security26
LoginName Control ជា Web Security Control មួយដដលមាននាទ្ី
ទញយក និង បងាា ញធឈ្លម ោះរបស់ user ដដលបាន Log ចូល។
LoginStatus Control ជា Web Security Control មួយដដលអ្នុញ្ញា ត្ឲ្យ
Web Developer បធងកើត្ Log Out control ស្មាប់ឲ្យ user ធ្វើការ Log
Out វីញ។
LoginName
LoginStatus
Displayed
27.
CreateUserWizard Control
ហោ សូហនឿនWeb Form Security27
ដូចបានធលើកធ ើងធៅកនុង Membership API ធដើមបីអ្នុញ្ញា ត្ឲ្យ user
អាចចុោះធឈ្លម ោះជាសមាជិកធៅកនុង Website របស់ធយើងបាន ធយើង្ត្ូវ
មាន Page ស្មាប់បធងកើត្ user មួយដដលមាន CreateUserWizard
control។
<asp:CreateUserWizard ID="CreateUserWizard1"
runat="server">
<WizardSteps>
<asp:CreateUserWizardStep runat="server" />
<asp:CompleteWizardStep runat="server" />
</WizardSteps>
</asp:CreateUserWizard>