Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 21st, 2003, 03:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default authentication problem with the server

I want to authenticate the intranet site by following coding.
But I could not success to authenticate the page with server.
Please check the condition
If user = “rs” then page will redirect.

I could not get value in rs and condition not working.
How I can get value in rs so that I check condition.

following coding give this error message
"
Response object, ASP 0185 (0x8002000E)
A default property was not found for the object.
/dcil/signin.asp "

Please help.
What problem in this coding. how I can solved it.


<%
name = Request.ServerVariables("logon_user")

user = mid(name, 9, (len(name)-8))

dim ssql
set cn=server.CreateObject("adodb.connection")
cn.ConnectionString="Provider=SQLOLEDB.1;Integrate d Security=SSPI;Persist Security Info=False;Initial Catalog=dcil;Data Source=AUHTRIPSVR2"
cn.Open

ssql="select user_id from system order by user_id"

set rs=cn.Execute(ssql)

do while rs.eof=false

rs.movenext
loop

if user = "rs” then

Response.Redirect("trip.asp")

else

Response.Redirect("signin.asp")

end if


%>
 
Old July 22nd, 2003, 04:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are not checking whether any of the records contain the user's name. You are also comparing the variable user to a hard coded string "rs" therefore the only time the code will work is when the name is "rs".

Assuming the database table 'system' has a field 'user' which contains the user's name here is what I would do:

Code:
...
ssql = "SELECT user FROM system WHERE user = '" & user & "'"
Set rs = cn.Execute(ssql)
If Not rs.EOF Then
    Response.Redirect("trip.asp")
Else
    Response.Redirect("signin.asp")
End If
%>
You really need to think about how you are coding, this is a very simple problem that can be solved by using common sense.

The variable rs is a recordset which contains records, "rs" is a string that will always have a value of "rs" and unless you actually look for the row in your recordset instead of just looping through them all you will never find the correct row.

Hardly an ASP Pro Code question, more of a 'can someone teach me how to program' question.

Regards
Owain Williams
 
Old July 22nd, 2003, 04:03 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Why not just add a WHERE clause to your SQL, like this:
Code:
ssql="select user_id from system WHERE user_id='" & name & "'"

set rs=cn.Execute(ssql)

If rs.EOF Then
  Response.Redirect("signin.asp")
Else
  Response.Redirect("trip.asp")
End if
 
Old July 22nd, 2003, 05:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks you for your help

Mateen





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect to SQL Server using NT Authentication (ADO donnie200 Access VBA 5 July 15th, 2005 06:33 AM
problem in form authentication simmi BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 February 15th, 2005 02:14 PM
Secure SQL Server authentication sal ASP.NET 1.x and 2.0 Application Design 3 October 17th, 2004 04:02 PM
Authentication Problem CW Classic ASP Databases 2 October 30th, 2003 06:12 AM
forms authentication with sql server 2000 Lee8mm ASP.NET 1.0 and 1.1 Professional 0 September 26th, 2003 08:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.