Private Function Find_Failed_Logins()
Dim MyConnection As New OleDbConnection("Provider=SQLOLEDB.1;User Id=WeGotItRight_website;Password=sOnicgAtewa1y;database=WeGotItRight_website;server=secure.wegir.com;Use Encryption for Data=False")
Dim UsernameTry As String = SafeUsername
Dim paramValue As Object = "@username"
Dim MyCommand As New OleDbCommand("SELECT * FROM Login_Attempts WHERE Username = " & UsernameTry & " and Payload = Auth Failed and Date = " & Date.Now.Date & "", MyConnection) & " and Time = " & date.Now.ToLongTimeString
Try
Dim MyCommand As New OleDbCommand(("exec Retreave_Failed_Logins " & UsernameTry & ", " & Date.Now.Date & ""), MyConnection) & " and Time = " & date.Now.ToLongTimeString
Dim sqlselect As String = "exec Retreave_Failed_Logins @Usern, " & Date.Now.Date & ""
Dim MyCommand As New OleDbCommand(sqlselect, MyConnection) & " and Time = " & date.Now.ToLongTimeString
MyCommand.Parameters("@Usern").Value = UsernameTry.Trim()
Dim nowdate As DateTime = DateTime.Parse(Date.Now.ToLongTimeString)
Dim faileddate As DateTime = DateTime.Parse("6:51:49 AM")
MyConnection.Open()
Dim MyReader As OleDbDataReader = MyCommand.ExecuteReader()
While MyReader.Read
faileddate = DateTime.Parse(MyReader("Time"))
Dim TimeDiff As New TimeSpan(nowdate.Ticks - faileddate.Ticks)
If TimeDiff.TotalMinutes < 30 Then
Response.Write(TimeDiff.TotalMinutes & ";")
NumOfRec = NumOfRec + 1
End If
End While
validationwindow.Text = validationwindow.Text & "User failed to login: " & NumOfRec & " times within 30 minutes. " & vbNewLine
MyConnection.Close()
Catch
connectionstatus.Text = connectionstatus.Text & "Banned user lookup failed" & Err.Description & vbNewLine
End Try
Return NumOfRec
End Function