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.

290 lines
8.4 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation
  4. //
  5. // sobjpath.h
  6. //
  7. // alanbos 27-Mar-00 Created.
  8. //
  9. // CSWbemObjectPath definition
  10. //
  11. //***************************************************************************
  12. #ifndef _SOBJPATH_H_
  13. #define _SOBJPATH_H_
  14. //***************************************************************************
  15. //
  16. // CLASS NAME:
  17. //
  18. // CSWbemObjectPath
  19. //
  20. // DESCRIPTION:
  21. //
  22. // Implements the ISWbemObjectPath interface.
  23. //
  24. //***************************************************************************
  25. class CSWbemObjectPath : public ISWbemObjectPath,
  26. public IObjectSafety,
  27. public ISupportErrorInfo,
  28. public IProvideClassInfo
  29. {
  30. friend CSWbemServices;
  31. private:
  32. class CObjectPathDispatchHelp : public CDispatchHelp
  33. {
  34. public:
  35. bool HandleNulls (
  36. DISPID dispidMember,
  37. unsigned short wFlags)
  38. {
  39. return false;
  40. }
  41. };
  42. CObjectPathDispatchHelp m_Dispatch;
  43. class CWbemObjectPathSecurity : public ISWbemSecurity,
  44. public ISupportErrorInfo,
  45. public IProvideClassInfo
  46. {
  47. private:
  48. CDispatchHelp m_Dispatch;
  49. protected:
  50. long m_cRef;
  51. public:
  52. CWbemObjectPathSecurity (CSWbemSecurity *pSecurity);
  53. CWbemObjectPathSecurity (ISWbemSecurity *pObjectPathSecurity);
  54. virtual ~CWbemObjectPathSecurity (void);
  55. //Non-delegating object IUnknown
  56. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  57. STDMETHODIMP_(ULONG) AddRef(void);
  58. STDMETHODIMP_(ULONG) Release(void);
  59. // IDispatch
  60. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
  61. {return m_Dispatch.GetTypeInfoCount(pctinfo);}
  62. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  63. {return m_Dispatch.GetTypeInfo(itinfo, lcid, pptinfo);}
  64. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  65. UINT cNames, LCID lcid, DISPID* rgdispid)
  66. {return m_Dispatch.GetIDsOfNames(riid, rgszNames, cNames,
  67. lcid,
  68. rgdispid);}
  69. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  70. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  71. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  72. {return m_Dispatch.Invoke(dispidMember, riid, lcid, wFlags,
  73. pdispparams, pvarResult, pexcepinfo, puArgErr);}
  74. // ISWbemSecurity methods
  75. HRESULT STDMETHODCALLTYPE get_ImpersonationLevel
  76. (
  77. /* [out] */ WbemImpersonationLevelEnum *iImpersonationLevel
  78. );
  79. HRESULT STDMETHODCALLTYPE put_ImpersonationLevel
  80. (
  81. /* [in] */ WbemImpersonationLevelEnum iImpersonationLevel
  82. );
  83. HRESULT STDMETHODCALLTYPE get_AuthenticationLevel
  84. (
  85. /* [out] */ WbemAuthenticationLevelEnum *iAuthenticationLevel
  86. );
  87. HRESULT STDMETHODCALLTYPE put_AuthenticationLevel
  88. (
  89. /* [in] */ WbemAuthenticationLevelEnum iAuthenticationLevel
  90. );
  91. HRESULT STDMETHODCALLTYPE get_Privileges
  92. (
  93. /* [out] */ ISWbemPrivilegeSet **objWbemPrivileges
  94. );
  95. // ISupportErrorInfo methods
  96. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  97. (
  98. /* [in] */ REFIID riid
  99. );
  100. // IProvideClassInfo methods
  101. HRESULT STDMETHODCALLTYPE GetClassInfo
  102. (
  103. /* [in,out] */ ITypeInfo **ppTI
  104. )
  105. {
  106. return m_Dispatch.GetClassInfo (ppTI);
  107. };
  108. bool m_authnSpecified;
  109. bool m_impSpecified;
  110. enum WbemAuthenticationLevelEnum m_authnLevel;
  111. enum WbemImpersonationLevelEnum m_impLevel;
  112. CSWbemPrivilegeSet *m_pPrivilegeSet;
  113. };
  114. CWbemObjectPathSecurity *m_pSecurity;
  115. BSTR m_bsLocale;
  116. BSTR m_bsAuthority;
  117. protected:
  118. long m_cRef; //Object reference count
  119. CWbemPathCracker *m_pPathCracker;
  120. protected:
  121. public:
  122. CSWbemObjectPath(CSWbemSecurity *pSecurity = NULL, BSTR bsLocale = NULL);
  123. CSWbemObjectPath(CSWbemObjectPath & wbemObjectPath);
  124. CSWbemObjectPath(ISWbemObjectPath *pISWbemObjectPath);
  125. ~CSWbemObjectPath(void);
  126. //Non-delegating object IUnknown
  127. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  128. STDMETHODIMP_(ULONG) AddRef(void);
  129. STDMETHODIMP_(ULONG) Release(void);
  130. // IDispatch
  131. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
  132. {return m_Dispatch.GetTypeInfoCount(pctinfo);}
  133. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  134. {return m_Dispatch.GetTypeInfo(itinfo, lcid, pptinfo);}
  135. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  136. UINT cNames, LCID lcid, DISPID* rgdispid)
  137. {return m_Dispatch.GetIDsOfNames(riid, rgszNames, cNames,
  138. lcid,
  139. rgdispid);}
  140. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  141. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  142. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  143. {return m_Dispatch.Invoke(dispidMember, riid, lcid, wFlags,
  144. pdispparams, pvarResult, pexcepinfo, puArgErr);}
  145. // ISWbemObjectPath methods
  146. HRESULT STDMETHODCALLTYPE get_Path(
  147. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  148. HRESULT STDMETHODCALLTYPE put_Path(
  149. /* [in] */ BSTR __RPC_FAR value) ;
  150. HRESULT STDMETHODCALLTYPE get_RelPath(
  151. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  152. HRESULT STDMETHODCALLTYPE put_RelPath(
  153. /* [in] */ BSTR __RPC_FAR value) ;
  154. HRESULT STDMETHODCALLTYPE get_DisplayName(
  155. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  156. HRESULT STDMETHODCALLTYPE put_DisplayName(
  157. /* [in] */ BSTR __RPC_FAR value) ;
  158. HRESULT STDMETHODCALLTYPE get_Namespace(
  159. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  160. HRESULT STDMETHODCALLTYPE put_Namespace(
  161. /* [in] */ BSTR __RPC_FAR value) ;
  162. HRESULT STDMETHODCALLTYPE get_ParentNamespace(
  163. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  164. HRESULT STDMETHODCALLTYPE get_Server(
  165. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  166. HRESULT STDMETHODCALLTYPE put_Server(
  167. /* [in] */ BSTR __RPC_FAR value) ;
  168. HRESULT STDMETHODCALLTYPE get_IsClass(
  169. /* [retval][out] */ VARIANT_BOOL __RPC_FAR *value) ;
  170. HRESULT STDMETHODCALLTYPE SetAsClass() ;
  171. HRESULT STDMETHODCALLTYPE get_IsSingleton(
  172. /* [retval][out] */ VARIANT_BOOL __RPC_FAR *value) ;
  173. HRESULT STDMETHODCALLTYPE SetAsSingleton() ;
  174. HRESULT STDMETHODCALLTYPE get_Class(
  175. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  176. HRESULT STDMETHODCALLTYPE put_Class(
  177. /* [in] */ BSTR __RPC_FAR value) ;
  178. HRESULT STDMETHODCALLTYPE get_Keys(
  179. /* [retval][out] */ ISWbemNamedValueSet **objKeys) ;
  180. HRESULT STDMETHODCALLTYPE get_Security_(
  181. /* [retval][out] */ ISWbemSecurity **objSecurity) ;
  182. HRESULT STDMETHODCALLTYPE get_Locale(
  183. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  184. HRESULT STDMETHODCALLTYPE put_Locale(
  185. /* [in] */ BSTR __RPC_FAR value) ;
  186. HRESULT STDMETHODCALLTYPE get_Authority(
  187. /* [retval][out] */ BSTR __RPC_FAR *value) ;
  188. HRESULT STDMETHODCALLTYPE put_Authority(
  189. /* [in] */ BSTR __RPC_FAR value) ;
  190. // IObjectSafety methods
  191. HRESULT STDMETHODCALLTYPE SetInterfaceSafetyOptions
  192. (
  193. /* [in] */ REFIID riid,
  194. /* [in] */ DWORD dwOptionSetMask,
  195. /* [in] */ DWORD dwEnabledOptions
  196. )
  197. {
  198. return (dwOptionSetMask & dwEnabledOptions) ? E_FAIL : S_OK;
  199. }
  200. HRESULT STDMETHODCALLTYPE GetInterfaceSafetyOptions(
  201. /* [in] */ REFIID riid,
  202. /* [out] */ DWORD __RPC_FAR *pdwSupportedOptions,
  203. /* [out] */ DWORD __RPC_FAR *pdwEnabledOptions
  204. )
  205. {
  206. if (pdwSupportedOptions) *pdwSupportedOptions = 0;
  207. if (pdwEnabledOptions) *pdwEnabledOptions = 0;
  208. return S_OK;
  209. }
  210. // ISupportErrorInfo methods
  211. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  212. (
  213. /* [in] */ REFIID riid
  214. );
  215. // IProvideClassInfo methods
  216. HRESULT STDMETHODCALLTYPE GetClassInfo
  217. (
  218. /* [in,out] */ ITypeInfo **ppTI
  219. )
  220. {
  221. return m_Dispatch.GetClassInfo (ppTI);
  222. };
  223. // Methods of CSWbemObjectPath
  224. static bool GetObjectPath (IWbemClassObject *pIWbemClassObject, CComBSTR & bsPath);
  225. static bool GetParentPath (IWbemClassObject *pIWbemClassObject, CComBSTR & bsPath);
  226. static bool CompareObjectPaths (IWbemClassObject *pIWbemClassObject, CWbemPathCracker & objectPath);
  227. };
  228. #endif