關於ASPNET_Membership用戶被鎖的解決

轉:http://jeremywadsworth.com/Default.aspx?blogentryid=42
總結如下:
      使用ASPNET_Membership用戶登錄失敗,用戶被鎖。兩種方法解鎖。
     1.手工修改ASPNET_Membership 數據庫表的IsLockedOut的字段爲False;
     2.程序修改,For Each user As MembershipUser In memberList
                                 If user.IsLockedOut = True Then user.UnlockUser()

原文如下:

The user account has been locked out
The error occurred when a user got locked out and then the administrator tried to go in and view the grid of users. When the code tried to retrieve the password for the locked out user, a MembershipPasswordException error was thrown. You can’t retrieve certain information for a user in ASP.NET 2.0 when that user has been locked. In the ASPNET_Membership table the column is IsLockedOut. When this column is set to 1 for a user in the table, you will not be able to retrieve the password.

A user gets locked out when they have too many failed login attempts and usually only get locked out for 10 minutes unless you’ve changed it to be a longer period.

In order to get around this error, I have to check if the user is locked out before trying to retrieve their password. If they are locked out I just call the UnlockUser method off of the membershipuser object. The following code illustrates this.

For Each user As MembershipUser In memberList
   If user.IsLockedOut = True Then user.UnlockUser()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章