mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 03:00:18 +08:00
feat: LDAP user can reset password with old password and new password (#3516)
* feat: support user reset password with old password and new password * feat: merge similar code
This commit is contained in:
@ -375,7 +375,7 @@ func GetExistUuids(owner string, uuids []string) ([]string, error) {
|
||||
return existUuids, nil
|
||||
}
|
||||
|
||||
func ResetLdapPassword(user *User, newPassword string, lang string) error {
|
||||
func ResetLdapPassword(user *User, oldPassword string, newPassword string, lang string) error {
|
||||
ldaps, err := GetLdaps(user.Owner)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -418,6 +418,15 @@ func ResetLdapPassword(user *User, newPassword string, lang string) error {
|
||||
}
|
||||
modifyPasswordRequest.Replace("unicodePwd", []string{pwdEncoded})
|
||||
modifyPasswordRequest.Replace("userAccountControl", []string{"512"})
|
||||
} else if oldPassword != "" {
|
||||
modifyPasswordRequestWithOldPassword := goldap.NewPasswordModifyRequest(userDn, oldPassword, newPassword)
|
||||
_, err = conn.Conn.PasswordModify(modifyPasswordRequestWithOldPassword)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return err
|
||||
}
|
||||
conn.Close()
|
||||
return nil
|
||||
} else {
|
||||
switch ldapServer.PasswordType {
|
||||
case "SSHA":
|
||||
|
Reference in New Issue
Block a user