Last active
December 15, 2015 23:59
-
-
Save FilipDeVos/5344709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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