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.

172 lines
3.2 KiB

  1. // Copyright (C) 1997 Microsoft Corporation
  2. //
  3. // Admin password page
  4. //
  5. // 2-4-98 sburns
  6. #include "headers.hxx"
  7. #include "adpass.hpp"
  8. #include "resource.h"
  9. #include "state.hpp"
  10. #include "ds.hpp"
  11. #include "common.hpp"
  12. AdminPasswordPage::AdminPasswordPage()
  13. :
  14. DCPromoWizardPage(
  15. IDD_ADMIN_PASSWORD,
  16. IDS_PASSWORD_PAGE_TITLE,
  17. IDS_PASSWORD_PAGE_SUBTITLE)
  18. {
  19. LOG_CTOR(AdminPasswordPage);
  20. }
  21. AdminPasswordPage::~AdminPasswordPage()
  22. {
  23. LOG_DTOR(AdminPasswordPage);
  24. }
  25. void
  26. AdminPasswordPage::OnInit()
  27. {
  28. LOG_FUNCTION(AdminPasswordPage::OnInit);
  29. // NTRAID#NTBUG9-202238-2000/11/07-sburns
  30. password.Init(Win::GetDlgItem(hwnd, IDC_PASSWORD));
  31. confirm.Init(Win::GetDlgItem(hwnd, IDC_CONFIRM));
  32. State& state = State::GetInstance();
  33. if (state.UsingAnswerFile())
  34. {
  35. EncryptedString pwd =
  36. state.GetEncryptedAnswerFileOption(AnswerFile::OPTION_ADMIN_PASSWORD);
  37. Win::SetDlgItemText(hwnd, IDC_PASSWORD, pwd);
  38. Win::SetDlgItemText(hwnd, IDC_CONFIRM, pwd);
  39. }
  40. }
  41. static
  42. String
  43. getPasswordMessage()
  44. {
  45. LOG_FUNCTION(getPasswordMessage);
  46. State& state = State::GetInstance();
  47. unsigned id = IDS_ENTER_DOMAIN_ADMIN_PASSWORD;
  48. switch (state.GetOperation())
  49. {
  50. case State::FOREST:
  51. case State::TREE:
  52. case State::CHILD:
  53. {
  54. // do nothing, id is already set.
  55. break;
  56. }
  57. case State::ABORT_BDC_UPGRADE:
  58. case State::DEMOTE:
  59. {
  60. id = IDS_ENTER_LOCAL_ADMIN_PASSWORD;
  61. break;
  62. }
  63. case State::REPLICA:
  64. case State::NONE:
  65. default:
  66. {
  67. ASSERT(false);
  68. break;
  69. }
  70. }
  71. return String::load(id);
  72. }
  73. bool
  74. AdminPasswordPage::OnSetActive()
  75. {
  76. LOG_FUNCTION(AdminPasswordPage::OnSetActive);
  77. State& state = State::GetInstance();
  78. if (state.RunHiddenUnattended())
  79. {
  80. // fully-qualify the Validate call, as it is virtual...
  81. int nextPage = AdminPasswordPage::Validate();
  82. if (nextPage != -1)
  83. {
  84. GetWizard().SetNextPageID(hwnd, nextPage);
  85. }
  86. else
  87. {
  88. state.ClearHiddenWhileUnattended();
  89. }
  90. }
  91. Win::PropSheet_SetWizButtons(
  92. Win::GetParent(hwnd),
  93. PSWIZB_BACK | PSWIZB_NEXT);
  94. Win::SetDlgItemText(hwnd, IDC_MESSAGE, getPasswordMessage());
  95. return true;
  96. }
  97. int
  98. AdminPasswordPage::Validate()
  99. {
  100. LOG_FUNCTION(AdminPasswordPage::Validate);
  101. int result = -1;
  102. EncryptedString password;
  103. if (IsValidPassword(hwnd, IDC_PASSWORD, IDC_CONFIRM, false, password))
  104. {
  105. State& state = State::GetInstance();
  106. state.SetAdminPassword(password);
  107. switch (state.GetOperation())
  108. {
  109. case State::ABORT_BDC_UPGRADE:
  110. case State::DEMOTE:
  111. {
  112. result = IDD_CONFIRMATION;
  113. break;
  114. }
  115. case State::REPLICA:
  116. case State::FOREST:
  117. case State::TREE:
  118. case State::CHILD:
  119. case State::NONE:
  120. default:
  121. {
  122. ASSERT(false);
  123. break;
  124. }
  125. }
  126. }
  127. return result;
  128. }