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.

459 lines
9.6 KiB

  1. // Copyright (C) 1997 Microsoft Corporation
  2. //
  3. // wizard state object
  4. //
  5. // 12-15-97 sburns
  6. #ifndef STATE_HPP_INCLUDED
  7. #define STATE_HPP_INCLUDED
  8. #include "AnswerFile.hpp"
  9. #include "UnattendSplashDialog.hpp"
  10. class State
  11. {
  12. public:
  13. // call from WinMain to init the global instance
  14. static
  15. void
  16. Init();
  17. // call from WinMain to delete the global instance
  18. static
  19. void
  20. Destroy();
  21. static
  22. State&
  23. GetInstance();
  24. bool
  25. AutoConfigureDNS() const;
  26. void
  27. SetAutoConfigureDNS(bool yesNo);
  28. String
  29. GetNewDomainNetbiosName() const;
  30. void
  31. SetNewDomainNetbiosName(const String& name);
  32. String
  33. GetNewDomainDNSName() const;
  34. void
  35. SetNewDomainDNSName(const String& name);
  36. String
  37. GetUsername() const;
  38. EncodedString
  39. GetPassword() const;
  40. void
  41. SetUsername(const String& name);
  42. void
  43. SetPassword(const EncodedString& password);
  44. String
  45. GetDatabasePath() const;
  46. String
  47. GetLogPath() const;
  48. String
  49. GetSYSVOLPath() const;
  50. String
  51. GetSiteName() const;
  52. void
  53. SetDatabasePath(const String& path);
  54. void
  55. SetLogPath(const String& path);
  56. void
  57. SetSYSVOLPath(const String& path);
  58. enum RunContext
  59. {
  60. NT5_DC, // already an NT5 DC
  61. NT5_STANDALONE_SERVER, // standalone to DC
  62. NT5_MEMBER_SERVER, // member server to DC
  63. BDC_UPGRADE, // NT4 BDC to NT5 DC
  64. PDC_UPGRADE // NT4 PDC to NT5 DC
  65. };
  66. RunContext
  67. GetRunContext() const;
  68. bool
  69. UsingAnswerFile() const;
  70. static const String OPTION_ADMIN_PASSWORD;
  71. static const String OPTION_AUTO_CONFIG_DNS;
  72. static const String OPTION_CHILD_NAME;
  73. static const String OPTION_CRITICAL_REPLICATION_ONLY;
  74. static const String OPTION_DATABASE_PATH;
  75. static const String OPTION_DNS_ON_NET;
  76. static const String OPTION_ALLOW_ANON_ACCESS;
  77. static const String OPTION_IS_LAST_DC;
  78. static const String OPTION_GC_CONFIRM;
  79. static const String OPTION_LOG_PATH;
  80. static const String OPTION_NEW_DOMAIN;
  81. static const String OPTION_NEW_DOMAIN_NAME;
  82. static const String OPTION_NEW_DOMAIN_NETBIOS_NAME;
  83. static const String OPTION_PARENT_DOMAIN_NAME;
  84. static const String OPTION_PASSWORD;
  85. static const String OPTION_REBOOT;
  86. static const String OPTION_REPLICA_DOMAIN_NAME;
  87. static const String OPTION_REPLICA_OR_MEMBER;
  88. static const String OPTION_REPLICA_OR_NEW_DOMAIN;
  89. static const String OPTION_REPLICATION_SOURCE;
  90. static const String OPTION_SAFE_MODE_ADMIN_PASSWORD;
  91. static const String OPTION_SET_FOREST_VERSION;
  92. static const String OPTION_SITE_NAME;
  93. static const String OPTION_SYSVOL_PATH;
  94. static const String OPTION_SYSKEY;
  95. static const String OPTION_USERNAME;
  96. static const String OPTION_USER_DOMAIN;
  97. static const String VALUE_DOMAIN;
  98. static const String VALUE_REPLICA;
  99. static const String VALUE_TREE;
  100. static const String VALUE_CHILD;
  101. static const String VALUE_YES;
  102. static const String VALUE_NO;
  103. static const String VALUE_NO_DONT_PROMPT;
  104. static const String OPTION_SOURCE_PATH;
  105. String
  106. GetAnswerFileOption(const String& option) const;
  107. EncodedString
  108. GetEncodedAnswerFileOption(const String& option) const;
  109. String
  110. GetReplicaDomainDNSName() const;
  111. enum Operation
  112. {
  113. NONE,
  114. REPLICA,
  115. FOREST,
  116. TREE,
  117. CHILD,
  118. DEMOTE,
  119. ABORT_BDC_UPGRADE
  120. };
  121. Operation
  122. GetOperation() const;
  123. String
  124. GetParentDomainDnsName() const;
  125. void
  126. SetParentDomainDNSName(const String& name);
  127. enum OperationResult
  128. {
  129. SUCCESS,
  130. FAILURE
  131. };
  132. void
  133. SetOperationResults(OperationResult result);
  134. OperationResult
  135. GetOperationResultsCode() const;
  136. void
  137. SetOperationResultsMessage(const String& message);
  138. String
  139. GetOperationResultsMessage() const;
  140. void
  141. SetOperation(Operation oper);
  142. void
  143. SetReplicaDomainDNSName(const String& dnsName);
  144. void
  145. SetSiteName(const String& site);
  146. void
  147. SetUserDomainName(const String& name);
  148. String
  149. GetUserDomainName() const;
  150. void
  151. ClearHiddenWhileUnattended();
  152. bool
  153. RunHiddenUnattended() const;
  154. bool
  155. IsLastDCInDomain() const;
  156. void
  157. SetIsLastDCInDomain(bool yesNo);
  158. void
  159. SetAdminPassword(const EncodedString& password);
  160. EncodedString
  161. GetAdminPassword() const;
  162. bool
  163. IsDNSOnNetwork() const;
  164. void
  165. SetDNSOnNetwork(bool yesNo);
  166. String
  167. GetInstalledSite() const;
  168. void
  169. SetInstalledSite(const String& site);
  170. void
  171. AddFinishMessage(const String& message);
  172. String
  173. GetFinishMessages() const;
  174. Computer&
  175. GetComputer();
  176. void
  177. SetFailureMessage(const String& message);
  178. String
  179. GetFailureMessage() const;
  180. bool
  181. ShouldInstallAndConfigureDns() const;
  182. String
  183. GetUserForestName() const;
  184. void
  185. SetUserForestName(const String& forest);
  186. bool
  187. IsDomainInForest(const String& domain) const;
  188. HRESULT
  189. ReadDomains();
  190. DNS_NAME_COMPARE_STATUS
  191. DomainFitsInForest(const String& domain, String& conflictingDomain);
  192. bool
  193. GetDomainReinstallFlag() const;
  194. void
  195. SetDomainReinstallFlag(bool newValue);
  196. // true to indicate that the RAS permissions script should be run.
  197. bool
  198. ShouldAllowAnonymousAccess() const;
  199. void
  200. SetShouldAllowAnonymousAccess(bool yesNo);
  201. String
  202. GetReplicationPartnerDC() const;
  203. void
  204. SetReplicationPartnerDC(const String dcName);
  205. // returns true if the machine is hosts a global catalog
  206. bool
  207. IsGlobalCatalog();
  208. EncodedString
  209. GetSafeModeAdminPassword() const;
  210. void
  211. SetSafeModeAdminPassword(const EncodedString& pwd);
  212. String
  213. GetAdminToolsShortcutPath() const;
  214. bool
  215. NeedsCommandLineHelp() const;
  216. bool
  217. IsAdvancedMode() const;
  218. void
  219. SetReplicateFromMedia(bool yesNo);
  220. void
  221. SetReplicationSourcePath(const String& path);
  222. bool
  223. ReplicateFromMedia() const;
  224. String
  225. GetReplicationSourcePath() const;
  226. bool
  227. IsReallyLastDcInDomain();
  228. enum SyskeyLocation
  229. {
  230. STORED, // stored w/ backup
  231. DISK, // look on disk
  232. PROMPT // prompt user
  233. };
  234. void
  235. SetSyskeyLocation(SyskeyLocation loc);
  236. SyskeyLocation
  237. GetSyskeyLocation() const;
  238. void
  239. SetIsBackupGc(bool yesNo);
  240. bool
  241. IsBackupGc() const;
  242. void
  243. SetSyskey(const EncodedString& syskey);
  244. EncodedString
  245. GetSyskey() const;
  246. void
  247. SetRestoreGc(bool yesNo);
  248. bool
  249. GetRestoreGc() const;
  250. bool
  251. IsSafeModeAdminPwdOptionPresent() const;
  252. bool
  253. GetDomainControllerReinstallFlag() const;
  254. void
  255. SetDomainControllerReinstallFlag(bool newValue);
  256. bool
  257. IsOperationRetryAllowed() const;
  258. ULONG
  259. GetOperationResultsFlags() const;
  260. void
  261. SetOperationResultsFlags(ULONG flags);
  262. void
  263. SetNeedsReboot();
  264. bool
  265. GetNeedsReboot() const;
  266. void
  267. SetSetForestVersionFlag(bool setVersion);
  268. bool
  269. GetSetForestVersionFlag() const;
  270. private:
  271. // can only be created/destroyed by Init/Destroy
  272. State();
  273. ~State();
  274. void
  275. DetermineRunContext();
  276. void
  277. SetupAnswerFile(const String& filename, bool isDefaultAnswerfile);
  278. HRESULT
  279. GetDomainControllerInfoForMyDomain(
  280. DS_DOMAIN_CONTROLLER_INFO_2W*& info,
  281. DWORD& dcCount);
  282. typedef StringList DomainList;
  283. EncodedString adminPassword;
  284. bool allowAnonAccess;
  285. AnswerFile* answerFile;
  286. bool autoConfigDns;
  287. Computer computer;
  288. RunContext context;
  289. String dbPath;
  290. DomainList domainsInForest;
  291. String failureMessage;
  292. String finishMessages;
  293. String installedSite;
  294. bool isAdvancedMode;
  295. bool isBackupGc;
  296. bool isDnsOnNet;
  297. bool isLastDc;
  298. bool isUpgrade;
  299. String logPath;
  300. bool needsCommandLineHelp;
  301. bool needsReboot;
  302. String newDomainDnsName;
  303. String newDomainFlatName;
  304. Operation operation;
  305. String operationResultsMessage;
  306. OperationResult operationResultsStatus;
  307. ULONG operationResultsFlags;
  308. String parentDomainDnsName;
  309. EncodedString password;
  310. bool reinstallDomain;
  311. bool reinstallDomainController;
  312. String replicaDnsDomainName;
  313. bool replicateFromMedia;
  314. String replicationPartnerDc;
  315. bool restoreGc;
  316. bool runHiddenWhileUnattended;
  317. EncodedString safeModeAdminPassword;
  318. bool setForestVersion;
  319. String shortcutPath;
  320. String siteName;
  321. String sourcePath;
  322. UnattendSplashDialog* splash;
  323. String sysvolPath;
  324. EncodedString syskey;
  325. SyskeyLocation syskeyLocation;
  326. bool useCurrentCredentials;
  327. String userDomain;
  328. String userForest;
  329. String username;
  330. // not defined: no copying.
  331. State(const State&);
  332. State& operator=(const State&);
  333. };
  334. #endif // STATE_HPP_INCLUDED