diff --git a/extensions/mssql/src/objectManagement/ui/loginDialog.ts b/extensions/mssql/src/objectManagement/ui/loginDialog.ts index f396b93eb3..c8a5277684 100644 --- a/extensions/mssql/src/objectManagement/ui/loginDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/loginDialog.ts @@ -64,7 +64,7 @@ export class LoginDialog extends PrincipalDialogBase { this.objectInfo.password = newValue; + this.mustChangePasswordCheckbox.enabled = this.objectInfo.enforcePasswordPolicy && this.isPasswordChanged(); + // this handles the case where the mustChangePasswordCheckbox is disabled when a user changes the password input and reverts the change. In that case we want to reset the check state of this checkbox to its original value instead of using the potentially dirty state set during password input changes. + if (!this.mustChangePasswordCheckbox.enabled) { + this.mustChangePasswordCheckbox.checked = this.objectInfo.mustChangePassword; + } }, this.objectInfo.password ?? ''); const passwordRow = this.createLabelInputContainer(objectManagementLoc.PasswordText, this.passwordInput); this.confirmPasswordInput = this.createPasswordInputBox(objectManagementLoc.ConfirmPasswordText, async () => { }, this.objectInfo.password ?? ''); @@ -158,21 +163,26 @@ export class LoginDialog extends PrincipalDialogBase { const enforceExpiration = checked; this.objectInfo.enforcePasswordExpiration = enforceExpiration; - this.mustChangePasswordCheckbox.enabled = enforceExpiration; - this.mustChangePasswordCheckbox.checked = enforceExpiration; + if (this.options.isNewObject || this.isPasswordChanged()) { + this.mustChangePasswordCheckbox.enabled = enforceExpiration; + this.mustChangePasswordCheckbox.checked = enforceExpiration; + } }, this.objectInfo.enforcePasswordPolicy); this.mustChangePasswordCheckbox = this.createCheckbox(objectManagementLoc.MustChangePasswordText, async (checked) => { this.objectInfo.mustChangePassword = checked; - }, this.objectInfo.mustChangePassword); + }, this.objectInfo.mustChangePassword, this.options.isNewObject); items.push(this.enforcePasswordPolicyCheckbox, this.enforcePasswordExpirationCheckbox, this.mustChangePasswordCheckbox); @@ -187,6 +197,10 @@ export class LoginDialog extends PrincipalDialogBase