Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.8 KiB

  1. function GetText(oTextInput)
  2. {
  3. var szValue = oTextInput.value;
  4. return szValue ? szValue : '';
  5. }
  6. function PageInit()
  7. {
  8. var oUser = top.window.g_oSelectedUser;
  9. top.window.PopulateLeftPane(null, null, top.window.CreateUserDisplayHTML(oUser));
  10. var szName = top.window.GetUserDisplayName(oUser);
  11. var szTitle;
  12. var szSubTitle;
  13. if (top.window.IsSelf())
  14. {
  15. szTitle = idPageTitle.innerHTML;
  16. szSubTitle = idPageSubtitle.innerHTML;
  17. idOldPassword.style.display = 'block';
  18. idOldPasswordInput.focus();
  19. var szHint = oUser.setting("Hint");
  20. if (szHint && szHint.length > 0)
  21. idShowHint.style.display = 'block';
  22. }
  23. else
  24. {
  25. szTitle = idAltPageTitle.innerHTML;
  26. szSubTitle = (top.window.g_bOsPersonal ? L_Personal_Message : L_Pro_Message) + idAltPageSubtitle.innerHTML + (oUser.isPasswordResetAvailable ? L_Backup_Message : L_NoBackup_Message);
  27. idOK.focus();
  28. }
  29. idPageTitle.innerHTML = szTitle.replace(/%1/g, szName);
  30. idPageSubtitle.innerHTML = szSubTitle.replace(/%1/g, szName);
  31. }
  32. function RemovePassword()
  33. {
  34. var bNavigate = true;
  35. var oUser = top.window.g_oSelectedUser;
  36. var nErr = 0;
  37. try
  38. {
  39. oUser.changePassword("", GetText(idOldPasswordInput));
  40. oUser.setting("Hint") = "";
  41. }
  42. catch (e)
  43. {
  44. nErr = (e.number & 0xffff);
  45. //alert("Change password error = " + nErr); // for debugging only
  46. }
  47. if (0 != nErr)
  48. {
  49. if (top.window.IsSelf())
  50. {
  51. idOldPasswordInput.value = '';
  52. idOldPasswordInput.focus();
  53. }
  54. var strMsg = top.window.L_RemovePassword_ErrorMessage;
  55. switch (nErr)
  56. {
  57. case 86: // ERROR_INVALID_PASSWORD
  58. case 1323: // ERROR_WRONG_PASSWORD
  59. strMsg = top.window.L_InvalidPassword_Message;
  60. bNavigate = false;
  61. break;
  62. // I've only seen NERR_PasswordTooShort and ERROR_ACCOUNT_RESTRICTION
  63. // in testing, and it's possible to get either of them for the
  64. // same password, depending on current policy settings.
  65. // That is, it's hard to distinguish them, so don't bother.
  66. // We may want to give separate messages for some of the others,
  67. // but I've never hit them.
  68. case 1324: // ERROR_ILL_FORMED_PASSWORD
  69. case 1325: // ERROR_PASSWORD_RESTRICTION
  70. case 1327: // ERROR_ACCOUNT_RESTRICTION
  71. case 2243: // NERR_PasswordCantChange
  72. case 2244: // NERR_PasswordHistConflict
  73. case 2245: // NERR_PasswordTooShort
  74. case 2246: // NERR_PasswordTooRecent
  75. strMsg = top.window.L_PasswordRequired_Message;
  76. break;
  77. }
  78. alert(strMsg);
  79. }
  80. if (bNavigate)
  81. top.window.g_Navigator.navigate("mainpage.htm", true);
  82. }