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.

383 lines
14 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. // ***************************************************************************
  5. //
  6. // Original Author: Rajesh Rao
  7. //
  8. // $Author: rajeshr $
  9. // $Date: 6/11/98 4:43p $
  10. // $Workfile:classpro.cpp $
  11. //
  12. // $Modtime: 6/11/98 11:21a $
  13. // $Revision: 1 $
  14. // $Nokeywords: $
  15. //
  16. //
  17. // Description: Contains the declaration for the DS Class Provider class. This is
  18. // the base class for all DS Class Providers. Note that an instance of the CDSClassProviderInitializer
  19. // class has to be created to initialize the static members of the CDSClassProvider class. Hence exactly
  20. // one instance of the CDSClassProviderInitializer class should be created for this
  21. // class to function properly.
  22. //
  23. //***************************************************************************
  24. /////////////////////////////////////////////////////////////////////////
  25. #ifndef DS_CLASS_PROVIDER_H
  26. #define DS_CLASS_PROVIDER_H
  27. // Forward declaration for the initializer class
  28. class CDSClassProviderInitializer;
  29. class CDSClassProvider : public IWbemProviderInit, public IWbemServices
  30. {
  31. // The initialization class is a friend of this class
  32. friend CDSClassProviderInitializer;
  33. public:
  34. static DWORD dwClassProviderCount;
  35. // Create the object by passing the log object
  36. CDSClassProvider () ;
  37. virtual ~CDSClassProvider () ;
  38. ////////////////////////////////////////
  39. //IUnknown members
  40. ////////////////////////////////////////
  41. STDMETHODIMP QueryInterface ( REFIID , LPVOID FAR * ) ;
  42. STDMETHODIMP_( ULONG ) AddRef () ;
  43. STDMETHODIMP_( ULONG ) Release () ;
  44. ////////////////////////////////////////
  45. //IWbemProviderInit members
  46. ////////////////////////////////////////
  47. virtual HRESULT STDMETHODCALLTYPE Initialize(
  48. LPWSTR wszUser,
  49. LONG lFlags,
  50. LPWSTR wszNamespace,
  51. LPWSTR wszLocale,
  52. IWbemServices __RPC_FAR *pNamespace,
  53. IWbemContext __RPC_FAR *pCtx,
  54. IWbemProviderInitSink __RPC_FAR *pInitSink) ;
  55. ////////////////////////////////////////
  56. //IWbemServices members
  57. ////////////////////////////////////////
  58. virtual HRESULT STDMETHODCALLTYPE OpenNamespace(
  59. /* [in] */ const BSTR strNamespace,
  60. /* [in] */ long lFlags,
  61. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  62. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  63. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult);
  64. virtual HRESULT STDMETHODCALLTYPE CancelAsyncCall(
  65. /* [in] */ IWbemObjectSink __RPC_FAR *pSink);
  66. virtual HRESULT STDMETHODCALLTYPE QueryObjectSink(
  67. /* [in] */ long lFlags,
  68. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler);
  69. virtual HRESULT STDMETHODCALLTYPE GetObject(
  70. /* [in] */ const BSTR strObjectPath,
  71. /* [in] */ long lFlags,
  72. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  73. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  74. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  75. virtual HRESULT STDMETHODCALLTYPE GetObjectAsync(
  76. /* [in] */ const BSTR strObjectPath,
  77. /* [in] */ long lFlags,
  78. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  79. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  80. virtual HRESULT STDMETHODCALLTYPE PutClass(
  81. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  82. /* [in] */ long lFlags,
  83. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  84. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  85. virtual HRESULT STDMETHODCALLTYPE PutClassAsync(
  86. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  87. /* [in] */ long lFlags,
  88. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  89. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  90. virtual HRESULT STDMETHODCALLTYPE DeleteClass(
  91. /* [in] */ const BSTR strClass,
  92. /* [in] */ long lFlags,
  93. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  94. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  95. virtual HRESULT STDMETHODCALLTYPE DeleteClassAsync(
  96. /* [in] */ const BSTR strClass,
  97. /* [in] */ long lFlags,
  98. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  99. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  100. virtual HRESULT STDMETHODCALLTYPE CreateClassEnum(
  101. /* [in] */ const BSTR strSuperclass,
  102. /* [in] */ long lFlags,
  103. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  104. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  105. virtual HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  106. /* [in] */ const BSTR strSuperclass,
  107. /* [in] */ long lFlags,
  108. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  109. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  110. virtual HRESULT STDMETHODCALLTYPE PutInstance(
  111. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  112. /* [in] */ long lFlags,
  113. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  114. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  115. virtual HRESULT STDMETHODCALLTYPE PutInstanceAsync(
  116. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  117. /* [in] */ long lFlags,
  118. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  119. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  120. virtual HRESULT STDMETHODCALLTYPE DeleteInstance(
  121. /* [in] */ const BSTR strObjectPath,
  122. /* [in] */ long lFlags,
  123. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  124. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  125. virtual HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
  126. /* [in] */ const BSTR strObjectPath,
  127. /* [in] */ long lFlags,
  128. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  129. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  130. virtual HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  131. /* [in] */ const BSTR strClass,
  132. /* [in] */ long lFlags,
  133. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  134. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  135. virtual HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
  136. /* [in] */ const BSTR strClass,
  137. /* [in] */ long lFlags,
  138. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  139. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  140. virtual HRESULT STDMETHODCALLTYPE ExecQuery(
  141. /* [in] */ const BSTR strQueryLanguage,
  142. /* [in] */ const BSTR strQuery,
  143. /* [in] */ long lFlags,
  144. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  145. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  146. virtual HRESULT STDMETHODCALLTYPE ExecQueryAsync(
  147. /* [in] */ const BSTR strQueryLanguage,
  148. /* [in] */ const BSTR strQuery,
  149. /* [in] */ long lFlags,
  150. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  151. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  152. virtual HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  153. /* [in] */ const BSTR strQueryLanguage,
  154. /* [in] */ const BSTR strQuery,
  155. /* [in] */ long lFlags,
  156. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  157. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  158. virtual HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
  159. /* [in] */ const BSTR strQueryLanguage,
  160. /* [in] */ const BSTR strQuery,
  161. /* [in] */ long lFlags,
  162. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  163. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  164. virtual HRESULT STDMETHODCALLTYPE ExecMethod(
  165. /* [in] */ const BSTR strObjectPath,
  166. /* [in] */ const BSTR strMethodName,
  167. /* [in] */ long lFlags,
  168. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  169. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  170. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppOutParams,
  171. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  172. virtual HRESULT STDMETHODCALLTYPE ExecMethodAsync(
  173. /* [in] */ const BSTR strObjectPath,
  174. /* [in] */ const BSTR strMethodName,
  175. /* [in] */ long lFlags,
  176. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  177. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  178. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  179. protected:
  180. #ifdef PROFILING
  181. // Used for profiling. Should be removed.
  182. DWORD dwStartTime;
  183. #endif
  184. ////////////////////////////////////////////////
  185. // Functions for interacting with ADSI providers
  186. ////////////////////////////////////////////////
  187. //***************************************************************************
  188. //
  189. // CDSClassProvider::GetWBEMProviderName
  190. //
  191. // Purpose : Returns the name of the provider. This should be the same as the
  192. // value of the field Name in the __Win32Provider instance used for registration
  193. // of the provider
  194. //
  195. // Parameters:
  196. // None
  197. //
  198. // Return Value: The name of the provider
  199. //***************************************************************************
  200. virtual const BSTR GetWBEMProviderName() = 0;
  201. //***************************************************************************
  202. //
  203. // CDSClassProvider::IsUnProvidedClass
  204. //
  205. // Purpose : To check whether a class is one that the provider does not provide
  206. //
  207. // Parameters:
  208. // lpszClassName : The WBEM Name of the class to be checked
  209. //
  210. //
  211. // Return Value: TRUE is this is one of the classes not provided by the provider
  212. //***************************************************************************
  213. virtual BOOLEAN IsUnProvidedClass(LPCWSTR lpszClassName) = 0;
  214. //***************************************************************************
  215. //
  216. // CDSClassProvider::GetClassFromCacheOrADSI
  217. //
  218. // Purpose : To create a WBEM class from an ADSI Class
  219. //
  220. // Parameters:
  221. // lpszClassName : The WBEM Name of the class to be retreived
  222. // pCtx : A pointer to the context object that was used in this call. This
  223. // may be used by this function to make calls to CIMOM
  224. //
  225. //
  226. // Return Value: The COM result representing the status.
  227. //***************************************************************************
  228. virtual HRESULT GetClassFromCacheOrADSI(LPCWSTR pszWBEMClassName,
  229. IWbemClassObject **ppReturnObject,
  230. IWbemContext *pCtx);
  231. //***************************************************************************
  232. //
  233. // CDSClassProvider::GetClassFromADSI
  234. //
  235. // Purpose : To create a WBEM class from an ADSI Class
  236. //
  237. // Parameters:
  238. // lpszClassName : The WBEM Name of the class to be retreived
  239. // pCtx : A pointer to the context object that was used in this call. This
  240. // may be used by this function to make calls to CIMOM
  241. // ppWbemClass : The resulting WBEM Class. This has to be released once the
  242. // user is done with it.
  243. //
  244. //
  245. // Return Value: The COM result representing the status.
  246. //***************************************************************************
  247. virtual HRESULT GetClassFromADSI(
  248. LPCWSTR lpszClassName,
  249. IWbemContext *pCtx,
  250. IWbemClassObject ** ppWbemClass
  251. ) = 0;
  252. //***************************************************************************
  253. //
  254. // CDSClassProvider::GetADSIClass
  255. //
  256. // Purpose : To Create a CADSIClass from an ADSI classSchema object
  257. // Parameters:
  258. // lpszWBEMClassName : The WBEM Name of the class to be fetched.
  259. // ppADSIClass : The address where the pointer to the CADSIClass will be stored.
  260. // It is the caller's responsibility to Release() the object when done with it
  261. //
  262. // Return Value: The COM status value indicating the status of the request.
  263. //***************************************************************************
  264. virtual HRESULT GetADSIClass(LPCWSTR lpszClassName,
  265. CADSIClass ** ppADSIClass) = 0;
  266. //***************************************************************************
  267. //
  268. // CDSClassProvider::GetADSIProperty
  269. //
  270. // Purpose : To create an CADSIProperty object from an LDAP AttributeSchema object
  271. // Parameters:
  272. // lpszPropertyName : The LDAPDisplayName of the LDAP property to be fetched.
  273. // ppADSIProperty : The address where the pointer to the IDirectoryObject interface will be stored
  274. // It is the caller's responsibility to Release() the interface when done with it
  275. //
  276. // Return Value: The COM status value indicating the status of the request
  277. //***************************************************************************
  278. virtual HRESULT GetADSIProperty(
  279. LPCWSTR lpszPropertyName,
  280. CADSIProperty **ppADSIProperty) = 0;
  281. //***************************************************************************
  282. //
  283. // CDSClassProvider::GetWBEMBaseClassName
  284. //
  285. // Purpose : Returns the name of the class that is the base class of all classes
  286. // provided by this provider.
  287. //
  288. // Parameters:
  289. // None
  290. //
  291. // Return Value: The name of the base class. NULL if such a class doesnt exist.
  292. //***************************************************************************
  293. virtual const BSTR GetWBEMBaseClassName() = 0;
  294. //***************************************************************************
  295. //
  296. // CDSClassProvider::GetWBEMBaseClass
  297. //
  298. // Purpose : Returns a pointer to the class that is the base class of all classes
  299. // provided by this provider.
  300. //
  301. // Parameters:
  302. // None
  303. //
  304. // Return Value: The IWbemClassObject pointer to the base class. It is the duty of
  305. // user to release the class when done with using it.
  306. //***************************************************************************
  307. virtual IWbemClassObject * GetWBEMBaseClass() = 0;
  308. // Returns whether the class name is present in the list of classes authorized for this user
  309. BOOLEAN IsClassAccessible();
  310. // The IWbemServices pointer stored from Initialize()
  311. IWbemServices *m_IWbemServices;
  312. // Indicates whether the call to Initialize() was successful
  313. BOOLEAN m_bInitializedSuccessfully;
  314. // Creates a log file using the m_lpszLogFileName member
  315. BOOLEAN CreateLogFile();
  316. // Some literals
  317. static BSTR CLASS_STR;
  318. // A cache of wbem classes
  319. static CWbemCache *s_pWbemCache;
  320. // A list of classes to which access has been granted for this user
  321. CNamesList m_AccessAllowedClasses;
  322. private:
  323. // The COM Reference count
  324. long m_lReferenceCount ;
  325. };
  326. #endif // DS_CLASS_PROVIDER_H