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.

261 lines
9.7 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:assocprov.h $
  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 CLDAPClassAsssociationsProviderInitializer
  19. // class has to be created to initialize the static members of the CLDAPClassAsssociationsProvider class. Hence exactly
  20. // one instance of the CLDAPClassAsssociationsProviderInitializer class should be created for this
  21. // class to function properly.
  22. //
  23. //***************************************************************************
  24. /////////////////////////////////////////////////////////////////////////
  25. #ifndef DS_CLASS_ASSOC_PROVIDER_H
  26. #define DS_CLASS_ASSOC_PROVIDER_H
  27. class CLDAPClassAsssociationsProvider : public IWbemProviderInit, public IWbemServices
  28. {
  29. public:
  30. // Create the object
  31. CLDAPClassAsssociationsProvider () ;
  32. virtual ~CLDAPClassAsssociationsProvider () ;
  33. ////////////////////////////////////////
  34. //IUnknown members
  35. ////////////////////////////////////////
  36. STDMETHODIMP QueryInterface ( REFIID , LPVOID FAR * ) ;
  37. STDMETHODIMP_( ULONG ) AddRef () ;
  38. STDMETHODIMP_( ULONG ) Release () ;
  39. ////////////////////////////////////////
  40. //IWbemProviderInit members
  41. ////////////////////////////////////////
  42. virtual HRESULT STDMETHODCALLTYPE Initialize(
  43. LPWSTR wszUser,
  44. LONG lFlags,
  45. LPWSTR wszNamespace,
  46. LPWSTR wszLocale,
  47. IWbemServices __RPC_FAR *pNamespace,
  48. IWbemContext __RPC_FAR *pCtx,
  49. IWbemProviderInitSink __RPC_FAR *pInitSink) ;
  50. ////////////////////////////////////////
  51. //IWbemServices members
  52. ////////////////////////////////////////
  53. virtual HRESULT STDMETHODCALLTYPE OpenNamespace(
  54. /* [in] */ const BSTR strNamespace,
  55. /* [in] */ long lFlags,
  56. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  57. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  58. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult);
  59. virtual HRESULT STDMETHODCALLTYPE CancelAsyncCall(
  60. /* [in] */ IWbemObjectSink __RPC_FAR *pSink);
  61. virtual HRESULT STDMETHODCALLTYPE QueryObjectSink(
  62. /* [in] */ long lFlags,
  63. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler);
  64. virtual HRESULT STDMETHODCALLTYPE GetObject(
  65. /* [in] */ const BSTR strObjectPath,
  66. /* [in] */ long lFlags,
  67. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  68. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  69. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  70. virtual HRESULT STDMETHODCALLTYPE GetObjectAsync(
  71. /* [in] */ const BSTR strObjectPath,
  72. /* [in] */ long lFlags,
  73. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  74. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  75. virtual HRESULT STDMETHODCALLTYPE PutClass(
  76. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  77. /* [in] */ long lFlags,
  78. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  79. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  80. virtual HRESULT STDMETHODCALLTYPE PutClassAsync(
  81. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  82. /* [in] */ long lFlags,
  83. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  84. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  85. virtual HRESULT STDMETHODCALLTYPE DeleteClass(
  86. /* [in] */ const BSTR strClass,
  87. /* [in] */ long lFlags,
  88. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  89. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  90. virtual HRESULT STDMETHODCALLTYPE DeleteClassAsync(
  91. /* [in] */ const BSTR strClass,
  92. /* [in] */ long lFlags,
  93. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  94. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  95. virtual HRESULT STDMETHODCALLTYPE CreateClassEnum(
  96. /* [in] */ const BSTR strSuperclass,
  97. /* [in] */ long lFlags,
  98. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  99. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  100. virtual HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  101. /* [in] */ const BSTR strSuperclass,
  102. /* [in] */ long lFlags,
  103. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  104. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  105. virtual HRESULT STDMETHODCALLTYPE PutInstance(
  106. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  107. /* [in] */ long lFlags,
  108. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  109. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  110. virtual HRESULT STDMETHODCALLTYPE PutInstanceAsync(
  111. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  112. /* [in] */ long lFlags,
  113. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  114. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  115. virtual HRESULT STDMETHODCALLTYPE DeleteInstance(
  116. /* [in] */ const BSTR strObjectPath,
  117. /* [in] */ long lFlags,
  118. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  119. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  120. virtual HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
  121. /* [in] */ const BSTR strObjectPath,
  122. /* [in] */ long lFlags,
  123. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  124. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  125. virtual HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  126. /* [in] */ const BSTR strClass,
  127. /* [in] */ long lFlags,
  128. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  129. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  130. virtual HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
  131. /* [in] */ const BSTR strClass,
  132. /* [in] */ long lFlags,
  133. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  134. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  135. virtual HRESULT STDMETHODCALLTYPE ExecQuery(
  136. /* [in] */ const BSTR strQueryLanguage,
  137. /* [in] */ const BSTR strQuery,
  138. /* [in] */ long lFlags,
  139. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  140. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  141. virtual HRESULT STDMETHODCALLTYPE ExecQueryAsync(
  142. /* [in] */ const BSTR strQueryLanguage,
  143. /* [in] */ const BSTR strQuery,
  144. /* [in] */ long lFlags,
  145. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  146. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  147. virtual HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  148. /* [in] */ const BSTR strQueryLanguage,
  149. /* [in] */ const BSTR strQuery,
  150. /* [in] */ long lFlags,
  151. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  152. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  153. virtual HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
  154. /* [in] */ const BSTR strQueryLanguage,
  155. /* [in] */ const BSTR strQuery,
  156. /* [in] */ long lFlags,
  157. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  158. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  159. virtual HRESULT STDMETHODCALLTYPE ExecMethod(
  160. /* [in] */ const BSTR strObjectPath,
  161. /* [in] */ const BSTR strMethodName,
  162. /* [in] */ long lFlags,
  163. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  164. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  165. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppOutParams,
  166. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  167. virtual HRESULT STDMETHODCALLTYPE ExecMethodAsync(
  168. /* [in] */ const BSTR strObjectPath,
  169. /* [in] */ const BSTR strMethodName,
  170. /* [in] */ long lFlags,
  171. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  172. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  173. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  174. protected:
  175. // Checks whether a containment is valid
  176. HRESULT IsContainedIn(LPCWSTR lpszChildClass, LPCWSTR lpszParentClass);
  177. // A helper function to do the ADSI LDAP provider specific initialization.
  178. BOOLEAN InitializeAssociationsProvider(IWbemContext *pCtx);
  179. // The IWbemServices pointer stored from Initialize()
  180. IWbemServices *m_IWbemServices;
  181. // Creates an instance of the association class
  182. HRESULT CreateInstance(BSTR strChildName, BSTR strParentName, IWbemClassObject **ppInstance);
  183. // Does enumeration of instnaces of the association class
  184. HRESULT DoEnumeration(IWbemObjectSink *pResponseHandler);
  185. private:
  186. // The Log File name
  187. static LPCWSTR s_LogFileName;
  188. // Indicates whether the call to Initialize() was successful
  189. BOOLEAN m_bInitializedSuccessfully;
  190. // The COM Reference count
  191. long m_lReferenceCount ;
  192. // The class for which instances are provider
  193. IWbemClassObject *m_pAssociationClass;
  194. // The path to the schema container
  195. LPWSTR m_lpszSchemaContainerSuffix;
  196. // The IDirectorySearch interface of the schema container
  197. IDirectorySearch *m_pDirectorySearchSchemaContainer;
  198. // Some literals
  199. static LPCWSTR CHILD_CLASS_PROPERTY;
  200. static LPCWSTR PARENT_CLASS_PROPERTY;
  201. static LPCWSTR POSSIBLE_SUPERIORS;
  202. BSTR CHILD_CLASS_PROPERTY_STR;
  203. BSTR PARENT_CLASS_PROPERTY_STR;
  204. BSTR CLASS_ASSOCIATION_CLASS_STR;
  205. BSTR POSSIBLE_SUPERIORS_STR;
  206. static LPCWSTR SCHEMA_NAMING_CONTEXT;
  207. static LPCWSTR LDAP_SCHEMA;
  208. static LPCWSTR LDAP_SCHEMA_SLASH;
  209. };
  210. #endif // DS_CLASS_ASSOC_PROVIDER_H