Getting the value of FailedPasswordAttemptCount from the object model, not database
I am trying to get the FailedPasswordAttemptCount
from the ASP.NET built in o开发者_如何学编程bjects and I am not able to find one, is there any way I can get this value without creating a new storedProc?
Excuse me if the question is redundant.
Thanks in advance.
The only one function of buil-in SqlMembershipProvider
uses this property I found is:
private void GetPasswordWithFormat(string username, bool updateLastLoginActivityDate, out int status, out string password, out int passwordFormat, out string passwordSalt, out int failedPasswordAttemptCount, out int failedPasswordAnswerAttemptCount, out bool isApproved, out DateTime lastLoginDate, out DateTime lastActivityDate)
it's private. Thus the best solution is to override the existed one, and roll your own with addition method to gather the data you need, e.g.:
public class MySqlMembershipProvider : SqlMembershipProvider
{
public int GetFailedPasswordAttemptCount (Guid userId)
{
// SELECT FailedPasswordAttemptCount FROM aspnet_Membership WHERE UserId = UserId
}
}
Usage:
var count = ((MySqlMembershipProvider)System.Web.Security.Membership.Provider).GetFailedPasswordAttemptCount(...);
精彩评论