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.

280 lines
10 KiB

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