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.

191 lines
3.4 KiB

  1. // Copyright (C) 1997 Microsoft Corporation
  2. //
  3. // new forest page
  4. //
  5. // 1-6-98 sburns
  6. #include "headers.hxx"
  7. #include "resource.h"
  8. #include "page.hpp"
  9. #include "ForestPage.hpp"
  10. #include "state.hpp"
  11. #include "common.hpp"
  12. #include <ValidateDomainName.hpp>
  13. #include <ValidateDomainName.h>
  14. ForestPage::ForestPage()
  15. :
  16. DCPromoWizardPage(
  17. IDD_NEW_FOREST,
  18. IDS_NEW_FOREST_PAGE_TITLE,
  19. IDS_NEW_FOREST_PAGE_SUBTITLE)
  20. {
  21. LOG_CTOR(ForestPage);
  22. }
  23. ForestPage::~ForestPage()
  24. {
  25. LOG_DTOR(ForestPage);
  26. }
  27. void
  28. ForestPage::OnInit()
  29. {
  30. LOG_FUNCTION(ForestPage::OnInit);
  31. Win::Edit_LimitText(
  32. Win::GetDlgItem(hwnd, IDC_DOMAIN),
  33. DNS_DOMAIN_NAME_MAX_LIMIT_DUE_TO_POLICY);
  34. State& state = State::GetInstance();
  35. if (state.UsingAnswerFile())
  36. {
  37. Win::SetDlgItemText(
  38. hwnd,
  39. IDC_DOMAIN,
  40. state.GetAnswerFileOption(AnswerFile::OPTION_NEW_DOMAIN_NAME));
  41. }
  42. }
  43. static
  44. void
  45. enable(HWND dialog)
  46. {
  47. ASSERT(Win::IsWindow(dialog));
  48. int next =
  49. !Win::GetTrimmedDlgItemText(dialog, IDC_DOMAIN).empty()
  50. ? PSWIZB_NEXT : 0;
  51. Win::PropSheet_SetWizButtons(
  52. Win::GetParent(dialog),
  53. PSWIZB_BACK | next);
  54. }
  55. bool
  56. ForestPage::OnCommand(
  57. HWND /* windowFrom */ ,
  58. unsigned controlIDFrom,
  59. unsigned code)
  60. {
  61. // LOG_FUNCTION(ForestPage::OnCommand);
  62. switch (controlIDFrom)
  63. {
  64. case IDC_DOMAIN:
  65. {
  66. if (code == EN_CHANGE)
  67. {
  68. SetChanged(controlIDFrom);
  69. enable(hwnd);
  70. }
  71. break;
  72. }
  73. default:
  74. {
  75. // do nothing
  76. break;
  77. }
  78. }
  79. return false;
  80. }
  81. bool
  82. ForestPage::OnSetActive()
  83. {
  84. LOG_FUNCTION(ForestPage::OnSetActive);
  85. ASSERT(State::GetInstance().GetOperation() == State::FOREST);
  86. Win::PropSheet_SetWizButtons(
  87. Win::GetParent(hwnd),
  88. PSWIZB_BACK);
  89. State& state = State::GetInstance();
  90. if (state.RunHiddenUnattended())
  91. {
  92. int nextPage = ForestPage::Validate();
  93. if (nextPage != -1)
  94. {
  95. GetWizard().SetNextPageID(hwnd, nextPage);
  96. }
  97. else
  98. {
  99. state.ClearHiddenWhileUnattended();
  100. }
  101. }
  102. enable(hwnd);
  103. return true;
  104. }
  105. int
  106. ForestPage::Validate()
  107. {
  108. LOG_FUNCTION(ForestPage::Validate);
  109. String domain = Win::GetTrimmedDlgItemText(hwnd, IDC_DOMAIN);
  110. if (domain.empty())
  111. {
  112. popup.Gripe(hwnd, IDC_DOMAIN, IDS_MUST_ENTER_DOMAIN);
  113. return -1;
  114. }
  115. State& state = State::GetInstance();
  116. int nextPage =
  117. state.GetRunContext() == State::PDC_UPGRADE
  118. ? IDD_FOREST_VERSION
  119. : IDD_NETBIOS_NAME;
  120. if (WasChanged(IDC_DOMAIN))
  121. {
  122. if (
  123. !ValidateDomainDnsNameSyntax(
  124. hwnd,
  125. IDC_DOMAIN,
  126. popup,
  127. // only warn on non RFC names if running interactively
  128. !state.RunHiddenUnattended())
  129. || !ConfirmNetbiosLookingNameIsReallyDnsName(hwnd, IDC_DOMAIN, popup)
  130. // do this test last, as it is expensive
  131. || !ForestValidateDomainDoesNotExist(hwnd, IDC_DOMAIN, popup))
  132. {
  133. nextPage = -1;
  134. }
  135. else
  136. {
  137. ClearChanges();
  138. }
  139. }
  140. if (nextPage != -1)
  141. {
  142. state.SetNewDomainDNSName(domain);
  143. }
  144. return nextPage;
  145. }