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.

335 lines
10 KiB

  1. /*Copyright (c) 1995-1999, Mission Critical Software, Inc. All rights reserved.
  2. ===============================================================================
  3. Module - TaskCheck.cpp
  4. System - Domain Consolidation Toolkit.
  5. Author - Christy Boles
  6. Created - 99/07/01
  7. Description - Routines that examine a the job defined by a varset and determine
  8. whether specific migration tasks need to be performed.
  9. Updates -
  10. ===============================================================================
  11. */
  12. //#include "stdafx.h"
  13. #include <windows.h>
  14. #include <stdio.h>
  15. //#include <process.h>
  16. //#import "\bin\McsVarSetMin.tlb" no_namespace
  17. #import "VarSet.tlb" no_namespace rename("property", "aproperty")
  18. #include "Common.hpp"
  19. #include "TaskChk.h"
  20. #include "ResStr.h"
  21. #include "UString.hpp"
  22. #include "ErrDct.hpp"
  23. extern TErrorDct errTrace;
  24. BOOL // ret- BOOL, whether account replicator should be called
  25. NeedToUseAR(
  26. IVarSet * pVarSet // in - varset containing migration settings
  27. )
  28. {
  29. _bstr_t text;
  30. BOOL bResult = FALSE;
  31. text = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyUsers));
  32. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  33. {
  34. errTrace.DbgMsgWrite(0,L"Need to use AR: Copying users");
  35. bResult = TRUE;
  36. }
  37. text = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyGlobalGroups));
  38. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  39. {
  40. errTrace.DbgMsgWrite(0,L"Need to use AR: Copying groups");
  41. bResult = TRUE;
  42. }
  43. text = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyComputers));
  44. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  45. {
  46. errTrace.DbgMsgWrite(0,L"Need to use AR: Copying computers");
  47. bResult = TRUE;
  48. }
  49. text = pVarSet->get(GET_BSTR(DCTVS_Options_LocalProcessingOnly));
  50. // account replication is only done locally on the machine where Domain Migrator is running
  51. // it cannot be dispatched to run on a different machine.
  52. // (you can't very well copy accounts from one domain to another while running as localsystem)
  53. if ( ! UStrICmp(text,GET_STRING(IDS_YES)) )
  54. {
  55. errTrace.DbgMsgWrite(0,L"Never use AR when running remotely.");
  56. bResult = FALSE;
  57. }
  58. // Account replicator should not be run when gathering information
  59. _bstr_t wizard = pVarSet->get(L"Options.Wizard");
  60. if ( !_wcsicmp((WCHAR*) wizard, L"reporting") )
  61. {
  62. errTrace.DbgMsgWrite(0,L"Never use AR when Gathering Information.");
  63. bResult = FALSE;
  64. }
  65. if ( !_wcsicmp((WCHAR*) wizard, L"sidremove") )
  66. {
  67. errTrace.DbgMsgWrite(0,L"Need to use AR. We are removing sids.");
  68. bResult = TRUE;
  69. }
  70. text = pVarSet->get(GET_BSTR(DCTVS_Accounts_NumItems));
  71. if ( text.length() == 0 )
  72. {
  73. // no accounts were specified
  74. bResult = FALSE;
  75. }
  76. return ( bResult );
  77. }
  78. BOOL // ret- BOOL, whether security translator should be called
  79. NeedToUseST(
  80. IVarSet * pVarSet, // in - varset containing migration settings
  81. BOOL bForceRemoteCheck // in - forces checking to be done based on the remote operations, not local ones
  82. )
  83. {
  84. BOOL bResult = FALSE;
  85. BOOL bLocalAgent;
  86. _bstr_t text = pVarSet->get(GET_BSTR(DCTVS_Options_LocalProcessingOnly));
  87. if (!text)
  88. return FALSE;
  89. bLocalAgent = ( UStrICmp(text,GET_STRING(IDS_YES)) == 0 );
  90. if ( bLocalAgent || bForceRemoteCheck )
  91. {
  92. // the agent dispatched to remote machines does translation for
  93. // files
  94. text = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateFiles));
  95. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  96. {
  97. errTrace.DbgMsgWrite(0,L"Need to use ST: Files");
  98. bResult = TRUE;
  99. }
  100. // and Shares
  101. text = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateShares));
  102. if (! UStrICmp(text,GET_STRING(IDS_YES)) )
  103. {
  104. errTrace.DbgMsgWrite(0,L"Need to use ST: Shares");
  105. bResult = TRUE;
  106. }
  107. // and User Rights
  108. text = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateUserRights));
  109. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  110. {
  111. errTrace.DbgMsgWrite(0,L"Need to use ST: Rights");
  112. bResult = TRUE;
  113. }
  114. // and Local Groups
  115. text = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateLocalGroups));
  116. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  117. {
  118. errTrace.DbgMsgWrite(0,L"Need to use ST: LGroups");
  119. bResult = TRUE;
  120. }
  121. // and Printers
  122. text = pVarSet->get(GET_BSTR(DCTVS_Security_TranslatePrinters));
  123. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  124. {
  125. errTrace.DbgMsgWrite(0,L"Need to use ST: Printers");
  126. bResult = TRUE;
  127. }
  128. // and User Profiles
  129. text = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateUserProfiles));
  130. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  131. {
  132. errTrace.DbgMsgWrite(0,L"Need to use ST: Local User Profiles");
  133. bResult = TRUE;
  134. }
  135. text = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateRegistry));
  136. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  137. {
  138. errTrace.DbgMsgWrite(0,L"Need to use ST: Registry");
  139. bResult = TRUE;
  140. }
  141. // when dispatching, the settings are per-job, not per-server
  142. // it is possible to choose whether to migrate, translate, or both,
  143. // for each computer in the server list.
  144. // this setting indicates that the translation will not be run on this computer
  145. // even though other computers are being translated during this same job
  146. text = pVarSet->get(GET_BSTR(DCTVS_LocalServer_MigrateOnly));
  147. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  148. {
  149. errTrace.DbgMsgWrite(0,L"Need to use ST: but not on this computer");
  150. bResult = FALSE;
  151. }
  152. }
  153. else
  154. {
  155. // The local engine does exchange translation for
  156. // mailboxes
  157. text = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateMailboxes));
  158. if ( text.length() )
  159. {
  160. errTrace.DbgMsgWrite(0,L"Need to use ST: Mailboxes");
  161. bResult = TRUE;
  162. }
  163. // and containers
  164. text = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateContainers));
  165. if ( text.length() )
  166. {
  167. errTrace.DbgMsgWrite(0,L"Need to use ST: Containers");
  168. bResult = TRUE;
  169. }
  170. // The local engine is also used to build an account mapping file to
  171. // send out with the dispatched agents for security translation
  172. text = pVarSet->get(GET_BSTR(DCTVS_Security_BuildCacheFile));
  173. if ( text.length() )
  174. {
  175. errTrace.DbgMsgWrite(0,L"Need to use ST: BuildCacheFile");
  176. bResult = TRUE;
  177. }
  178. }
  179. return bResult;
  180. }
  181. BOOL // ret- whether agents need to be dispatched to remote machines
  182. NeedToDispatch(
  183. IVarSet * pVarSet // in - varset describing migration job
  184. )
  185. {
  186. BOOL bNeedToDispatch = FALSE;
  187. _bstr_t text;
  188. long count;
  189. _bstr_t wizard = pVarSet->get(L"Options.Wizard");
  190. if (!wizard)
  191. return FALSE;
  192. if (! UStrICmp(wizard,L"user") )
  193. {
  194. bNeedToDispatch = FALSE;
  195. }
  196. else if (! UStrICmp(wizard,L"group") )
  197. {
  198. bNeedToDispatch = FALSE;
  199. }
  200. else if ( !UStrICmp(wizard,L"computer") )
  201. {
  202. bNeedToDispatch = TRUE;
  203. }
  204. else if ( ! UStrICmp(wizard,L"security" ) )
  205. {
  206. bNeedToDispatch = TRUE;
  207. }
  208. else if ( ! UStrICmp(wizard,L"service" ) )
  209. {
  210. bNeedToDispatch = TRUE;
  211. }
  212. else if ( ! UStrICmp(wizard,L"retry") )
  213. {
  214. bNeedToDispatch = TRUE;
  215. }
  216. // the dispatcher is used to migrate computers, and to translate security
  217. count = pVarSet->get(GET_BSTR(DCTVS_Servers_NumItems));
  218. if ( count > 0 )
  219. {
  220. bNeedToDispatch = TRUE;
  221. }
  222. return bNeedToDispatch;
  223. }
  224. BOOL
  225. NeedToRunReports(
  226. IVarSet * pVarSet // in - varset describing migration job
  227. )
  228. {
  229. BOOL bNeedToReport = FALSE;
  230. _bstr_t text = pVarSet->get(GET_BSTR(DCTVS_Reports_Generate));
  231. if (!text)
  232. return FALSE;
  233. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  234. {
  235. bNeedToReport = TRUE;
  236. }
  237. return bNeedToReport;
  238. }
  239. BOOL // ret- whether the local engine needs to be called to perform domain specific tasks
  240. NeedToRunLocalAgent(
  241. IVarSet * pVarSet // in - varset describing migration job
  242. )
  243. {
  244. BOOL bNeedToRunLocal = FALSE;
  245. _bstr_t text;
  246. _bstr_t wizard = pVarSet->get(L"Options.Wizard");
  247. if (!wizard)
  248. return FALSE;
  249. // if the wizard type is specified, use it to determine what to do
  250. if ( ! UStrICmp(wizard,L"user") )
  251. {
  252. bNeedToRunLocal = TRUE;
  253. }
  254. else if (! UStrICmp(wizard,L"group") )
  255. {
  256. bNeedToRunLocal = TRUE;
  257. }
  258. else if ( !UStrICmp(wizard,L"computer") )
  259. {
  260. bNeedToRunLocal = TRUE;
  261. }
  262. else if ( !UStrICmp(wizard,L"security") )
  263. {
  264. bNeedToRunLocal = FALSE;
  265. }
  266. else if ( !UStrICmp(wizard,L"undo") )
  267. {
  268. bNeedToRunLocal = TRUE;
  269. }
  270. else if ( ! UStrICmp(wizard,L"service") )
  271. {
  272. bNeedToRunLocal = FALSE;
  273. }
  274. else if ( !UStrICmp(wizard, "exchange") )
  275. {
  276. bNeedToRunLocal = TRUE;
  277. }
  278. else if (! UStrICmp(wizard,L"retry") )
  279. {
  280. bNeedToRunLocal = FALSE;
  281. }
  282. else if ( ! UStrICmp(wizard,L"reporting") )
  283. {
  284. text = pVarSet->get(GET_BSTR(DCTVS_GatherInformation_ComputerPasswordAge));
  285. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  286. {
  287. bNeedToRunLocal = TRUE;
  288. }
  289. }
  290. else
  291. {
  292. // wizard type is not specified, try to determine what needs to be done from the varset entries
  293. // The local agent is used for account replication and exchange translation
  294. if ( NeedToUseAR(pVarSet) )
  295. bNeedToRunLocal = TRUE;
  296. if ( NeedToUseST(pVarSet) )
  297. bNeedToRunLocal = TRUE;
  298. }
  299. return bNeedToRunLocal;
  300. }