% @ Language = VBScript %> <% Option Explicit With Response .Buffer = true .Expires = 0 .Clear End With %> <% Dim oAuth, bAuthorized Set oAuth = new DBAuthorization oAuth.ConnString = "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("./mydata.mdb") oAuth.ConnUser = "" oAuth.ConnPass = "" oAuth.UserName = request.form("user") oAuth.Password = request.form("pass") bAuthorized = oAuth.Authorized() Set oAuth = nothing ' if they want to logout, reset security and redirect to form. If Request.ServerVariables("QUERY_STRING") = "logout" Then Session.Abandon Response.redirect "./restrictedAccessDb.asp" End If if bAuthorized then session("authorized") = 1 ' welcome to the system ' handle any unauthorized usrs who didn't submit the form. If session("authorized") <> 1 then session("authorized") = 0 ' check for authentication for this page and if there is none, display the form ' otherwise display the entire page as it appears below. If session("authorized") <> 1 then Dim pageText ' display form to allow user to enter info pageText = pageText & "" & vbCrLf pageText = pageText & "
" & vbCrLf pageText = pageText & "" & vbCrLf pageText = pageText & " " & vbCrLf & "" & vbCrLf response.write pageText response.end End If ' everything below this point has been secured by ASP ' and is restricted from casual viewing. ' On any other page, you would use the following block of ' code to check for authentication (remove comments when ' using in another file): ' If session("authorized") <> 1 then ' response.write "You are not allowed to view this page." ' response.end ' End If ' to log someone out, call the ' session.abandon ' method and the user will have to enter their user name and password to ' view the restricted page again. %>