望着核心代码(UserController.ChangePasswordByToken()),看来该密码历史检验的密码验证之前发生。历史记录检查还会将尝试的密码添加到历史记录中。因此,如果您的密码不符合验证规则,则可能会将其添加到历史记录中而不进行更改。
在主机>主机设置>高级设置>成员资格管理中,可以通过取消选中“启用密码历史记录”来禁用历史记录。
但是你需要关注密码验证,因为这似乎是失败的。它由网络中的AspNetSqlMembershipProvider的三个属性组成。配置:
- minRequiredPasswordLength
- minRequiredNonalphanumericCharacters
- passwordStrengthRegularExpression
就像你提到的,passwordStrengthRegularExpression为空或丢失,这样不应该关注的问题。确保输入的密码符合minRequiredPasswordLength中的最小字符长度并包含minRequiredNonalphanumericCharacters所需的非字母数字字符数。
下面是一个代码片段我使用注册新用户:
newUser = new UserInfo();
newUser.PortalID = this.PortalId;
newUser.IsSuperUser = false;
newUser.FirstName = txtFirstName.Text;
newUser.LastName = txtLastName.Text;
newUser.DisplayName = txtFirstName.Text + " " + txtLastName.Text;
newUser.Email = txtEmailAddress.Text.Trim();
newUser.Username = txtEmailAddress.Text.Trim();
newUser.LastIPAddress = Request.UserHostAddress;
newUser.Profile.ProfileProperties["CompanyName"].PropertyValue = txtCompanyName.Text;
newUser.Profile.ProfileProperties["AddressLine1"].PropertyValue = txtAddressLine1.Text;
newUser.Profile.ProfileProperties["AddressLine2"].PropertyValue = txtAddressLine2.Text;
newUser.Profile.City = txtCity.Text;
newUser.Profile.ProfileProperties["State"].PropertyValue = ddlState.SelectedValue;
newUser.Profile.PostalCode = wmeZipCode.Text.Trim().TrimEnd('-');
newUser.Profile.Telephone = wmePhoneNumber.Text;
if (lblWmePhoneNumberExtension.Text.Trim().CompareTo(String.Empty) != 0) { newUser.Profile.ProfileProperties["TelephoneExtension"].PropertyValue = wmePhoneNumberExtension.Text; }
var newMembership = new UserMembership(newUser);
newMembership.Approved = true;
newMembership.CreatedDate = DateTime.Now;
newMembership.IsOnLine = false;
newMembership.Password = txtPassword.Text;
newMembership.PasswordQuestion = ddlSecurityQuestion.SelectedValue;
newMembership.PasswordAnswer = txtSecurityQuestionAnswer.Text;
newUser.Membership = newMembership;
UserCreateStatus userStatus = membershipProvider.CreateUser(ref newUser);
感谢您的反馈意见。可悲的是,我仍然无法让这个工作。我具有以下值的属性:minRequiredPasswordLength =“8”minRequiredNonalphanumericCharacters =“1”。我正在使用一个我刚刚编制的全新密码“ChickEnHea%d”,它仍然不起作用:( 您有任何其他想法吗?唯一想到的可能是我的自定义用户注册模块没有做它应该为了使密码重置工作,我正在使用UserMembership对象来填充帐户创建密码 – KPhillipson
您可能需要提供一个登录提供程序代码片段,特别是如何设置密码。看着提供商我建,我用下面的行到的UserInfo对象上设置的密码: /*设置会员*/ UserMembership oNewMembership =新UserMembership(oUser){密码=密码}; /*绑定用户成员*/ oUser.Membership = oNewMembership; – DotNetNuclear
我将自定义注册码添加到原始帖子中。再次感谢你的帮助。 – KPhillipson