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.

205 lines
6.1 KiB

  1. #include "stdafx.h"
  2. #include "DomMigSI.h"
  3. #include "DomMigr.h"
  4. #include "MyNodes.h"
  5. #include "TReg.hpp"
  6. #include "ResStr.h"
  7. #include "Err.hpp"
  8. TError err;
  9. TError & errCommon = err;
  10. StringLoader gString;
  11. //#import "\bin\DBManager.tlb" no_namespace, named_guids
  12. #import "DBMgr.tlb" no_namespace, named_guids
  13. // {F521FE00-3FA1-11d3-8AED-00A0C9AFE114}
  14. static const GUID CReportingGUID_NODETYPE =
  15. { 0xf521fe00, 0x3fa1, 0x11d3, { 0x8a, 0xed, 0x0, 0xa0, 0xc9, 0xaf, 0xe1, 0x14 } };
  16. const GUID* CReportingNode::m_NODETYPE = &CReportingGUID_NODETYPE;
  17. const OLECHAR* CReportingNode::m_SZNODETYPE = OLESTR("F521FE00-3FA1-11d3-8AED-00A0C9AFE114");
  18. const OLECHAR* CReportingNode::m_SZDISPLAY_NAME = GET_BSTR(IDS_Reporting);
  19. const CLSID* CReportingNode::m_SNAPIN_CLASSID = &CLSID_DomMigrator;
  20. CReportingNode::CReportingNode()
  21. {
  22. // m_idHTML = IDR_REPT_HTML;
  23. m_htmlPath[0] = 0;
  24. m_bstrDisplayName = SysAllocString(GET_STRING(IDS_ReportsMMCNode));
  25. m_scopeDataItem.nImage = IMAGE_INDEX_AD;
  26. m_scopeDataItem.nOpenImage = IMAGE_INDEX_AD_OPEN;
  27. m_resultDataItem.nImage = 0;
  28. m_Reports[0] = NULL;
  29. m_Reports[1] = NULL;
  30. m_Reports[2] = NULL;
  31. m_Reports[3] = NULL;
  32. m_Reports[4] = NULL;
  33. };
  34. STDMETHODIMP CReportingNode::GetResultViewType(LPOLESTR * ppViewType, long *pViewOptions)
  35. {
  36. USES_CONVERSION;
  37. TCHAR szPath[MAX_PATH];
  38. TCHAR szModulePath[MAX_PATH];
  39. // set the result view to an HTML page
  40. GetModuleFileName(_Module.GetModuleInstance(),szModulePath, MAX_PATH);
  41. // append decorations RT_HTML IDR_HTML1
  42. if ( m_htmlPath[0] )
  43. {
  44. _stprintf(szPath,_T("file://%s"),m_htmlPath);
  45. }
  46. else
  47. {
  48. // _stprintf(szPath,_T("res://%s/%ld"),szModulePath,m_idHTML);
  49. _stprintf(szPath,_T("res://%s/rept.htm"),szModulePath);
  50. }
  51. (*ppViewType) = (LPOLESTR) CoTaskMemAlloc( (_tcslen(szPath)+1) * (sizeof OLECHAR));
  52. if (!(*ppViewType))
  53. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  54. ocscpy(*ppViewType,T2OLE(szPath));
  55. (*pViewOptions) = MMC_VIEW_OPTIONS_NOLISTVIEWS;
  56. return S_OK;
  57. }
  58. HRESULT CReportingNode::UpdateChildren(IConsole * pConsole)
  59. {
  60. HRESULT hr = S_OK;
  61. m_ChildArray.RemoveAll();
  62. // check the registry entries to see if which reports have been generated
  63. TRegKey rKey;
  64. WCHAR filename[MAX_PATH];
  65. CReportingNode * pNode = NULL;
  66. hr = rKey.Open(GET_STRING(IDS_REGKEY_REPORTS));
  67. if ( ! hr )
  68. {
  69. // check each report
  70. // Migrated users & groups
  71. hr = rKey.ValueGetStr(L"MigratedAccounts",filename,MAX_PATH);
  72. if (! hr )
  73. {
  74. if ( ! m_Reports[0] )
  75. {
  76. pNode = new CReportingNode();
  77. if (pNode)
  78. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  79. pNode->SetHtmlPath(GET_STRING(IDS_REPORT_MigratedAccounts),filename);
  80. m_Reports[0] = pNode;
  81. if ( pConsole )
  82. {
  83. hr = InsertNodeToScopepane2(pConsole,pNode,m_scopeDataItem.ID);
  84. }
  85. }
  86. else
  87. {
  88. m_Reports[0]->SetHtmlPath(GET_STRING(IDS_REPORT_MigratedAccounts),filename);
  89. }
  90. m_ChildArray.Add(pNode);
  91. }
  92. // Migrated computers
  93. hr = rKey.ValueGetStr(L"MigratedComputers",filename,MAX_PATH);
  94. if (! hr )
  95. {
  96. if ( ! m_Reports[1] )
  97. {
  98. pNode = new CReportingNode();
  99. if (pNode)
  100. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  101. pNode->SetHtmlPath(GET_STRING(IDS_REPORT_MigratedComputers),filename);
  102. m_Reports[1] = pNode;
  103. if ( pConsole )
  104. {
  105. hr = InsertNodeToScopepane2(pConsole,pNode,m_scopeDataItem.ID);
  106. }
  107. }
  108. else
  109. {
  110. m_Reports[1]->SetHtmlPath(GET_STRING(IDS_REPORT_MigratedComputers),filename);
  111. }
  112. m_ChildArray.Add(pNode);
  113. }
  114. // expired computers
  115. hr = rKey.ValueGetStr(L"ExpiredComputers",filename,MAX_PATH);
  116. if (! hr )
  117. {
  118. if ( ! m_Reports[2] )
  119. {
  120. pNode = new CReportingNode();
  121. if (pNode)
  122. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  123. pNode->SetHtmlPath(GET_STRING(IDS_REPORT_ExpiredComputers),filename);
  124. m_Reports[2] = pNode;
  125. if ( pConsole )
  126. {
  127. hr = InsertNodeToScopepane2(pConsole,pNode,m_scopeDataItem.ID);
  128. }
  129. }
  130. else
  131. {
  132. m_Reports[2]->SetHtmlPath(GET_STRING(IDS_REPORT_ExpiredComputers),filename);
  133. }
  134. m_ChildArray.Add(pNode);
  135. }
  136. // account references
  137. hr = rKey.ValueGetStr(L"AccountReferences",filename,MAX_PATH);
  138. if (! hr )
  139. {
  140. if (! m_Reports[3] )
  141. {
  142. pNode = new CReportingNode();
  143. if (pNode)
  144. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  145. pNode->SetHtmlPath(GET_STRING(IDS_REPORT_AccountReferences),filename);
  146. m_Reports[3] = pNode;
  147. if ( pConsole )
  148. {
  149. hr = InsertNodeToScopepane2(pConsole,pNode,m_scopeDataItem.ID);
  150. }
  151. }
  152. else
  153. {
  154. m_Reports[3]->SetHtmlPath(GET_STRING(IDS_REPORT_AccountReferences),filename);
  155. }
  156. m_ChildArray.Add(pNode);
  157. }
  158. // name conflicts
  159. hr = rKey.ValueGetStr(L"NameConflicts",filename,MAX_PATH);
  160. if (! hr )
  161. {
  162. if ( ! m_Reports[4] )
  163. {
  164. pNode = new CReportingNode();
  165. if (pNode)
  166. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  167. pNode->SetHtmlPath(GET_STRING(IDS_REPORT_NameConflicts),filename);
  168. m_Reports[4] = pNode;
  169. if ( pConsole )
  170. {
  171. hr = InsertNodeToScopepane2(pConsole,pNode,m_scopeDataItem.ID);
  172. }
  173. }
  174. else
  175. {
  176. m_Reports[4]->SetHtmlPath(GET_STRING(IDS_REPORT_NameConflicts),filename);
  177. }
  178. m_ChildArray.Add(pNode);
  179. }
  180. }
  181. return hr;
  182. }