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.

188 lines
5.0 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation
  4. //
  5. // locator.h
  6. //
  7. // alanbos 27-Mar-00 Created.
  8. //
  9. // CSWbemLocator definition.
  10. //
  11. //***************************************************************************
  12. #ifndef _LOCATOR_H_
  13. #define _LOCATOR_H_
  14. //***************************************************************************
  15. //
  16. // CLASS NAME:
  17. //
  18. // CSWbemLocator
  19. //
  20. // DESCRIPTION:
  21. //
  22. // Implements the IWbemSLocator interface. This class is what the client gets
  23. // when it initially hooks up to the Wbemprox.dll. The ConnectServer function
  24. // is what get the communication between client and server started.
  25. //
  26. //***************************************************************************
  27. class CSWbemLocator : public ISWbemLocator,
  28. public IDispatchEx,
  29. public IObjectSafety,
  30. public ISupportErrorInfo,
  31. public IProvideClassInfo
  32. {
  33. private:
  34. CWbemLocatorSecurity *m_SecurityInfo;
  35. CComPtr<IWbemLocator> m_pIWbemLocator;
  36. CDispatchHelp m_Dispatch;
  37. IServiceProvider *m_pIServiceProvider;
  38. IUnsecuredApartment *m_pUnsecuredApartment;
  39. static wchar_t *s_pDefaultNamespace;
  40. static BSTR BuildPath (BSTR Server, BSTR Namespace);
  41. static const wchar_t *GetDefaultNamespace ();
  42. protected:
  43. long m_cRef; //Object reference count
  44. public:
  45. CSWbemLocator(CSWbemPrivilegeSet *pPrivilegeSet = NULL);
  46. CSWbemLocator(CSWbemLocator &csWbemLocator);
  47. ~CSWbemLocator(void);
  48. //Non-delegating object IUnknown
  49. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  50. STDMETHODIMP_(ULONG) AddRef(void);
  51. STDMETHODIMP_(ULONG) Release(void);
  52. // IDispatch methods should be inline
  53. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
  54. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo);
  55. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  56. UINT cNames, LCID lcid, DISPID* rgdispid);
  57. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  58. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  59. EXCEPINFO* pexcepinfo, UINT* puArgErr);
  60. // IDispatchEx methods should be inline
  61. HRESULT STDMETHODCALLTYPE GetDispID(
  62. /* [in] */ BSTR bstrName,
  63. /* [in] */ DWORD grfdex,
  64. /* [out] */ DISPID __RPC_FAR *pid);
  65. /* [local] */ HRESULT STDMETHODCALLTYPE InvokeEx(
  66. /* [in] */ DISPID id,
  67. /* [in] */ LCID lcid,
  68. /* [in] */ WORD wFlags,
  69. /* [in] */ DISPPARAMS __RPC_FAR *pdp,
  70. /* [out] */ VARIANT __RPC_FAR *pvarRes,
  71. /* [out] */ EXCEPINFO __RPC_FAR *pei,
  72. /* [unique][in] */ IServiceProvider __RPC_FAR *pspCaller);
  73. HRESULT STDMETHODCALLTYPE DeleteMemberByName(
  74. /* [in] */ BSTR bstr,
  75. /* [in] */ DWORD grfdex);
  76. HRESULT STDMETHODCALLTYPE DeleteMemberByDispID(
  77. /* [in] */ DISPID id);
  78. HRESULT STDMETHODCALLTYPE GetMemberProperties(
  79. /* [in] */ DISPID id,
  80. /* [in] */ DWORD grfdexFetch,
  81. /* [out] */ DWORD __RPC_FAR *pgrfdex);
  82. HRESULT STDMETHODCALLTYPE GetMemberName(
  83. /* [in] */ DISPID id,
  84. /* [out] */ BSTR __RPC_FAR *pbstrName);
  85. HRESULT STDMETHODCALLTYPE GetNextDispID(
  86. /* [in] */ DWORD grfdex,
  87. /* [in] */ DISPID id,
  88. /* [out] */ DISPID __RPC_FAR *pid);
  89. HRESULT STDMETHODCALLTYPE GetNameSpaceParent(
  90. /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppunk);
  91. // ISWbemLocator methods
  92. HRESULT STDMETHODCALLTYPE ConnectServer
  93. (
  94. /*[in]*/ BSTR Server,
  95. /*[in]*/ BSTR Namespace,
  96. /*[in]*/ BSTR User,
  97. /*[in]*/ BSTR Password,
  98. /*[in]*/ BSTR Locale,
  99. /*[in]*/ BSTR Authority,
  100. /*[in]*/ long lSecurityFlags,
  101. /*[in]*/ /*ISWbemNamedValueSet*/ IDispatch *pContext,
  102. /*[out]*/ ISWbemServices **ppNamespace
  103. );
  104. HRESULT STDMETHODCALLTYPE get_Security_
  105. (
  106. /* [in] */ ISWbemSecurity **ppSecurity
  107. );
  108. // IObjectSafety methods
  109. HRESULT STDMETHODCALLTYPE SetInterfaceSafetyOptions
  110. (
  111. /* [in] */ REFIID riid,
  112. /* [in] */ DWORD dwOptionSetMask,
  113. /* [in] */ DWORD dwEnabledOptions
  114. )
  115. {
  116. return (dwOptionSetMask & dwEnabledOptions) ? E_FAIL : S_OK;
  117. }
  118. HRESULT STDMETHODCALLTYPE GetInterfaceSafetyOptions(
  119. /* [in] */ REFIID riid,
  120. /* [out] */ DWORD __RPC_FAR *pdwSupportedOptions,
  121. /* [out] */ DWORD __RPC_FAR *pdwEnabledOptions
  122. )
  123. {
  124. if (pdwSupportedOptions) *pdwSupportedOptions = 0;
  125. if (pdwEnabledOptions) *pdwEnabledOptions = 0;
  126. return S_OK;
  127. }
  128. // ISupportErrorInfo methods
  129. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  130. (
  131. /* [in] */ REFIID riid
  132. );
  133. // IProvideClassInfo methods
  134. HRESULT STDMETHODCALLTYPE GetClassInfo
  135. (
  136. /* [in,out] */ ITypeInfo **ppTI
  137. )
  138. {
  139. return m_Dispatch.GetClassInfo (ppTI);
  140. };
  141. static void Shutdown ()
  142. {
  143. if (s_pDefaultNamespace)
  144. {
  145. delete [] s_pDefaultNamespace;
  146. s_pDefaultNamespace = NULL;
  147. }
  148. }
  149. CWbemLocatorSecurity *GetSecurityInfo ()
  150. {
  151. return m_SecurityInfo;
  152. }
  153. };
  154. #endif