A simple user Login authentication class in ASP

Source: Internet
Author: User

The source code is as follows:

<% ' ==========================================================================
'
' User Login Authentication class
'
' Name:checklogin
'
' Author:infozero
' Date:2006-5-28
'
' COMMENT: User Login Authentication Class
'
'==========================================================================

Class Checklogin
'==========================================================================
' Function: Sensitive character filtering
' Str---> characters to filter
' ReturnCode---> return type, 0-digit; 1-character. Returns a null value if the number contains sensitive characters, and the default return string
'==========================================================================
Private Sub Class_Initialize ()
Dim Loginflag:loginflag = 0
End Sub


' Private Function getsafestr (Str,returncode)
' Dim Temp
' Select case ReturnCode
' Case 0
' If isnumeric (Str) = False Then
' Temp = '
' Else
' Temp = Str
' End If
' Case 1
' Temp = Replace (str, ' ' ', ' ' ')
' Temp = Replace (str, <, "")
' Temp = Replace (str, >, "")
' Case Else
' Temp = Replace (str, ' ' ', ' ' ')
' End Select
' Getsafestr = Temp
' End Function

'==========================================================================
' Verify user Login
' Frmname user-entered user name
' Frmpassword user-entered password
' User name in Tagetname datasheet
' Targetpassword the code in the data table
'==========================================================================
Public Sub Checklogininfo (Frmname,frmpassword,tagetname,targetpassword)
If frmname = tagetname and Frmpassword = Targetpassword Then
Loginflag = 1
Session ("LoginName") = Frmname
End If
End Sub

'==========================================================================
' Access to the user's login information can be based on this to determine whether the user has landed
'==========================================================================
Public Function Loginnameinfo ()
Loginnameinfo = Session ("LoginName")
End Function

'==========================================================================
' Determine if the user is logged in as an administrator, and the default is no
' If you want to confirm that you are logged in as an administrator, the value of Yesorno is 1.
'==========================================================================
Public Function ISAdmin (Yesorno)
If Trim (Loginnameinfo ()) <> "" and Yesorno = "Yes" Then
ISAdmin = True
Else
ISAdmin = False
End If
End Function

'==========================================================================
' Implement directory-level access restrictions on Web site resources
' Denydir-restricted folders such as/cls/test/
' Errpage-no landing on the prompt page when accessing restricted folders
' Adminpermission-allow admin to access 0-no, 1-yes
'==========================================================================
Public Function dirpermission (ByVal denydir,byval errpage,adminpermission)
Dim Target
Target = Trim (Request.ServerVariables ("Script_name"))
If InStr (Target,denydir) <> 0 and adminpermission = 0 and ISAdmin ("yes") = False Then
Response.Redirect (Errpage)
End If

End Function

Private Sub Class_Terminate ()
Loginflag = 0
End Sub
End Class

%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.