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.

208 lines
6.2 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation
  2. //
  3. // File: ExpressInstallationUnit.cpp
  4. //
  5. // Synopsis: Defines a ExpressInstallationUnit
  6. // This object has the knowledge for installing the
  7. // services for the express path. AD, DNS, and DHCP
  8. //
  9. // History: 02/08/2001 JeffJon Created
  10. #include "pch.h"
  11. #include "resource.h"
  12. #include "ExpressInstallationUnit.h"
  13. #include "InstallationUnitProvider.h"
  14. #define CYS_TAPI_CONFIG_COMMAND_FORMAT L"tapicfg.exe Install /Directory:%1 /ForceDefault"
  15. // Finish page help
  16. static PCWSTR CYS_EXPRESS_FINISH_PAGE_HELP = L"cys.chm::/cys_configuring_first_server.htm";
  17. ExpressInstallationUnit::ExpressInstallationUnit() :
  18. InstallationUnit(
  19. IDS_EXPRESS_PATH_TYPE,
  20. IDS_EXPRESS_PATH_DESCRIPTION,
  21. CYS_EXPRESS_FINISH_PAGE_HELP,
  22. EXPRESS_INSTALL)
  23. {
  24. LOG_CTOR(ExpressInstallationUnit);
  25. }
  26. ExpressInstallationUnit::~ExpressInstallationUnit()
  27. {
  28. LOG_DTOR(ExpressInstallationUnit);
  29. }
  30. InstallationReturnType
  31. ExpressInstallationUnit::InstallService(HANDLE logfileHandle, HWND hwnd)
  32. {
  33. LOG_FUNCTION(ExpressInstallationUnit::InstallService);
  34. InstallationReturnType result = INSTALL_SUCCESS;
  35. do
  36. {
  37. // Warn the user of a reboot during installation
  38. if (IDOK == Win::MessageBox(
  39. hwnd,
  40. String::load(IDS_CONFIRM_REBOOT),
  41. String::load(IDS_WIZARD_TITLE),
  42. MB_OKCANCEL))
  43. {
  44. // Call the DNS installation unit to set the static IP address and subnet mask
  45. result = InstallationUnitProvider::GetInstance().GetDNSInstallationUnit().InstallService(logfileHandle, hwnd);
  46. if (result != INSTALL_SUCCESS)
  47. {
  48. LOG(L"Failed to install static IP address and subnet mask");
  49. break;
  50. }
  51. // Install DHCP
  52. result = InstallationUnitProvider::GetInstance().GetDHCPInstallationUnit().InstallService(logfileHandle, hwnd);
  53. if (result != INSTALL_SUCCESS)
  54. {
  55. LOG(L"Failed to install DCHP");
  56. break;
  57. }
  58. result = InstallationUnitProvider::GetInstance().GetADInstallationUnit().InstallService(logfileHandle, hwnd);
  59. }
  60. else
  61. {
  62. result = INSTALL_FAILURE;
  63. }
  64. } while (false);
  65. LOG_INSTALL_RETURN(result);
  66. return result;
  67. }
  68. bool
  69. ExpressInstallationUnit::IsServiceInstalled()
  70. {
  71. LOG_FUNCTION(ExpressInstallationUnit:IsServiceInstalled);
  72. bool result = false;
  73. if (InstallationUnitProvider::GetInstance().GetDHCPInstallationUnit().IsServiceInstalled() ||
  74. InstallationUnitProvider::GetInstance().GetDNSInstallationUnit().IsServiceInstalled() ||
  75. InstallationUnitProvider::GetInstance().GetADInstallationUnit().IsServiceInstalled())
  76. {
  77. result = true;
  78. }
  79. LOG_BOOL(result);
  80. return result;
  81. }
  82. bool
  83. ExpressInstallationUnit::GetFinishText(String& message)
  84. {
  85. LOG_FUNCTION(ExpressInstallationUnit::GetFinishText);
  86. // ADInstallationUnit& adInstallationUnit =
  87. // InstallationUnitProvider::GetInstance().GetADInstallationUnit();
  88. DNSInstallationUnit& dnsInstallationUnit =
  89. InstallationUnitProvider::GetInstance().GetDNSInstallationUnit();
  90. DHCPInstallationUnit& dhcpInstallationUnit =
  91. InstallationUnitProvider::GetInstance().GetDHCPInstallationUnit();
  92. // Add the standard install message
  93. message = String::load(IDS_EXPRESS_FINISH_TEXT);
  94. // Add the create domain message
  95. message += String::format(
  96. String::load(IDS_EXPRESS_FINISH_DOMAIN_NAME),
  97. InstallationUnitProvider::GetInstance().GetADInstallationUnit().GetNewDomainDNSName().c_str());
  98. // Get the static IP address so that it is easy to format
  99. DWORD staticIP = dnsInstallationUnit.GetStaticIPAddress();
  100. // Add the static IP message
  101. message += String::format(
  102. String::load(IDS_EXPRESS_FINISH_STATIC_IP),
  103. FIRST_IPADDRESS(staticIP),
  104. SECOND_IPADDRESS(staticIP),
  105. THIRD_IPADDRESS(staticIP),
  106. FOURTH_IPADDRESS(staticIP));
  107. // Get the DHCP starting and ending scope IP addresses so that it is easy to format
  108. DWORD startIP = dhcpInstallationUnit.GetStartIPAddress();
  109. DWORD endIP = dhcpInstallationUnit.GetEndIPAddress();
  110. // Add the DHCP scope message
  111. message += String::format(
  112. String::load(IDS_EXPRESS_FINISH_DHCP_SCOPE),
  113. FIRST_IPADDRESS(startIP),
  114. SECOND_IPADDRESS(startIP),
  115. THIRD_IPADDRESS(startIP),
  116. FOURTH_IPADDRESS(startIP),
  117. FIRST_IPADDRESS(endIP),
  118. SECOND_IPADDRESS(endIP),
  119. THIRD_IPADDRESS(endIP),
  120. FOURTH_IPADDRESS(endIP));
  121. // Add the TAPI message
  122. message += String::load(IDS_EXPRESS_FINISH_TAPI);
  123. LOG_BOOL(true);
  124. return true;
  125. }
  126. HRESULT
  127. ExpressInstallationUnit::DoTapiConfig(const String& dnsName)
  128. {
  129. LOG_FUNCTION2(
  130. ExpressInstallationUnit::DoTapiConfig,
  131. dnsName);
  132. // Comments below taken from old HTA CYS
  133. /*
  134. // The TAPICFG is a straight command line utility where all the required parameters can be at once supplied
  135. // in the command line arguments and there are no sub-menus to traverse. The /Directory switch takes the DNS
  136. // name of the NC to be created and the optional /Server switch takes the name of the domain controller on
  137. // which the NC is to be created. If the /server switch is not specified, then the command assumes it is
  138. // running on a DC and tries to create the NC locally.
  139. // NDNC (non-domain naming context) is a partition that is created on Active Directory and serves as a dynamic
  140. // directory, where its used for temporary storage (depending on TTL) of objects pre-defined in the AD schema.
  141. // Here in TAPI we use NDNC to store user and conference information dynamically on the server.
  142. */
  143. HRESULT hr = S_OK;
  144. String commandLine = String::format(CYS_TAPI_CONFIG_COMMAND_FORMAT, dnsName.c_str());
  145. DWORD exitCode = 0;
  146. hr = CreateAndWaitForProcess(commandLine, exitCode);
  147. if (SUCCEEDED(hr) &&
  148. exitCode != 0)
  149. {
  150. LOG(String::format(L"Exit code = %1!x!", exitCode));
  151. hr = E_FAIL;
  152. }
  153. LOG(String::format(L"hr = %1!x!", hr));
  154. return hr;
  155. }