MembershipUser.UnlockUser 方法


清除用户的锁定状态以便可以验证成员资格用户。Clears the locked-out state of the user so that the membership user can be validated.

 virtual bool UnlockUser();
public virtual bool UnlockUser ();
abstract member UnlockUser : unit -> bool
override this.UnlockUser : unit -> bool
Public Overridable Function UnlockUser () As Boolean


如果成功取消成员资格用户的锁定,则为 true;否则为 falsetrue if the membership user was successfully unlocked; otherwise, false.


此方法不可用。This method is not available. 如果应用程序以 .NET Framework 4 Client Profile.NET Framework 4 Client Profile 为目标,则会发生这种情况。This can occur if the application targets the .NET Framework 4 Client Profile.NET Framework 4 Client Profile. 若要避免此异常,请重写该方法,或将应用程序更改为面向 .NET Framework 的完整版本。To prevent this exception, override the method, or change the application to target the full version of the .NET Framework.


当在中ValidateUser 到达PasswordAttemptWindow时,用户通常被锁定,并且不能通过方法MaxInvalidPasswordAttempts进行验证。Users are most commonly locked out and cannot be validated by the ValidateUser method when the MaxInvalidPasswordAttempts is reached within the PasswordAttemptWindow.

如果你使用GetPassword接受密码答案的或ResetPassword重载,并且Membership.MaxInvalidPasswordAttempts用户输入的错误答案的数目达到中Membership.PasswordAttemptWindow的值,则用户也可以被锁定。Users can also be locked out if you use the GetPassword or ResetPassword overload that accepts a password answer and the number of bad answers entered by the user reaches the value of Membership.MaxInvalidPasswordAttempts within the Membership.PasswordAttemptWindow.

此方法的实现应将IsLockedOut属性设置为false,并将LastLockoutDate属性设置为当前日期,并重置用于跟踪尝试中的失败日志数的任何计数器,等等。Your implementation of this method should set the IsLockedOut property to false, set the LastLockoutDate property to the current date, and reset any counters that you use to track the number of failed log in attempts and so forth.