Candor.Security.SqlProvider.UserProvider.GetRecentFailedUserNameAuthenticationCount C# (CSharp) Method

GetRecentFailedUserNameAuthenticationCount() protected method

Gets the number of times a user name has failed authentication within the configured allowable failure period.
protected GetRecentFailedUserNameAuthenticationCount ( string name ) : Int32
name string
return System.Int32
        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();
                }
            }
        }