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.

262 lines
9.7 KiB

  1. #ifndef __WBEM_POLICY_SOM__H_
  2. #define __WBEM_POLICY_SOM__H_
  3. class CPolicySOM : public CUnk
  4. {
  5. public:
  6. enum
  7. {
  8. AD_LOCAL_CONTEXT = 0,
  9. AD_GLOBAL_CONTEXT,
  10. AD_MAX_CONTEXT
  11. };
  12. CPolicySOM(CLifeControl* pControl = NULL, IUnknown* pOuter = NULL)
  13. : CUnk(pControl, pOuter), m_XProvider(this), m_XInit(this),
  14. m_pWMIMgmt(NULL)
  15. {
  16. m_pADMgmt[AD_LOCAL_CONTEXT] = NULL;
  17. m_pADMgmt[AD_GLOBAL_CONTEXT] = NULL;
  18. }
  19. ~CPolicySOM();
  20. void* GetInterface(REFIID riid);
  21. IWbemServices* GetWMIServices();
  22. IADsContainer* GetADServices(wchar_t *pADDomain, HRESULT &hres);
  23. bool SetWMIServices(IWbemServices* pServices);
  24. bool SetADServices(IADsContainer* ,unsigned);
  25. protected:
  26. class XProvider : public CImpl<IWbemServices, CPolicySOM>
  27. {
  28. public:
  29. /* construction & de- */
  30. XProvider(CPolicySOM* pObj)
  31. : CImpl<IWbemServices, CPolicySOM>(pObj), m_pSOMClassObject(NULL), m_pLocator(NULL)
  32. { /* this page intentionally left blank */ }
  33. ~XProvider();
  34. /* Internals */
  35. protected:
  36. /* Method support */
  37. HRESULT Evaluate(IWbemClassObject* pObj, IWbemClassObject* pOutInstance);
  38. HRESULT BatchEvaluate(IWbemClassObject* pObj, IWbemClassObject* pOutClass, IWbemServices* pPolicyNamespace);
  39. HRESULT EvaluateRule(IWbemServices*& pNamespace, BSTR& namespaceName, IWbemClassObject* pRule, bool& bResult);
  40. /* class object management */
  41. IWbemClassObject* GetSomClass();
  42. IWbemClassObject* GetSomInstance();
  43. /* communication w/ winmgmt management */
  44. HRESULT GetLocator(IWbemLocator*& pLocator);
  45. HRESULT GetNewNamespace(BSTR namespaceName, IWbemServices*& pNamespace);
  46. HRESULT ValidateRules(IWbemClassObject* pInst, IWbemClassObject*& pErrorObject);
  47. private:
  48. // templates for each type of object we support
  49. // NULL until we need it
  50. IWbemClassObject* m_pSOMClassObject;
  51. // NULL until we need it -
  52. // access through GetLocator;
  53. IWbemLocator* m_pLocator;
  54. /* IWbemServices */
  55. public:
  56. HRESULT STDMETHODCALLTYPE OpenNamespace(
  57. /* [in] */ const BSTR Namespace,
  58. /* [in] */ long lFlags,
  59. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  60. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  61. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult)
  62. {return WBEM_E_NOT_SUPPORTED;};
  63. HRESULT STDMETHODCALLTYPE CancelAsyncCall(
  64. /* [in] */ IWbemObjectSink __RPC_FAR *pSink)
  65. {return WBEM_E_NOT_SUPPORTED;};
  66. HRESULT STDMETHODCALLTYPE QueryObjectSink(
  67. /* [in] */ long lFlags,
  68. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler)
  69. {return WBEM_E_NOT_SUPPORTED;};
  70. HRESULT STDMETHODCALLTYPE GetObject(
  71. /* [in] */ const BSTR ObjectPath,
  72. /* [in] */ long lFlags,
  73. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  74. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  75. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  76. {return WBEM_E_NOT_SUPPORTED;};
  77. HRESULT STDMETHODCALLTYPE GetObjectAsync(
  78. /* [in] */ const BSTR ObjectPath,
  79. /* [in] */ long lFlags,
  80. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  81. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  82. HRESULT STDMETHODCALLTYPE PutClass(
  83. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  84. /* [in] */ long lFlags,
  85. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  86. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  87. {return WBEM_E_NOT_SUPPORTED;};
  88. HRESULT STDMETHODCALLTYPE PutClassAsync(
  89. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  90. /* [in] */ long lFlags,
  91. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  92. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  93. {return WBEM_E_NOT_SUPPORTED;};
  94. HRESULT STDMETHODCALLTYPE DeleteClass(
  95. /* [in] */ const BSTR Class,
  96. /* [in] */ long lFlags,
  97. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  98. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  99. {return WBEM_E_NOT_SUPPORTED;};
  100. HRESULT STDMETHODCALLTYPE DeleteClassAsync(
  101. /* [in] */ const BSTR Class,
  102. /* [in] */ long lFlags,
  103. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  104. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  105. {return WBEM_E_NOT_SUPPORTED;};
  106. HRESULT STDMETHODCALLTYPE CreateClassEnum(
  107. /* [in] */ const BSTR Superclass,
  108. /* [in] */ long lFlags,
  109. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  110. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  111. {return WBEM_E_NOT_SUPPORTED;};
  112. HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  113. /* [in] */ const BSTR Superclass,
  114. /* [in] */ long lFlags,
  115. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  116. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  117. {return WBEM_E_NOT_SUPPORTED;};
  118. HRESULT STDMETHODCALLTYPE PutInstance(
  119. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  120. /* [in] */ long lFlags,
  121. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  122. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  123. {return WBEM_E_NOT_SUPPORTED;};
  124. HRESULT STDMETHODCALLTYPE PutInstanceAsync(
  125. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  126. /* [in] */ long lFlags,
  127. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  128. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  129. HRESULT STDMETHODCALLTYPE DeleteInstance(
  130. /* [in] */ const BSTR ObjectPath,
  131. /* [in] */ long lFlags,
  132. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  133. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  134. {return WBEM_E_NOT_SUPPORTED;};
  135. HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
  136. /* [in] */ const BSTR ObjectPath,
  137. /* [in] */ long lFlags,
  138. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  139. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  140. HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  141. /* [in] */ const BSTR Class,
  142. /* [in] */ long lFlags,
  143. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  144. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  145. {return WBEM_E_NOT_SUPPORTED;};
  146. HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
  147. /* [in] */ const BSTR Class,
  148. /* [in] */ long lFlags,
  149. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  150. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  151. HRESULT STDMETHODCALLTYPE ExecQuery(
  152. /* [in] */ const BSTR QueryLanguage,
  153. /* [in] */ const BSTR Query,
  154. /* [in] */ long lFlags,
  155. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  156. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  157. {return WBEM_E_NOT_SUPPORTED;};
  158. HRESULT STDMETHODCALLTYPE ExecQueryAsync(
  159. /* [in] */ const BSTR QueryLanguage,
  160. /* [in] */ const BSTR Query,
  161. /* [in] */ long lFlags,
  162. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  163. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  164. HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  165. /* [in] */ const BSTR QueryLanguage,
  166. /* [in] */ const BSTR Query,
  167. /* [in] */ long lFlags,
  168. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  169. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  170. {return WBEM_E_NOT_SUPPORTED;};
  171. HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
  172. /* [in] */ const BSTR QueryLanguage,
  173. /* [in] */ const BSTR Query,
  174. /* [in] */ long lFlags,
  175. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  176. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  177. {return WBEM_E_NOT_SUPPORTED;};
  178. HRESULT STDMETHODCALLTYPE ExecMethod( const BSTR, const BSTR, long, IWbemContext*,
  179. IWbemClassObject*, IWbemClassObject**, IWbemCallResult**)
  180. {return WBEM_E_NOT_SUPPORTED;}
  181. HRESULT STDMETHODCALLTYPE ExecMethodAsync(
  182. /* [in] */ const BSTR strObjectPath,
  183. /* [in] */ const BSTR strMethodName,
  184. /* [in] */ long lFlags,
  185. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  186. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  187. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  188. } m_XProvider;
  189. friend XProvider;
  190. class XInit : public CImpl<IWbemProviderInit, CPolicySOM>
  191. {
  192. public:
  193. XInit(CPolicySOM* pObj)
  194. : CImpl<IWbemProviderInit, CPolicySOM>(pObj){}
  195. HRESULT STDMETHODCALLTYPE Initialize(
  196. LPWSTR, LONG, LPWSTR, LPWSTR, IWbemServices*, IWbemContext*,
  197. IWbemProviderInitSink*);
  198. } m_XInit;
  199. friend XInit;
  200. private:
  201. // pointer back to win management
  202. IWbemServices* m_pWMIMgmt;
  203. // pointer to AD policy template table
  204. IADsContainer* m_pADMgmt[AD_MAX_CONTEXT];
  205. CComVariant
  206. m_vDsConfigContext,
  207. m_vDsLocalContext;
  208. // a little something to keep our threads from getting tangled
  209. // will use a single critical section to protect all instance variables
  210. CCritSec m_CS;
  211. };
  212. #endif // __WBEM_POLICY_SOM__H_