UserPrincipal.ChangePassword Throwing PasswordException

1

I have a password reset page that I created for my employees and for the UserPrincipal object, I perform the following:

UserPrincipal user = Helpers.LDAPHelper.GetUserPrincipal(model.EmailAddress);

string temporary = Membership.GeneratePassword(12, 4);

user.SetPassword(temporary);
user.ChangePassword(temporary, model.ConfirmPassword);

The user.SetPassword call works fine, but does not trigger that the password has changed, so any password age tracking that I do (to remind users to reset their password before it expires) does not work. So, I wanted to since the ChangePassword method requires the current password, I set a temporary password and then use that as the current. BUT, it throws a PasswordException every time:

"The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. (Exception from HRESULT: 0x800708C5)"

Can someone tell me what I'm doing wrong?

Oh, I forgot to include the Group Policy settings: enter image description here

c#
active-directory
change-password
asked on Stack Overflow Jul 13, 2017 by clockwiseq

1 Answer

1

It should be the new password that is throwing the exception, is the new one a string? Also, could there be password policy other than that one such as a default policy.

answered on Stack Overflow Jul 13, 2017 by S. Hurley

User contributions licensed under CC BY-SA 3.0