UserPrincipal.ChangePassword 抛出 PasswordException
UserPrincipal.ChangePassword Throwing PasswordException
我有一个为我的员工和 UserPrincipal
对象创建的密码重置页面,我执行以下操作:
UserPrincipal user = Helpers.LDAPHelper.GetUserPrincipal(model.EmailAddress);
string temporary = Membership.GeneratePassword(12, 4);
user.SetPassword(temporary);
user.ChangePassword(temporary, model.ConfirmPassword);
user.SetPassword
调用工作正常,但不会触发密码已更改,因此我所做的任何密码年龄跟踪(提醒用户在密码过期前重置密码)都不起作用。所以,我想因为 ChangePassword
方法需要当前密码,所以我设置了一个临时密码,然后将其用作当前密码。但是,它每次都会抛出一个 PasswordException
:
"The password does not meet the password policy requirements. Check
the minimum password length, password complexity and password history
requirements. (Exception from HRESULT: 0x800708C5)"
谁能告诉我哪里做错了?
哦,我忘了包括组策略设置:
应该是新密码抛出的异常,新密码是字符串吗?另外,是否可以有除默认策略之外的密码策略。
我有一个为我的员工和 UserPrincipal
对象创建的密码重置页面,我执行以下操作:
UserPrincipal user = Helpers.LDAPHelper.GetUserPrincipal(model.EmailAddress);
string temporary = Membership.GeneratePassword(12, 4);
user.SetPassword(temporary);
user.ChangePassword(temporary, model.ConfirmPassword);
user.SetPassword
调用工作正常,但不会触发密码已更改,因此我所做的任何密码年龄跟踪(提醒用户在密码过期前重置密码)都不起作用。所以,我想因为 ChangePassword
方法需要当前密码,所以我设置了一个临时密码,然后将其用作当前密码。但是,它每次都会抛出一个 PasswordException
:
"The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. (Exception from HRESULT: 0x800708C5)"
谁能告诉我哪里做错了?
哦,我忘了包括组策略设置:
应该是新密码抛出的异常,新密码是字符串吗?另外,是否可以有除默认策略之外的密码策略。