示例#1
0
        /// <summary>
        /// Returns the number of times that the password for the specified account was incorrectly entered since the last successful login or since the membership account was created.
        /// </summary>
        /// <param name="userName">The user name of the account.</param>
        /// <returns>The count of failed password attempts for the specified account.</returns>
        /// <exception cref="System.InvalidOperationException">
        /// The <seealso cref="Initialized"/> method was not called.-or-
        /// The <seealso cref="InitializeDatabaseConnection(string)"/> method was not called.-or-
        /// The <seealso cref="MySqlSimpleMembershipProvider"/> membership provider is not registered in the configuration of your site.
        /// For more information, contact your site's system administrator.
        /// </exception>
        public static int GetPasswordFailuresSinceLastSuccess(string userName)
        {
            MySqlSimpleMembershipProvider provider = VerifyProvider();

            Debug.Assert(provider != null); // VerifyProvider checks this

            return(provider.GetPasswordFailuresSinceLastSuccess(userName));
        }
示例#2
0
 internal static bool IsAccountLockedOutInternal(MySqlSimpleMembershipProvider provider, string userName, int allowedPasswordAttempts, TimeSpan interval)
 {
     return(provider.GetUser(userName, false) != null &&
            provider.GetPasswordFailuresSinceLastSuccess(userName) > allowedPasswordAttempts &&
            provider.GetLastPasswordFailureDate(userName).Add(interval) > DateTime.Now);
 }