Skip to content

Instantly share code, notes, and snippets.

@FilipDeVos
Last active December 15, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FilipDeVos/5344709 to your computer and use it in GitHub Desktop.
Save FilipDeVos/5344709 to your computer and use it in GitHub Desktop.
Public Sub Authenticate(username As String, password As String, connString As String)
Using oConn As New SqlConnection(connString)
'Check that connection exists and is open
oConn.Open()
If oConn.State = ConnectionState.Open Then
Using sqlCmd As New SqlCommand("EXEC dbo.sGetHashedPW @UserName = @userName", oConn)
sqlCmd.Parameters.Add("userName", SqlDbType.VarChar).Value = username
_pwhash = sqlCmd.ExecuteScalar
_authenticated = EncryptHash.VerifyHash(password, "SHA512", _pwhash)
If _authenticated Then
_username = username
_connString = oConn.ConnectionString
Using sessionCmd As New SqlCommand("EXEC dbo.sStartSession", oConn)
_hashToken = sqlCmd.ExecuteScalar
End Using
Else
clearVariables()
End If
End Using
End If
End Using
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment