Hello all!
I'm hoping someone can check my work to see if there are any red flags with how I've handled this.
I am working on an Access interface linked to a SQL Server Backend, and just completed a password validation routine.
To start, I have a trigger in the SQL Server table that converts inserted passwords into salted and hashed strings. Paired with that I have a SQL Server Function called "passvalid" that salts and hashes the password entered in the login attempt and checks it against the string saved in the users table, returning a bit. I'm using a pass-through query to call the function from Access and check the return. I've copied the sub below. Thanks!
I'm hoping someone can check my work to see if there are any red flags with how I've handled this.
I am working on an Access interface linked to a SQL Server Backend, and just completed a password validation routine.
To start, I have a trigger in the SQL Server table that converts inserted passwords into salted and hashed strings. Paired with that I have a SQL Server Function called "passvalid" that salts and hashes the password entered in the login attempt and checks it against the string saved in the users table, returning a bit. I'm using a pass-through query to call the function from Access and check the return. I've copied the sub below. Thanks!
Code:
Private Sub cmdLogIn_Click()
Dim intID As Integer
Dim strPassword As String
intID = Me.cboUser
strPassword = Me.txtPassword
With CurrentDb.QueryDefs("qryPassValid")
.SQL = "SELECT dbo.passvalid(" & intID & ", '" & strPassword & "') AS valid"
.ReturnsRecords = True
End With
Dim Valid As Integer
Valid = DLookup("valid", "qryPassValid")
Select Case Valid
Case 0
MsgBox "Invalid password.", vbOKOnly, "Login"
Me.txtPassword = ""
Me.txtPassword.SetFocus
Case Else
'Routine that opens program
End Select
End Sub