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.

469 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. EncryptedString
  39. GetPassword() const;
  40. void
  41. SetUsername(const String& name);
  42. void
  43. SetPassword(const EncryptedString& 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. String
  71. GetAnswerFileOption(const String& option) const;
  72. EncryptedString
  73. GetEncryptedAnswerFileOption(const String& option) const;
  74. String
  75. GetReplicaDomainDNSName() const;
  76. enum Operation
  77. {
  78. NONE,
  79. REPLICA,
  80. FOREST,
  81. TREE,
  82. CHILD,
  83. DEMOTE,
  84. ABORT_BDC_UPGRADE
  85. };
  86. Operation
  87. GetOperation() const;
  88. String
  89. GetParentDomainDnsName() const;
  90. void
  91. SetParentDomainDNSName(const String& name);
  92. enum OperationResult
  93. {
  94. SUCCESS,
  95. FAILURE
  96. };
  97. void
  98. SetOperationResults(OperationResult result);
  99. OperationResult
  100. GetOperationResultsCode() const;
  101. void
  102. SetOperationResultsMessage(const String& message);
  103. String
  104. GetOperationResultsMessage() const;
  105. void
  106. SetOperation(Operation oper);
  107. #define FreeIfmHandle() SetIfmHandle(0)
  108. void
  109. SetIfmHandle(DSROLE_IFM_OPERATION_HANDLE IfmHandleIn);
  110. void
  111. SetReplicaDomainDNSName(const String& dnsName);
  112. void
  113. SetSiteName(const String& site);
  114. void
  115. SetUserDomainName(const String& name);
  116. String
  117. GetUserDomainName() const;
  118. void
  119. ClearHiddenWhileUnattended();
  120. bool
  121. RunHiddenUnattended() const;
  122. bool
  123. IsLastDCInDomain() const;
  124. void
  125. SetIsLastDCInDomain(bool yesNo);
  126. void
  127. SetAdminPassword(const EncryptedString& password);
  128. EncryptedString
  129. GetAdminPassword() const;
  130. bool
  131. IsDNSOnNetwork() const;
  132. void
  133. SetDNSOnNetwork(bool yesNo);
  134. String
  135. GetInstalledSite() const;
  136. void
  137. SetInstalledSite(const String& site);
  138. void
  139. AddFinishMessage(const String& message);
  140. String
  141. GetFinishMessages() const;
  142. Computer&
  143. GetComputer();
  144. void
  145. SetFailureMessage(const String& message);
  146. String
  147. GetFailureMessage() const;
  148. bool
  149. ShouldInstallAndConfigureDns() const;
  150. String
  151. GetUserForestName() const;
  152. void
  153. SetUserForestName(const String& forest);
  154. bool
  155. IsDomainInForest(const String& domain) const;
  156. HRESULT
  157. ReadDomains();
  158. DNS_NAME_COMPARE_STATUS
  159. DomainFitsInForest(const String& domain, String& conflictingDomain);
  160. bool
  161. GetDomainReinstallFlag() const;
  162. void
  163. SetDomainReinstallFlag(bool newValue);
  164. // true to indicate that the RAS permissions script should be run.
  165. bool
  166. ShouldAllowAnonymousAccess() const;
  167. void
  168. SetShouldAllowAnonymousAccess(bool yesNo);
  169. String
  170. GetReplicationPartnerDC() const;
  171. void
  172. SetReplicationPartnerDC(const String dcName);
  173. // returns true if the machine is hosts a global catalog
  174. bool
  175. IsGlobalCatalog();
  176. EncryptedString
  177. GetSafeModeAdminPassword() const;
  178. void
  179. SetSafeModeAdminPassword(const EncryptedString& pwd);
  180. String
  181. GetAdminToolsShortcutPath() const;
  182. bool
  183. NeedsCommandLineHelp() const;
  184. bool
  185. IsAdvancedMode() const;
  186. void
  187. SetReplicateFromMedia(bool yesNo);
  188. void
  189. SetReplicationSourcePath(const String& path);
  190. bool
  191. ReplicateFromMedia() const;
  192. String
  193. GetReplicationSourcePath() const;
  194. bool
  195. IsReallyLastDcInDomain();
  196. enum SyskeyLocation
  197. {
  198. STORED, // stored w/ backup
  199. DISK, // look on disk
  200. PROMPT // prompt user
  201. };
  202. void
  203. SetSyskeyLocation(SyskeyLocation loc);
  204. SyskeyLocation
  205. GetSyskeyLocation() const;
  206. void
  207. SetIsBackupGc(bool yesNo);
  208. bool
  209. IsBackupGc() const;
  210. void
  211. SetSyskey(const EncryptedString& syskey);
  212. EncryptedString
  213. GetSyskey() const;
  214. void
  215. SetRestoreGc(bool yesNo);
  216. bool
  217. GetRestoreGc() const;
  218. bool
  219. IsSafeModeAdminPwdOptionPresent() const;
  220. bool
  221. GetDomainControllerReinstallFlag() const;
  222. void
  223. SetDomainControllerReinstallFlag(bool newValue);
  224. bool
  225. IsOperationRetryAllowed() const;
  226. ULONG
  227. GetOperationResultsFlags() const;
  228. void
  229. SetOperationResultsFlags(ULONG flags);
  230. void
  231. SetNeedsReboot();
  232. bool
  233. GetNeedsReboot() const;
  234. void
  235. SetSetForestVersionFlag(bool setVersion);
  236. bool
  237. GetSetForestVersionFlag() const;
  238. #ifdef DBG
  239. bool
  240. IsExitOnFailureMode() const;
  241. #endif
  242. bool
  243. ShouldConfigDnsClient() const;
  244. // Determines if the domain controller is the last replica of any
  245. // non-domain naming contexts (a.k.a. Application Partitions). If so,
  246. // returns true. If not, returns false. Returns false if the machine is
  247. // not a DC.
  248. //
  249. // Also saves the list of the DNs of each partition for which the machine
  250. // is the last replica, which can be retrieved with GetAppPartitionList.
  251. bool
  252. State::IsLastAppPartitionReplica();
  253. const StringList&
  254. GetAppPartitionList() const;
  255. bool
  256. IsForcedDemotion() const;
  257. private:
  258. // can only be created/destroyed by Init/Destroy
  259. State();
  260. ~State();
  261. void
  262. DetermineRunContext();
  263. void
  264. SetupAnswerFile(const String& filename, bool isDefaultAnswerfile);
  265. HRESULT
  266. GetDomainControllerInfoForMyDomain(
  267. DS_DOMAIN_CONTROLLER_INFO_2W*& info,
  268. DWORD& dcCount);
  269. typedef StringList DomainList;
  270. EncryptedString adminPassword;
  271. bool allowAnonAccess;
  272. AnswerFile* answerFile;
  273. bool autoConfigDns;
  274. Computer computer;
  275. RunContext context;
  276. String dbPath;
  277. DomainList domainsInForest;
  278. String failureMessage;
  279. String finishMessages;
  280. String installedSite;
  281. bool isAdvancedMode;
  282. bool isBackupGc;
  283. bool isDnsOnNet;
  284. // NTRAID#NTBUG9-416968-2001/06/14-sburns
  285. #ifdef DBG
  286. bool isExitOnFailureMode;
  287. #endif
  288. bool isForcedDemotion;
  289. bool isLastDc;
  290. bool isUpgrade;
  291. String logPath;
  292. bool needsCommandLineHelp;
  293. bool needsReboot;
  294. String newDomainDnsName;
  295. String newDomainFlatName;
  296. Operation operation;
  297. String operationResultsMessage;
  298. OperationResult operationResultsStatus;
  299. ULONG operationResultsFlags;
  300. String parentDomainDnsName;
  301. StringList partitionList;
  302. EncryptedString password;
  303. bool reinstallDomain;
  304. bool reinstallDomainController;
  305. String replicaDnsDomainName;
  306. DSROLE_IFM_OPERATION_HANDLE IfmHandle;
  307. bool replicateFromMedia;
  308. String replicationPartnerDc;
  309. bool restoreGc;
  310. bool runHiddenWhileUnattended;
  311. EncryptedString safeModeAdminPassword;
  312. bool setForestVersion;
  313. String shortcutPath;
  314. bool shouldConfigDnsClient;
  315. String siteName;
  316. String sourcePath;
  317. UnattendSplashDialog* splash;
  318. String sysvolPath;
  319. EncryptedString syskey;
  320. SyskeyLocation syskeyLocation;
  321. bool useCurrentCredentials;
  322. String userDomain;
  323. String userForest;
  324. String username;
  325. // not defined: no copying.
  326. State(const State&);
  327. State& operator=(const State&);
  328. };
  329. #endif // STATE_HPP_INCLUDED