%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' Names of roles users may log in as
Const AdvisorRoleName = "Advisor"
Const GuestRoleName = "Guest"
Const TeleconferenceRoleName = "Teleconference"
Const AdminRoleName = "Admin"
' Returns the user name of the current user.
Function GetCurrentUserName( _
)
GetCurrentUserName = Session( "MM_Username" )
End Function
' Returns the role name of the current user.
Function GetCurrentRoleName( _
)
GetCurrentRoleName = Session( "MM_RoleName" )
End Function
' Validates that the current user is logged in and in the correct role. If the user is not logged
' in or not in the correct role, he/she is redirected to a login page.
Sub AuthorizeCurrentUser( _
RoleName, _
LoginPage _
)
Dim MM_grantAccess
Dim MM_qsChar
Dim MM_referrer
' *** Restrict Access To Page: Grant or deny access to this page
MM_grantAccess=false
' If the user is logged in,
If GetCurrentUserName( ) <> "" Then
' and if the user is in the correct role for this page,
If GetCurrentRoleName( ) = RoleName Then
' The user is grnated access
MM_grantAccess = true
End If
End If
' If the user is not allowed to view this page,
If Not MM_grantAccess Then
' Redirect the user to the appropriate login page
MM_qsChar = "?"
If (InStr(1,LoginPage,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
LoginPage = LoginPage & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(LoginPage)
End If
End Sub
%>
<% Session("username1") = Request("username") %>
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Request.QueryString
MM_valUsername=CStr(Request.Form("username"))
If MM_valUsername <> "" Then
MM_redirectLoginSuccess="advisor_central.asp"
MM_redirectLoginFailed="advisorlogin_fail.asp"
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = Application("CenturionCounsel_ConnectionString")
MM_rsUser.Source = "SELECT username, password"
MM_rsUser.Source = MM_rsUser.Source & " FROM advisors WHERE username='" & Replace(MM_valUsername,"'","''") &"' AND password='" & Replace(Request.Form("password"),"'","''") & "'"
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username") = MM_valUsername
Session("MM_RoleName") = AdvisorRoleName
if CStr(Request.QueryString("accessdenied")) <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>