Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: authentication


Message #1 by nusrat sarwar <nusratsarwar@y...> on Sun, 23 Dec 2001 12:17:03 -0800 (PST)
Hello All!!

I am having problem with authenticate the user

its not redirecting to unauthorised page and giving

access to authorised page to every one.



if any one help me out 

I wanna  give access to only successfully login users

and if not redirect to login page.

if any one have any better idea it will be appreciated

its urgent



see the code and correct it and forgive wrong coding



<%@ Language=VBScript %>

<%option explicit %>



<%



On Error Resume Next





Dim adoCon 		

Dim strCon		

Dim rsCheckUser 		

Dim strSQL 		

Dim strUserName 	

Dim strPassword

Dim strLoginid

strUserName =rsCheckUser("username").value

strassword = Request.Form("password")

strLoginid = Request.Form("loginid")

Set adoCon = Server.CreateObject("ADODB.Connection")





strCon = "DRIVER=Microsoft Access Driver (*.mdb);DBQ="

& Server.MapPath("http://localhost/folder/mydb.mdb") 



adoCon.Open strCon





Set rsCheckUser 

Server.CreateObject("ADODB.Recordset")



strSQL = "SELECT username,loginid,Password FROM user

WHERE loginid ='" & strLoginid & "'"





rsCheckUser.Open strSQL, strCon



If NOT rsCheckUser.EOF Then

	

	

	If (Request.Form("password")) 

rsCheckUser("Password") Then

		

		Session("blnIsUserGood") = True

		

			Set adoCon = Nothing

		Set strCon = Nothing

		Set rsCheckUser = Nothing

		

		

		Response.Redirect"authorisedpage.asp"

	End If

End If









Set adoCon = Nothing

Set strCon = Nothing

Set rsCheckUser = Nothing

	



If

Session("blnIsUserGood") = False then



Response.Redirect"login.htm"

%>

-----------------



on  authorisedpage.asp

<%

If the session variable is False or does not exsist

then redirect the user to the unauthorised user page

If Session("blnIsUserGood") = False or

IsNull(Session("blnIsUserGood")) = True then

	

	Response.Redirect"unauthorised_user_page.htm"

End If

%>







__________________________________________________

Do You Yahoo!?

Send your FREE holiday greetings online!

http://greetings.yahoo.com


  Return to Index