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.

555 lines
16 KiB

  1. /*---------------------------------------------------------------------------
  2. File: StrDesc.cpp
  3. Comments: Implementation of CMigrator member functions that build string descriptions
  4. of the operations to be performed. These are implemented in this seperate file to avoid cluttering
  5. Migrator.cpp.
  6. (c) Copyright 1999, Mission Critical Software, Inc., All Rights Reserved
  7. Proprietary and confidential to Mission Critical Software, Inc.
  8. REVISION LOG ENTRY
  9. Revision By: Christy Boles
  10. ---------------------------------------------------------------------------
  11. */// Migrator.cpp : Implementation of CMcsMigrationDriverApp and DLL registration.
  12. #include "stdafx.h"
  13. #include "MigDrvr.h"
  14. //#import "\bin\McsVarSetMin.tlb" no_namespace, named_guids
  15. #import "VarSet.tlb" no_namespace, named_guids rename("property", "aproperty")
  16. #include "Migrator.h"
  17. #include "TaskChk.h"
  18. #include "ResStr.h"
  19. #include "Common.hpp"
  20. #include "UString.hpp"
  21. void CMigrator::BuildGeneralDesc(IVarSet * pVarSet,CString & str)
  22. {
  23. CString temp;
  24. _bstr_t str1;
  25. _bstr_t str2;
  26. temp.FormatMessage(IDS_DescGeneral);
  27. str += temp;
  28. // Migrate from %ls to %ls
  29. str1 = pVarSet->get(GET_BSTR(DCTVS_Options_SourceDomain));
  30. str2 = pVarSet->get(GET_BSTR(DCTVS_Options_TargetDomain));
  31. temp.FormatMessage(IDS_DescDomains,(WCHAR*)str1,(WCHAR*)str2);
  32. //str += temp;
  33. // Logfile: %ls
  34. str1 = pVarSet->get(GET_BSTR(DCTVS_Options_Logfile));
  35. temp.FormatMessage(IDS_DescLogfile,(WCHAR*)str1);
  36. str += temp;
  37. // write changes
  38. str1 = pVarSet->get(GET_BSTR(DCTVS_Options_NoChange));
  39. if ( !UStrICmp(str1,GET_STRING(IDS_YES)) )
  40. {
  41. temp.FormatMessage(IDS_DescNoChange);
  42. }
  43. else
  44. {
  45. temp.FormatMessage(IDS_DescWriteChanges);
  46. }
  47. str += temp;
  48. }
  49. void CMigrator::BuildAcctReplDesc(IVarSet * pVarSet,CString & str)
  50. {
  51. const WCHAR DELIMITER[3] = L",\0";//used to seperate names in the prop exclusion lists
  52. CString temp;
  53. _bstr_t val;
  54. _bstr_t val2;
  55. _bstr_t val3;
  56. _bstr_t val4;
  57. LONG_PTR nVal;
  58. BOOL bCanUseSIDHistory = FALSE;
  59. CString sPropList;
  60. temp.FormatMessage(IDS_DescAccountMigration);
  61. str += temp;
  62. // count of accounts to be copied
  63. nVal = pVarSet->get(GET_BSTR(DCTVS_Accounts_NumItems));
  64. temp.FormatMessage(IDS_DescAccountCount,nVal);
  65. str += temp;
  66. temp.FormatMessage(IDS_DescCopyAccountTypes);
  67. str += temp;
  68. // copy users?
  69. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyUsers));
  70. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  71. {
  72. temp.FormatMessage(IDS_DescCopyUsers);
  73. str += temp;
  74. bCanUseSIDHistory = TRUE;
  75. }
  76. // copy groups?
  77. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyGlobalGroups));
  78. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyLocalGroups));
  79. if ( !UStrICmp(val,GET_STRING(IDS_YES)) || ! UStrICmp(val2,GET_STRING(IDS_YES)) )
  80. {
  81. temp.FormatMessage(IDS_DescCopyGroups);
  82. str += temp;
  83. bCanUseSIDHistory = TRUE;
  84. }
  85. // copy ous
  86. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyOUs));
  87. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  88. {
  89. temp.FormatMessage(IDS_DescCopyOUs);
  90. str += temp;
  91. }
  92. // copy computers
  93. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyComputers));
  94. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  95. {
  96. temp.FormatMessage(IDS_DescCopyComputers);
  97. str += temp;
  98. }
  99. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_AddSidHistory));
  100. val2 = pVarSet->get(GET_BSTR(DCTVS_Options_IsIntraforest));
  101. if ( !UStrICmp(val,GET_STRING(IDS_YES)) || !UStrICmp(val2,GET_STRING(IDS_YES)) )
  102. {
  103. temp.FormatMessage(IDS_SIDHistory_Yes);
  104. }
  105. else
  106. {
  107. temp.FormatMessage(IDS_SIDHistory_No);
  108. }
  109. // If SID-History doesn't apply (i.e. Migrating Computers), don't mention it in the summary screen
  110. if ( bCanUseSIDHistory )
  111. {
  112. str += temp;
  113. }
  114. //if rename with prefix
  115. val = pVarSet->get(GET_BSTR(DCTVS_Options_Prefix));
  116. if (val.length())
  117. {
  118. temp.FormatMessage(IDS_DescRenameWithPrefix,(WCHAR*)val);
  119. str += temp;
  120. }
  121. //if rename with suffix
  122. val = pVarSet->get(GET_BSTR(DCTVS_Options_Suffix));
  123. if (val.length())
  124. {
  125. temp.FormatMessage(IDS_DescRenameWithSuffix,(WCHAR*)val);
  126. str += temp;
  127. }
  128. // name collisions
  129. temp.FormatMessage(IDS_DescNoReplaceExisting);
  130. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ReplaceExistingAccounts));
  131. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  132. {
  133. temp.FormatMessage(IDS_DescReplaceExisting);
  134. }
  135. else
  136. {
  137. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_Prefix));
  138. if ( val.length() )
  139. {
  140. temp.FormatMessage(IDS_DescRenameWithPrefixOnConf,(WCHAR*)val);
  141. }
  142. else
  143. {
  144. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_Suffix));
  145. if ( val.length() )
  146. {
  147. temp.FormatMessage(IDS_DescRenameWithSuffixOnConf,(WCHAR*)val);
  148. }
  149. }
  150. }
  151. str += temp;
  152. // account disabling status
  153. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_DisableSourceAccounts));
  154. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_DisableCopiedAccounts));
  155. val3 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExpireSourceAccounts));
  156. val4 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_TgtStateSameAsSrc));
  157. //if disable source accounts, add to summary
  158. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  159. {
  160. temp.FormatMessage(IDS_DescDisableSrcAccts);
  161. str += temp;
  162. }
  163. //if expire source accounts, add to summary
  164. if (wcslen(val3))
  165. {
  166. nVal = _wtol(val3);
  167. temp.FormatMessage(IDS_DescExpireSrcAccts,nVal);
  168. str += temp;
  169. }
  170. //else if disable target accounts, add to summary
  171. if ( !UStrICmp(val2,GET_STRING(IDS_YES)) )
  172. {
  173. temp.FormatMessage(IDS_DescDisableTgtAccts);
  174. str += temp;
  175. }
  176. else if ( !UStrICmp(val4,GET_STRING(IDS_YES)) )
  177. {
  178. temp.FormatMessage(IDS_DescTgtSameAsSrc);
  179. str += temp;
  180. }
  181. //else if leave source and target accounts active, add to summary
  182. else
  183. {
  184. temp.FormatMessage(IDS_DescLeaveAcctsActive);
  185. str += temp;
  186. }
  187. // roaming profile translation?
  188. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_TranslateRoamingProfiles));
  189. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  190. {
  191. temp.FormatMessage(IDS_DescTranslateRoaming);
  192. str += temp;
  193. }
  194. // update user rights?
  195. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_UpdateUserRights));
  196. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  197. {
  198. temp.FormatMessage(IDS_DescUpdateUserRights);
  199. str += temp;
  200. }
  201. // password generation?
  202. //if copying password, say so
  203. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyPasswords));
  204. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  205. {
  206. temp.FormatMessage(IDS_DescCopyPassword);
  207. str += temp;
  208. }
  209. else //else checkfor complex or same as username
  210. {
  211. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_GenerateStrongPasswords));
  212. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_PasswordFile));
  213. //if complex, say so
  214. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  215. {
  216. temp.FormatMessage(IDS_DescStrongPassword, (WCHAR*)val2);
  217. str += temp;
  218. }
  219. else //else if same as username, say so
  220. {
  221. temp.FormatMessage(IDS_DescSimplePassword, (WCHAR*)val2);
  222. str += temp;
  223. }
  224. }
  225. /* add description of any excluded properties */
  226. //add user properties excluded, if any
  227. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyUsers));
  228. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludeProps));
  229. val3 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludedUserProps));
  230. if (!UStrICmp(val,GET_STRING(IDS_YES)) && !UStrICmp(val2,GET_STRING(IDS_YES))
  231. && UStrICmp(val3, L""))
  232. {
  233. temp.FormatMessage(IDS_DescExUserProps);
  234. str += temp;
  235. //diplay the list of props (currently in a comma-seperated string)
  236. sPropList = (WCHAR*)val3;
  237. if (!sPropList.IsEmpty())
  238. {
  239. WCHAR* pStr = sPropList.GetBuffer(0);
  240. WCHAR* pTemp = wcstok(pStr, DELIMITER);
  241. while (pTemp != NULL)
  242. {
  243. temp.FormatMessage(IDS_DescExcludedProp, pTemp);
  244. str += temp;
  245. //get the next item
  246. pTemp = wcstok(NULL, DELIMITER);
  247. }
  248. sPropList.ReleaseBuffer();
  249. }
  250. }
  251. //add group properties excluded, if any
  252. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyGlobalGroups));
  253. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyLocalGroups));
  254. val3 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludeProps));
  255. val4 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludedGroupProps));
  256. if ((!UStrICmp(val,GET_STRING(IDS_YES)) || !UStrICmp(val2,GET_STRING(IDS_YES)))
  257. && !UStrICmp(val3,GET_STRING(IDS_YES)) && UStrICmp(val4, L""))
  258. {
  259. temp.FormatMessage(IDS_DescExGrpProps);
  260. str += temp;
  261. //diplay the list of props (currently in a comma-seperated string)
  262. sPropList = (WCHAR*)val4;
  263. if (!sPropList.IsEmpty())
  264. {
  265. WCHAR* pStr = sPropList.GetBuffer(0);
  266. WCHAR* pTemp = wcstok(pStr, DELIMITER);
  267. while (pTemp != NULL)
  268. {
  269. temp.FormatMessage(IDS_DescExcludedProp, pTemp);
  270. str += temp;
  271. //get the next item
  272. pTemp = wcstok(NULL, DELIMITER);
  273. }
  274. sPropList.ReleaseBuffer();
  275. }
  276. }
  277. //add computer properties excluded, if any
  278. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyComputers));
  279. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludeProps));
  280. val3 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludedComputerProps));
  281. if (!UStrICmp(val,GET_STRING(IDS_YES)) && !UStrICmp(val2,GET_STRING(IDS_YES))
  282. && UStrICmp(val3, L""))
  283. {
  284. temp.FormatMessage(IDS_DescExCmpProps);
  285. str += temp;
  286. //diplay the list of props (currently in a comma-seperated string)
  287. sPropList = (WCHAR*)val3;
  288. if (!sPropList.IsEmpty())
  289. {
  290. WCHAR* pStr = sPropList.GetBuffer(0);
  291. WCHAR* pTemp = wcstok(pStr, DELIMITER);
  292. while (pTemp != NULL)
  293. {
  294. temp.FormatMessage(IDS_DescExcludedProp, pTemp);
  295. str += temp;
  296. //get the next item
  297. pTemp = wcstok(NULL, DELIMITER);
  298. }
  299. sPropList.ReleaseBuffer();
  300. }
  301. }
  302. }
  303. void CMigrator::BuildSecTransDesc(IVarSet * pVarSet,CString & str,BOOL bLocal)
  304. {
  305. CString temp;
  306. CString temp2;
  307. BOOL bHeaderShown = FALSE;
  308. if ( bLocal )
  309. {
  310. // exchange translation
  311. _bstr_t server = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateContainers));
  312. if ( server.length() )
  313. {
  314. temp.FormatMessage(IDS_DescContainerTranslation,(WCHAR*)server);
  315. str += temp;
  316. // include the translation mode
  317. _bstr_t mode = pVarSet->get(GET_BSTR(DCTVS_Security_TranslationMode));
  318. temp.FormatMessage(IDS_TranslationMode,(WCHAR*)mode);
  319. str += temp;
  320. }
  321. }
  322. else
  323. {
  324. CString head;
  325. _bstr_t val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_SecurityInputMOT));
  326. _bstr_t sInput;
  327. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  328. {
  329. sInput = pVarSet->get(GET_BSTR(DCTVS_Options_SourceDomain));
  330. CString sInputCap = (WCHAR*)sInput;
  331. sInputCap.MakeUpper();
  332. temp.FormatMessage(IDS_DescTransInputMOT, (LPCTSTR)sInputCap);
  333. str += temp;
  334. }
  335. else
  336. {
  337. sInput = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_SecurityMapFile));
  338. temp.FormatMessage(IDS_DescTransInputFile, (WCHAR*)sInput);
  339. str += temp;
  340. }
  341. head.FormatMessage(IDS_DescSecurityTranslationFor);
  342. // translate files?
  343. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateFiles));
  344. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  345. {
  346. if ( ! bHeaderShown )
  347. {
  348. str += head;
  349. bHeaderShown = TRUE;
  350. }
  351. temp.FormatMessage(IDS_DescFileTrans);
  352. str += temp;
  353. }
  354. // translate shares?
  355. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateShares));
  356. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  357. {
  358. if ( ! bHeaderShown )
  359. {
  360. str += head;
  361. bHeaderShown = TRUE;
  362. }
  363. temp.FormatMessage(IDS_DescShareTrans);
  364. str += temp;
  365. }
  366. // translate printers?
  367. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslatePrinters));
  368. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  369. {
  370. if ( ! bHeaderShown )
  371. {
  372. str += head;
  373. bHeaderShown = TRUE;
  374. }
  375. temp.FormatMessage(IDS_DescPrinterTrans);
  376. str += temp;
  377. }
  378. // Translate local group memberships
  379. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateLocalGroups));
  380. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  381. {
  382. if ( ! bHeaderShown )
  383. {
  384. str += head;
  385. bHeaderShown = TRUE;
  386. }
  387. temp.FormatMessage(IDS_DescLGTrans);
  388. str += temp;
  389. }
  390. // Translate user rights
  391. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateUserRights));
  392. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  393. {
  394. if ( ! bHeaderShown )
  395. {
  396. str += head;
  397. bHeaderShown = TRUE;
  398. }
  399. temp.FormatMessage(IDS_DescRightsTrans);
  400. str += temp;
  401. }
  402. // Translate local user profiles
  403. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateUserProfiles));
  404. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  405. {
  406. if ( ! bHeaderShown )
  407. {
  408. str += head;
  409. bHeaderShown = TRUE;
  410. }
  411. temp.FormatMessage(IDS_DescProfileTrans);
  412. str += temp;
  413. }
  414. // Translate Registry
  415. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateRegistry));
  416. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  417. {
  418. if ( ! bHeaderShown )
  419. {
  420. str += head;
  421. bHeaderShown = TRUE;
  422. }
  423. temp.FormatMessage(IDS_DescRegistryTrans);
  424. str += temp;
  425. }
  426. if ( bHeaderShown )
  427. {
  428. // include the translation mode
  429. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslationMode));
  430. temp.FormatMessage(IDS_TranslationMode,(WCHAR*)val);
  431. str += temp;
  432. }
  433. }
  434. }
  435. void CMigrator::BuildDispatchDesc(IVarSet * pVarSet,CString & str)
  436. {
  437. BuildSecTransDesc(pVarSet,str,FALSE);
  438. }
  439. void CMigrator::BuildUndoDesc(IVarSet * pVarSet,CString & str)
  440. {
  441. CString temp;
  442. _bstr_t val;
  443. _bstr_t val2;
  444. long nVal;
  445. temp.FormatMessage(IDS_DescUndo);
  446. str += temp;
  447. // count of accounts to be copied
  448. nVal = pVarSet->get(GET_BSTR(DCTVS_Accounts_NumItems));
  449. temp.FormatMessage(IDS_DescAccountCountForDelete,nVal);
  450. str += temp;
  451. }
  452. void CMigrator::BuildReportDesc(IVarSet * pVarSet, CString & str)
  453. {
  454. _bstr_t text;
  455. CString temp;
  456. text = pVarSet->get(GET_BSTR(DCTVS_Reports_Generate));
  457. if ( UStrICmp(text,GET_STRING(IDS_YES)) )
  458. {
  459. // not generating any reports
  460. return;
  461. }
  462. text = pVarSet->get(GET_BSTR(DCTVS_Reports_MigratedAccounts));
  463. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  464. {
  465. temp.FormatMessage(IDS_GenerateMigratedAccountsReport);
  466. str += temp;
  467. }
  468. text = pVarSet->get(GET_BSTR(DCTVS_Reports_MigratedComputers));
  469. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  470. {
  471. temp.FormatMessage(IDS_GenerateMigratedComputersReport);
  472. str += temp;
  473. }
  474. text = pVarSet->get(GET_BSTR(DCTVS_Reports_ExpiredComputers));
  475. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  476. {
  477. temp.FormatMessage(IDS_GenerateExpiredComputersReport);
  478. str += temp;
  479. }
  480. text = pVarSet->get(GET_BSTR(DCTVS_Reports_AccountReferences));
  481. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  482. {
  483. temp.FormatMessage(IDS_GenerateAccountReferencesReport);
  484. str += temp;
  485. }
  486. text = pVarSet->get(GET_BSTR(DCTVS_Reports_NameConflicts));
  487. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  488. {
  489. temp.FormatMessage(IDS_GenerateNameConflictReport);
  490. str += temp;
  491. }
  492. }
  493. void CMigrator::BuildGroupMappingDesc(IVarSet * pVarSet, CString & str)
  494. {
  495. long nItems;
  496. CString temp;
  497. nItems = pVarSet->get(GET_BSTR(DCTVS_Accounts_NumItems));
  498. _bstr_t tgtGroup = pVarSet->get(L"Accounts.0.TargetName");
  499. temp.FormatMessage(IDS_GroupsWillBeMapped,nItems,(WCHAR*)tgtGroup);
  500. str += temp;
  501. }