protected override Int32 GetRecentFailedUserNameAuthenticationCount(string name)
{
using (var cn = new SqlConnection(ConnectionStringAudit))
{
cn.Open();
using (var cmd = new SqlCommand())
{
cmd.Connection = cn;
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = @"Select count(RecordID)
from Security.AuthenticationHistory
where UserName = @UserName
and CreatedDate > @StartDate
order by CreatedDate desc";
#warning This should only check for attempts where IsAuthenticated == 0, and failures after the last success?
cmd.Parameters.AddWithValue("UserName", name);
cmd.Parameters.AddWithValue("StartDate", DateTime.UtcNow.AddMinutes(-FailurePeriodMinutes));
return (Int32)cmd.ExecuteScalar();
}
}
}