Re: User Login via SQL Server...(ASP Pages)...
From: Mary Chipman (mchip@nomail.please)
Date: 03/24/03
- Next message: John Saunders: "Re: Managed to Unmanaged security."
- Previous message: Chris Blanco: "Re: Managed to Unmanaged security."
- In reply to: Luke: "User Login via SQL Server...(ASP Pages)..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: Mary Chipman <mchip@nomail.please> Date: Mon, 24 Mar 2003 15:39:28 -0500
Even if your code did work, it would leave you vulnerable to SQL
Injection attacks. If the error isn't on the connection opening, then
the best way to test your query strings is to open a Query Analyzer
window and paste in the string. Sometimes it's just a proofreading
error. A better solution to the code you have here would be to create
a stored procedure that returns 0 or 1 if the user is found in the
users table, and pass the user name and password as parameter values
to the stored procedure. You want to validate all input parameters
both in your page and in your stored procedure. The way it is now it
would be a piece of cake for an attacker to get all the user names and
passwords in the database.
-- Mary
MCW Technologies
http://www.mcwtech.com
On Mon, 24 Mar 2003 11:44:50 +1100, "Luke" <lwoolhouse@janison.com.au>
wrote:
>I am trying to validate users via a SQL Server. But something is wrong with
>my code.
>I think i've seen every single tutorial and example on the net, however I
>can't get it to work.
>
>Any help would be nice. Am I going about the procedure correctly?
>
>Thanks,
>Luke
>
>Heres the asp code:
>
><%
> Dim objConnection, objRecordSet, strSQL
>
> Set objConnection = Server.CreateObject("ADODB.Connection")
> Set objRecordSet = Server.CreateObject("ADODB.Recordset")
>
> objConnection.Open "Provider=SQLOLEDB.1;Data Source=TRILLIAN;User
>ID=sqluser;Password=xxxxx;Initial Catalog=ComicChat"
>
> Dim strUsername, strPassword
> strUsername = Request.Form("UsernameBox")
> strPassword = Request.Form("PasswordBox")
>
> strSQL = "SELECT * FROM tblUsers "
> strSQL = strSQL & " WHERE Username='" & strUsername & "'"
> strSQL = strSQL & " AND Password='" & strPassword & "'"
>
> objRecordSet.Open strSQL, objConnection 'This bit isn't working...Is it
>because my SQL string is whack?
>
> Response.Write "Yes, the above code is really working..."
>%>
>
- Next message: John Saunders: "Re: Managed to Unmanaged security."
- Previous message: Chris Blanco: "Re: Managed to Unmanaged security."
- In reply to: Luke: "User Login via SQL Server...(ASP Pages)..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|