Leaked source code of windows server 2003
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.

133 lines
4.4 KiB

  1. function GetText(oTextInput)
  2. {
  3. var szValue = oTextInput.value;
  4. return szValue ? szValue : '';
  5. }
  6. function PWInit(bSelf)
  7. {
  8. var oUser = top.window.g_oSelectedUser;
  9. var szName = top.window.GetUserDisplayName(oUser);
  10. idPageTitle.innerHTML = idPageTitle.innerHTML.replace(/%1/g, szName);
  11. top.window.PopulateLeftPane(null, idLearnAboutContent.innerHTML);
  12. idHintDefn.ttText = bSelf ? top.window.L_SelfHint_ToolTip : top.window.L_NonSelfHint_ToolTip;
  13. if (!bSelf)
  14. {
  15. var strReset = (top.window.g_bOsPersonal ? L_Personal_Message : L_Pro_Message) + (oUser.isPasswordResetAvailable ? L_Backup_Message : L_NoBackup_Message);
  16. idResetWarning.innerHTML = strReset.replace(/%1/g, szName);
  17. }
  18. idNewPassword1Input.focus();
  19. }
  20. function ApplyPasswordChange()
  21. {
  22. var szNewPassword1 = GetText(idNewPassword1Input);
  23. var szNewPassword2 = GetText(idNewPassword2Input);
  24. if (szNewPassword1 == szNewPassword2)
  25. {
  26. var oUser = top.window.g_oSelectedUser;
  27. var bSelf = top.window.IsSelf();
  28. var bOldPW = oUser.passwordRequired;
  29. var nErr = 0;
  30. try
  31. {
  32. oUser.changePassword(szNewPassword1, (bSelf && bOldPW) ? GetText(idOldPasswordInput) : "");
  33. oUser.setting("Hint") = GetText(idHintInput);
  34. }
  35. catch (e)
  36. {
  37. nErr = (e.number & 0xffff);
  38. //alert("Change password error = " + nErr); // for debugging only
  39. }
  40. if (0 == nErr)
  41. {
  42. // If the current user is an admin and just created a password for
  43. // herself, ask if she wants to make her profile folder private.
  44. //
  45. // However, if she just made a folder private, which caused us
  46. // to be launched with initialTask=ChangePassword, then we don't
  47. // want to do this prompt.
  48. if (top.window.g_szInitialTask != "ChangePassword" &&
  49. bSelf && !bOldPW &&
  50. top.window.g_bRunningAsOwner)
  51. {
  52. var bPrivate = false;
  53. var bCanMakePrivate = true;
  54. try
  55. {
  56. bPrivate = oUser.isProfilePrivate;
  57. }
  58. catch (e)
  59. {
  60. bCanMakePrivate = false;
  61. }
  62. if (bCanMakePrivate && !bPrivate)
  63. {
  64. top.window.g_Navigator.navigate("passwordpage2.htm");
  65. return;
  66. }
  67. }
  68. top.window.g_Navigator.navigate("mainpage.htm", true);
  69. }
  70. else
  71. {
  72. idNewPassword1Input.value = '';
  73. idNewPassword2Input.value = '';
  74. idHintInput.value = '';
  75. idNewPassword1Input.focus();
  76. var strMsg = top.window.L_ChangePassword_ErrorMessage;
  77. switch (nErr)
  78. {
  79. case 86: // ERROR_INVALID_PASSWORD
  80. case 1323: // ERROR_WRONG_PASSWORD
  81. if (bSelf && bOldPW)
  82. {
  83. idOldPasswordInput.value = '';
  84. idOldPasswordInput.focus();
  85. strMsg = top.window.L_InvalidPassword_Message;
  86. }
  87. break;
  88. // I've only seen NERR_PasswordTooShort and ERROR_ACCOUNT_RESTRICTION
  89. // in testing, and it's possible to get either of them for the
  90. // same password, depending on current policy settings.
  91. // That is, it's hard to distinguish them, so don't bother.
  92. // We may want to give separate messages for some of the others,
  93. // but I've never hit them.
  94. case 1324: // ERROR_ILL_FORMED_PASSWORD
  95. case 1325: // ERROR_PASSWORD_RESTRICTION
  96. case 1327: // ERROR_ACCOUNT_RESTRICTION
  97. case 2243: // NERR_PasswordCantChange
  98. case 2244: // NERR_PasswordHistConflict
  99. case 2245: // NERR_PasswordTooShort
  100. case 2246: // NERR_PasswordTooRecent
  101. strMsg = top.window.L_PasswordTooShort_Message;
  102. break;
  103. }
  104. alert(strMsg);
  105. }
  106. }
  107. else
  108. {
  109. idNewPassword1Input.value = '';
  110. idNewPassword2Input.value = '';
  111. idNewPassword1Input.focus();
  112. alert(top.window.L_PasswordMismatch_Message);
  113. }
  114. }