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.

248 lines
5.3 KiB

  1. /*++
  2. Copyright (C) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. CALLSEC.H
  5. Abstract:
  6. History:
  7. raymcc 29-Jul-98 First draft.
  8. --*/
  9. #ifndef _CALLSEC_H_
  10. #define _CALLSEC_H_
  11. /******************************************************************************
  12. *
  13. * Name:
  14. *
  15. *
  16. * Description:
  17. *
  18. *
  19. *****************************************************************************/
  20. class CLifeControl
  21. {
  22. public:
  23. BOOL ObjectCreated(IUnknown* pv) { return TRUE;};
  24. void ObjectDestroyed(IUnknown* pv){};
  25. void AddRef(IUnknown* pv) {};
  26. void Release(IUnknown* pv){};;
  27. };
  28. /******************************************************************************
  29. *
  30. * Name:
  31. *
  32. *
  33. * Description:
  34. *
  35. *
  36. *****************************************************************************/
  37. class CLifeControl ;
  38. class CWbemThreadSecurityHandle : public _IWmiThreadSecHandle
  39. {
  40. private:
  41. LONG m_ReferenceCount ;
  42. HANDLE m_ThreadToken ;
  43. DWORD m_ImpersonationLevel ;
  44. DWORD m_AuthenticationService ;
  45. DWORD m_AuthorizationService ;
  46. DWORD m_AuthenticationLevel ;
  47. LPWSTR m_ServerPrincipalName ;
  48. LPWSTR m_Identity ;
  49. WMI_THREAD_SECURITY_ORIGIN m_Origin ;
  50. CLifeControl *m_Control ;
  51. public:
  52. CWbemThreadSecurityHandle ( CLifeControl *a_Control ) ;
  53. CWbemThreadSecurityHandle ( const CWbemThreadSecurityHandle &a_Copy ) ;
  54. ~CWbemThreadSecurityHandle () ;
  55. CWbemThreadSecurityHandle &operator= ( const CWbemThreadSecurityHandle &a_Copy ) ;
  56. HRESULT CloneRpcContext (
  57. IServerSecurity *a_Security
  58. ) ;
  59. HRESULT CloneThreadContext () ;
  60. HRESULT CloneProcessContext () ;
  61. /*
  62. * IUnknown.
  63. */
  64. ULONG STDMETHODCALLTYPE AddRef () ;
  65. ULONG STDMETHODCALLTYPE Release () ;
  66. HRESULT STDMETHODCALLTYPE QueryInterface ( REFIID a_Riid , void **a_Void ) ;
  67. /*
  68. *
  69. */
  70. HRESULT STDMETHODCALLTYPE GetHandleType ( ULONG *a_Type ) { return WMI_HANDLE_THREAD_SECURITY; }
  71. HRESULT STDMETHODCALLTYPE GetTokenOrigin ( WMI_THREAD_SECURITY_ORIGIN *a_Origin ) { return m_Origin ; }
  72. /*
  73. * _IWmiThreadSecHandle
  74. */
  75. HRESULT STDMETHODCALLTYPE GetImpersonation (
  76. DWORD *a_Level
  77. ) ;
  78. HRESULT STDMETHODCALLTYPE GetAuthentication (
  79. DWORD *a_Level
  80. ) ;
  81. HRESULT STDMETHODCALLTYPE GetUser (
  82. ULONG *a_Size ,
  83. LPWSTR a_Buffer
  84. ) ;
  85. HRESULT STDMETHODCALLTYPE GetUserSid (
  86. ULONG *a_Size ,
  87. PSID a_Sid
  88. ) ;
  89. HRESULT STDMETHODCALLTYPE GetToken ( HANDLE *a_ThreadToken ) ;
  90. HRESULT STDMETHODCALLTYPE GetAuthenticationLuid ( LPVOID a_Luid ) ;
  91. /*
  92. * Implementation publics
  93. */
  94. HANDLE GetThreadToken () { return m_ThreadToken ; }
  95. DWORD GetImpersonationLevel () { return m_ImpersonationLevel ; }
  96. DWORD GetAuthenticationService () { return m_AuthenticationService ; }
  97. DWORD GetAuthorizationService () { return m_AuthorizationService ; }
  98. DWORD GetAuthenticationLevel () { return m_AuthenticationLevel ; }
  99. LPWSTR GetServerPrincipalName () { return m_ServerPrincipalName ; }
  100. LPWSTR GetIdentity () { return m_Identity ; }
  101. void SetOrigin ( WMI_THREAD_SECURITY_ORIGIN a_Origin ) { m_Origin = a_Origin ; }
  102. static CWbemThreadSecurityHandle *New () ;
  103. } ;
  104. /******************************************************************************
  105. *
  106. * Name:
  107. *
  108. *
  109. * Description:
  110. *
  111. *
  112. *****************************************************************************/
  113. class CLifeControl ;
  114. class CWbemCallSecurity : public IServerSecurity , public _IWmiCallSec
  115. {
  116. private:
  117. LONG m_ReferenceCount ;
  118. DWORD m_ImpersonationLevel ;
  119. CWbemThreadSecurityHandle *m_ThreadSecurityHandle ;
  120. HANDLE m_ThreadToken ;
  121. CLifeControl *m_Control ;
  122. public:
  123. CWbemCallSecurity ( CLifeControl *a_Control ) ;
  124. ~CWbemCallSecurity () ;
  125. CWbemCallSecurity &operator= ( const CWbemCallSecurity &a_Copy ) ;
  126. public:
  127. CWbemThreadSecurityHandle *GetThreadSecurityHandle () { return m_ThreadSecurityHandle ; }
  128. /*
  129. * IUnknown.
  130. */
  131. ULONG STDMETHODCALLTYPE AddRef () ;
  132. ULONG STDMETHODCALLTYPE Release () ;
  133. HRESULT STDMETHODCALLTYPE QueryInterface ( REFIID a_Riid , void **a_Void ) ;
  134. /*
  135. * IServerSecurity.
  136. */
  137. HRESULT STDMETHODCALLTYPE QueryBlanket (
  138. DWORD *a_AuthenticationService ,
  139. DWORD *a_AuthorizationService ,
  140. OLECHAR **a_ServerPrincipleName ,
  141. DWORD *a_AuthorizationLevel ,
  142. DWORD *a_ImpersonationLevel ,
  143. void **a_Privileges ,
  144. DWORD *a_Capabilities
  145. ) ;
  146. HRESULT STDMETHODCALLTYPE ImpersonateClient () ;
  147. HRESULT STDMETHODCALLTYPE RevertToSelf () ;
  148. BOOL STDMETHODCALLTYPE IsImpersonating () ;
  149. /*
  150. * _IWmiCallSec
  151. */
  152. HRESULT STDMETHODCALLTYPE GetImpersonation (
  153. DWORD *a_Level
  154. ) ;
  155. HRESULT STDMETHODCALLTYPE GetAuthentication (
  156. DWORD *a_Level
  157. ) ;
  158. HRESULT STDMETHODCALLTYPE GetUser (
  159. ULONG *a_Size ,
  160. LPWSTR a_Buffer
  161. ) ;
  162. HRESULT STDMETHODCALLTYPE GetUserSid (
  163. ULONG *a_Size ,
  164. PSID a_Sid
  165. ) ;
  166. HRESULT STDMETHODCALLTYPE GetAuthenticationLuid ( LPVOID a_Luid ) ;
  167. HRESULT STDMETHODCALLTYPE GetThreadSecurity ( WMI_THREAD_SECURITY_ORIGIN a_Origin , _IWmiThreadSecHandle **a_ThreadSecurity ) ;
  168. HRESULT STDMETHODCALLTYPE SetThreadSecurity ( _IWmiThreadSecHandle *a_ThreadSecurity ) ;
  169. static CWbemCallSecurity *New () ;
  170. } ;
  171. #endif