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.

85 lines
2.1 KiB

  1. // PolicyTemplateManager.cpp : Implementation of CPolicyTemplateManager
  2. #include "stdafx.h"
  3. #include <wbemidl.h>
  4. #include "resource.h"
  5. #include "defines.h"
  6. #include "ntdmutils.h"
  7. #include "SchemaManager.h"
  8. #include "PolicyTemplateManager.h"
  9. #include "PolicyTemplateMgrDlg.h"
  10. extern CPolicyTemplateManagerDlg *g_pPolicyTemplateManagerDlg;
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CPolicyTemplateManager
  13. CPolicyTemplateManager::CPolicyTemplateManager()
  14. {
  15. m_hWnd = NULL;
  16. }
  17. //---------------------------------------------------------------------------
  18. CPolicyTemplateManager::~CPolicyTemplateManager()
  19. {
  20. }
  21. //---------------------------------------------------------------------------
  22. STDMETHODIMP CPolicyTemplateManager::ConnectToWMI()
  23. {
  24. HRESULT hr;
  25. CComPtr<IWbemLocator>pIWbemLocator;
  26. NTDM_BEGIN_METHOD()
  27. m_pIWbemServices = NULL;
  28. // create the webm locator
  29. NTDM_ERR_MSG_IF_FAIL(CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,
  30. IID_IWbemLocator, (LPVOID *) &pIWbemLocator));
  31. NTDM_ERR_MSG_IF_FAIL(pIWbemLocator->ConnectServer( _T("root\\policy"),
  32. NULL,
  33. NULL,
  34. NULL,
  35. 0,
  36. NULL,
  37. NULL,
  38. &m_pIWbemServices));
  39. NTDM_ERR_MSG_IF_FAIL(CoSetProxyBlanket(m_pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
  40. RPC_C_AUTHN_LEVEL_CONNECT, RPC_C_IMP_LEVEL_IMPERSONATE ,
  41. NULL, EOAC_NONE));
  42. NTDM_END_METHOD()
  43. // cleanup
  44. return hr;
  45. }
  46. //---------------------------------------------------------------------------
  47. STDMETHODIMP CPolicyTemplateManager::RunManager(HWND hwndParent)
  48. {
  49. HRESULT hr;
  50. NTDM_BEGIN_METHOD()
  51. m_hWnd = hwndParent;
  52. NTDM_ERR_IF_FAIL(ConnectToWMI());
  53. g_pPolicyTemplateManagerDlg = new CPolicyTemplateManagerDlg(this);
  54. DialogBox(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDD_POLICY_TEMPLATE_MANAGER), (HWND)hwndParent, PolicyTemplateManagerDlgProc);
  55. NTDM_END_METHOD()
  56. // cleanup
  57. NTDM_DELETE_OBJECT(g_pPolicyTemplateManagerDlg);
  58. return hr;
  59. }