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.

587 lines
18 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. // only applicable if migrating users
  203. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyUsers));
  204. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  205. {
  206. //if copying password, say so
  207. //passwords are always copied during intra-forest migrations
  208. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyPasswords));
  209. val2 = pVarSet->get(GET_BSTR(DCTVS_Options_IsIntraforest));
  210. if ( !UStrICmp(val,GET_STRING(IDS_YES)) || !UStrICmp(val2,GET_STRING(IDS_YES)) )
  211. {
  212. temp.FormatMessage(IDS_DescCopyPassword);
  213. str += temp;
  214. }
  215. else //else checkfor complex or same as username
  216. {
  217. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_GenerateStrongPasswords));
  218. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_PasswordFile));
  219. //if complex, say so
  220. if ( !UStrICmp(val,GET_STRING(IDS_YES)) )
  221. {
  222. temp.FormatMessage(IDS_DescStrongPassword, (WCHAR*)val2);
  223. str += temp;
  224. }
  225. else //else if same as username, say so
  226. {
  227. temp.FormatMessage(IDS_DescSimplePassword, (WCHAR*)val2);
  228. str += temp;
  229. }
  230. }
  231. }
  232. /* add description of any excluded properties */
  233. //add user properties excluded, if any
  234. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyUsers));
  235. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludeProps));
  236. val3 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludedUserProps));
  237. if (!UStrICmp(val,GET_STRING(IDS_YES)) && !UStrICmp(val2,GET_STRING(IDS_YES))
  238. && UStrICmp(val3, L""))
  239. {
  240. temp.FormatMessage(IDS_DescExUserProps);
  241. str += temp;
  242. //diplay the list of props (currently in a comma-seperated string)
  243. sPropList = (WCHAR*)val3;
  244. if (!sPropList.IsEmpty())
  245. {
  246. WCHAR* pStr = sPropList.GetBuffer(0);
  247. WCHAR* pTemp = wcstok(pStr, DELIMITER);
  248. while (pTemp != NULL)
  249. {
  250. temp.FormatMessage(IDS_DescExcludedProp, pTemp);
  251. str += temp;
  252. //get the next item
  253. pTemp = wcstok(NULL, DELIMITER);
  254. }
  255. sPropList.ReleaseBuffer();
  256. }
  257. }
  258. //add InetOrgPerson properties excluded, if any
  259. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyUsers));
  260. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludeProps));
  261. val3 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludedInetOrgPersonProps));
  262. if (!UStrICmp(val,GET_STRING(IDS_YES)) && !UStrICmp(val2,GET_STRING(IDS_YES))
  263. && UStrICmp(val3, L""))
  264. {
  265. temp.FormatMessage(IDS_DescExInetOrgPersonProps);
  266. str += temp;
  267. //diplay the list of props (currently in a comma-seperated string)
  268. sPropList = (WCHAR*)val3;
  269. if (!sPropList.IsEmpty())
  270. {
  271. WCHAR* pStr = sPropList.GetBuffer(0);
  272. WCHAR* pTemp = wcstok(pStr, DELIMITER);
  273. while (pTemp != NULL)
  274. {
  275. temp.FormatMessage(IDS_DescExcludedProp, pTemp);
  276. str += temp;
  277. //get the next item
  278. pTemp = wcstok(NULL, DELIMITER);
  279. }
  280. sPropList.ReleaseBuffer();
  281. }
  282. }
  283. //add group properties excluded, if any
  284. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyGlobalGroups));
  285. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyLocalGroups));
  286. val3 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludeProps));
  287. val4 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludedGroupProps));
  288. if ((!UStrICmp(val,GET_STRING(IDS_YES)) || !UStrICmp(val2,GET_STRING(IDS_YES)))
  289. && !UStrICmp(val3,GET_STRING(IDS_YES)) && UStrICmp(val4, L""))
  290. {
  291. temp.FormatMessage(IDS_DescExGrpProps);
  292. str += temp;
  293. //diplay the list of props (currently in a comma-seperated string)
  294. sPropList = (WCHAR*)val4;
  295. if (!sPropList.IsEmpty())
  296. {
  297. WCHAR* pStr = sPropList.GetBuffer(0);
  298. WCHAR* pTemp = wcstok(pStr, DELIMITER);
  299. while (pTemp != NULL)
  300. {
  301. temp.FormatMessage(IDS_DescExcludedProp, pTemp);
  302. str += temp;
  303. //get the next item
  304. pTemp = wcstok(NULL, DELIMITER);
  305. }
  306. sPropList.ReleaseBuffer();
  307. }
  308. }
  309. //add computer properties excluded, if any
  310. val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_CopyComputers));
  311. val2 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludeProps));
  312. val3 = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_ExcludedComputerProps));
  313. if (!UStrICmp(val,GET_STRING(IDS_YES)) && !UStrICmp(val2,GET_STRING(IDS_YES))
  314. && UStrICmp(val3, L""))
  315. {
  316. temp.FormatMessage(IDS_DescExCmpProps);
  317. str += temp;
  318. //diplay the list of props (currently in a comma-seperated string)
  319. sPropList = (WCHAR*)val3;
  320. if (!sPropList.IsEmpty())
  321. {
  322. WCHAR* pStr = sPropList.GetBuffer(0);
  323. WCHAR* pTemp = wcstok(pStr, DELIMITER);
  324. while (pTemp != NULL)
  325. {
  326. temp.FormatMessage(IDS_DescExcludedProp, pTemp);
  327. str += temp;
  328. //get the next item
  329. pTemp = wcstok(NULL, DELIMITER);
  330. }
  331. sPropList.ReleaseBuffer();
  332. }
  333. }
  334. }
  335. void CMigrator::BuildSecTransDesc(IVarSet * pVarSet,CString & str,BOOL bLocal)
  336. {
  337. CString temp;
  338. CString temp2;
  339. BOOL bHeaderShown = FALSE;
  340. if ( bLocal )
  341. {
  342. // exchange translation
  343. _bstr_t server = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateContainers));
  344. if ( server.length() )
  345. {
  346. temp.FormatMessage(IDS_DescContainerTranslation,(WCHAR*)server);
  347. str += temp;
  348. // include the translation mode
  349. _bstr_t mode = pVarSet->get(GET_BSTR(DCTVS_Security_TranslationMode));
  350. temp.FormatMessage(IDS_TranslationMode,(WCHAR*)mode);
  351. str += temp;
  352. }
  353. }
  354. else
  355. {
  356. CString head;
  357. _bstr_t val = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_SecurityInputMOT));
  358. _bstr_t sInput;
  359. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  360. {
  361. sInput = pVarSet->get(GET_BSTR(DCTVS_Options_SourceDomain));
  362. temp.FormatMessage(IDS_DescTransInputMOT, (LPCTSTR)sInput);
  363. str += temp;
  364. }
  365. else
  366. {
  367. sInput = pVarSet->get(GET_BSTR(DCTVS_AccountOptions_SecurityMapFile));
  368. temp.FormatMessage(IDS_DescTransInputFile, (WCHAR*)sInput);
  369. str += temp;
  370. }
  371. head.FormatMessage(IDS_DescSecurityTranslationFor);
  372. // translate files?
  373. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateFiles));
  374. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  375. {
  376. if ( ! bHeaderShown )
  377. {
  378. str += head;
  379. bHeaderShown = TRUE;
  380. }
  381. temp.FormatMessage(IDS_DescFileTrans);
  382. str += temp;
  383. }
  384. // translate shares?
  385. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateShares));
  386. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  387. {
  388. if ( ! bHeaderShown )
  389. {
  390. str += head;
  391. bHeaderShown = TRUE;
  392. }
  393. temp.FormatMessage(IDS_DescShareTrans);
  394. str += temp;
  395. }
  396. // translate printers?
  397. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslatePrinters));
  398. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  399. {
  400. if ( ! bHeaderShown )
  401. {
  402. str += head;
  403. bHeaderShown = TRUE;
  404. }
  405. temp.FormatMessage(IDS_DescPrinterTrans);
  406. str += temp;
  407. }
  408. // Translate local group memberships
  409. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateLocalGroups));
  410. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  411. {
  412. if ( ! bHeaderShown )
  413. {
  414. str += head;
  415. bHeaderShown = TRUE;
  416. }
  417. temp.FormatMessage(IDS_DescLGTrans);
  418. str += temp;
  419. }
  420. // Translate user rights
  421. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateUserRights));
  422. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  423. {
  424. if ( ! bHeaderShown )
  425. {
  426. str += head;
  427. bHeaderShown = TRUE;
  428. }
  429. temp.FormatMessage(IDS_DescRightsTrans);
  430. str += temp;
  431. }
  432. // Translate local user profiles
  433. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateUserProfiles));
  434. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  435. {
  436. if ( ! bHeaderShown )
  437. {
  438. str += head;
  439. bHeaderShown = TRUE;
  440. }
  441. temp.FormatMessage(IDS_DescProfileTrans);
  442. str += temp;
  443. }
  444. // Translate Registry
  445. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslateRegistry));
  446. if ( !UStrICmp(val,GET_STRING(IDS_YES)))
  447. {
  448. if ( ! bHeaderShown )
  449. {
  450. str += head;
  451. bHeaderShown = TRUE;
  452. }
  453. temp.FormatMessage(IDS_DescRegistryTrans);
  454. str += temp;
  455. }
  456. if ( bHeaderShown )
  457. {
  458. // include the translation mode
  459. val = pVarSet->get(GET_BSTR(DCTVS_Security_TranslationMode));
  460. temp.FormatMessage(IDS_TranslationMode,(WCHAR*)val);
  461. str += temp;
  462. }
  463. }
  464. }
  465. void CMigrator::BuildDispatchDesc(IVarSet * pVarSet,CString & str)
  466. {
  467. BuildSecTransDesc(pVarSet,str,FALSE);
  468. }
  469. void CMigrator::BuildUndoDesc(IVarSet * pVarSet,CString & str)
  470. {
  471. CString temp;
  472. _bstr_t val;
  473. _bstr_t val2;
  474. long nVal;
  475. temp.FormatMessage(IDS_DescUndo);
  476. str += temp;
  477. // count of accounts to be copied
  478. nVal = pVarSet->get(GET_BSTR(DCTVS_Accounts_NumItems));
  479. temp.FormatMessage(IDS_DescAccountCountForDelete,nVal);
  480. str += temp;
  481. }
  482. void CMigrator::BuildReportDesc(IVarSet * pVarSet, CString & str)
  483. {
  484. _bstr_t text;
  485. CString temp;
  486. text = pVarSet->get(GET_BSTR(DCTVS_Reports_Generate));
  487. if ( UStrICmp(text,GET_STRING(IDS_YES)) )
  488. {
  489. // not generating any reports
  490. return;
  491. }
  492. text = pVarSet->get(GET_BSTR(DCTVS_Reports_MigratedAccounts));
  493. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  494. {
  495. temp.FormatMessage(IDS_GenerateMigratedAccountsReport);
  496. str += temp;
  497. }
  498. text = pVarSet->get(GET_BSTR(DCTVS_Reports_MigratedComputers));
  499. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  500. {
  501. temp.FormatMessage(IDS_GenerateMigratedComputersReport);
  502. str += temp;
  503. }
  504. text = pVarSet->get(GET_BSTR(DCTVS_Reports_ExpiredComputers));
  505. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  506. {
  507. temp.FormatMessage(IDS_GenerateExpiredComputersReport);
  508. str += temp;
  509. }
  510. text = pVarSet->get(GET_BSTR(DCTVS_Reports_AccountReferences));
  511. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  512. {
  513. temp.FormatMessage(IDS_GenerateAccountReferencesReport);
  514. str += temp;
  515. }
  516. text = pVarSet->get(GET_BSTR(DCTVS_Reports_NameConflicts));
  517. if ( !UStrICmp(text,GET_STRING(IDS_YES)) )
  518. {
  519. temp.FormatMessage(IDS_GenerateNameConflictReport);
  520. str += temp;
  521. }
  522. }
  523. void CMigrator::BuildGroupMappingDesc(IVarSet * pVarSet, CString & str)
  524. {
  525. long nItems;
  526. CString temp;
  527. nItems = pVarSet->get(GET_BSTR(DCTVS_Accounts_NumItems));
  528. _bstr_t tgtGroup = pVarSet->get(L"Accounts.0.TargetName");
  529. temp.FormatMessage(IDS_GroupsWillBeMapped,nItems,(WCHAR*)tgtGroup);
  530. str += temp;
  531. }