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.

212 lines
6.5 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. if (( ppViewType == NULL ) || ( pViewOptions == NULL ))
  39. return E_POINTER;
  40. // append decorations RT_HTML IDR_HTML1
  41. if ( m_htmlPath[0] )
  42. {
  43. _stprintf(szPath,_T("file://%s"),m_htmlPath);
  44. }
  45. else
  46. {
  47. TCHAR szModulePath[MAX_PATH];
  48. // set the result view to an HTML page
  49. GetModuleFileName(_Module.GetModuleInstance(),szModulePath, MAX_PATH);
  50. szModulePath[MAX_PATH - 1] = _T('\0');
  51. _stprintf(szPath,_T("res://%s/rept.htm"),szModulePath);
  52. }
  53. (*ppViewType) = (LPOLESTR) CoTaskMemAlloc( (_tcslen(szPath)+1) * (sizeof OLECHAR));
  54. if (!(*ppViewType))
  55. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  56. ocscpy(*ppViewType,T2OLE(szPath));
  57. (*pViewOptions) = MMC_VIEW_OPTIONS_NOLISTVIEWS;
  58. return S_OK;
  59. }
  60. HRESULT CReportingNode::UpdateChildren(IConsole * pConsole)
  61. {
  62. HRESULT hr = S_OK;
  63. m_ChildArray.RemoveAll();
  64. // check the registry entries to see if which reports have been generated
  65. TRegKey rKey;
  66. WCHAR filename[MAX_PATH];
  67. CReportingNode * pNode = NULL;
  68. hr = rKey.Open(GET_STRING(IDS_REGKEY_REPORTS));
  69. if ( ! hr )
  70. {
  71. // check each report
  72. // Migrated users & groups
  73. hr = rKey.ValueGetStr(L"MigratedAccounts",filename,MAX_PATH);
  74. if (! hr )
  75. {
  76. if ( ! m_Reports[0] )
  77. {
  78. pNode = new CReportingNode();
  79. if (pNode == NULL)
  80. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  81. pNode->SetHtmlPath(GET_STRING(IDS_REPORT_MigratedAccounts),filename);
  82. m_Reports[0] = pNode;
  83. if ( pConsole )
  84. {
  85. hr = InsertNodeToScopepane2(pConsole,pNode,m_scopeDataItem.ID);
  86. }
  87. }
  88. else
  89. {
  90. pNode = m_Reports[0];
  91. m_Reports[0]->SetHtmlPath(GET_STRING(IDS_REPORT_MigratedAccounts),filename);
  92. }
  93. m_ChildArray.Add(pNode);
  94. }
  95. // Migrated computers
  96. hr = rKey.ValueGetStr(L"MigratedComputers",filename,MAX_PATH);
  97. if (! hr )
  98. {
  99. if ( ! m_Reports[1] )
  100. {
  101. pNode = new CReportingNode();
  102. if (pNode == NULL)
  103. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  104. pNode->SetHtmlPath(GET_STRING(IDS_REPORT_MigratedComputers),filename);
  105. m_Reports[1] = pNode;
  106. if ( pConsole )
  107. {
  108. hr = InsertNodeToScopepane2(pConsole,pNode,m_scopeDataItem.ID);
  109. }
  110. }
  111. else
  112. {
  113. pNode = m_Reports[1];
  114. m_Reports[1]->SetHtmlPath(GET_STRING(IDS_REPORT_MigratedComputers),filename);
  115. }
  116. m_ChildArray.Add(pNode);
  117. }
  118. // expired computers
  119. hr = rKey.ValueGetStr(L"ExpiredComputers",filename,MAX_PATH);
  120. if (! hr )
  121. {
  122. if ( ! m_Reports[2] )
  123. {
  124. pNode = new CReportingNode();
  125. if (pNode == NULL)
  126. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  127. pNode->SetHtmlPath(GET_STRING(IDS_REPORT_ExpiredComputers),filename);
  128. m_Reports[2] = pNode;
  129. if ( pConsole )
  130. {
  131. hr = InsertNodeToScopepane2(pConsole,pNode,m_scopeDataItem.ID);
  132. }
  133. }
  134. else
  135. {
  136. pNode = m_Reports[2];
  137. m_Reports[2]->SetHtmlPath(GET_STRING(IDS_REPORT_ExpiredComputers),filename);
  138. }
  139. m_ChildArray.Add(pNode);
  140. }
  141. // account references
  142. hr = rKey.ValueGetStr(L"AccountReferences",filename,MAX_PATH);
  143. if (! hr )
  144. {
  145. if (! m_Reports[3] )
  146. {
  147. pNode = new CReportingNode();
  148. if (pNode == NULL)
  149. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  150. pNode->SetHtmlPath(GET_STRING(IDS_REPORT_AccountReferences),filename);
  151. m_Reports[3] = pNode;
  152. if ( pConsole )
  153. {
  154. hr = InsertNodeToScopepane2(pConsole,pNode,m_scopeDataItem.ID);
  155. }
  156. }
  157. else
  158. {
  159. pNode = m_Reports[3];
  160. m_Reports[3]->SetHtmlPath(GET_STRING(IDS_REPORT_AccountReferences),filename);
  161. }
  162. m_ChildArray.Add(pNode);
  163. }
  164. // name conflicts
  165. hr = rKey.ValueGetStr(L"NameConflicts",filename,MAX_PATH);
  166. if (! hr )
  167. {
  168. if ( ! m_Reports[4] )
  169. {
  170. pNode = new CReportingNode();
  171. if (pNode == NULL)
  172. return HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
  173. pNode->SetHtmlPath(GET_STRING(IDS_REPORT_NameConflicts),filename);
  174. m_Reports[4] = pNode;
  175. if ( pConsole )
  176. {
  177. hr = InsertNodeToScopepane2(pConsole,pNode,m_scopeDataItem.ID);
  178. }
  179. }
  180. else
  181. {
  182. pNode = m_Reports[4];
  183. m_Reports[4]->SetHtmlPath(GET_STRING(IDS_REPORT_NameConflicts),filename);
  184. }
  185. m_ChildArray.Add(pNode);
  186. }
  187. }
  188. return hr;
  189. }