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.

155 lines
4.3 KiB

  1. /*++
  2. Copyright (C) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. CALLSEC.H
  5. Abstract:
  6. IWbemCallSecurity, IServerSecurity implementation for
  7. provider impersonation.
  8. History:
  9. raymcc 29-Jul-98 First draft.
  10. --*/
  11. #ifndef _CALLSEC_H_
  12. #define _CALLSEC_H_
  13. #include "parmdefs.h"
  14. // {2ECF39D0-2B26-11d2-AEC8-00C04FB68820}
  15. DEFINE_GUID(IID_IWbemCallSecurity,
  16. 0x2ecf39d0, 0x2b26, 0x11d2, 0xae, 0xc8, 0x0, 0xc0, 0x4f, 0xb6, 0x88, 0x20);
  17. class IWbemCallSecurity : public IServerSecurity
  18. {
  19. public:
  20. virtual HRESULT GetPotentialImpersonation() = 0;
  21. // Tells what the impersonation level would be if
  22. // this object were applied to a thread.
  23. virtual HRESULT GetActiveImpersonation() = 0;
  24. // Tells the true level of impersonation in the
  25. // executing thread.
  26. virtual HRESULT CloneThreadContext(BOOL bInternallyIssued) = 0;
  27. // Called to clone the execution context of the calling thread.
  28. virtual DWORD GetAuthenticationId(LUID& rluid) = 0;
  29. virtual HANDLE GetToken() = 0;
  30. };
  31. //***************************************************************************
  32. //
  33. // CWbemCallSecurity
  34. //
  35. // This object is used to supply client impersonation to providers.
  36. //
  37. //***************************************************************************
  38. class POLARITY CWbemCallSecurity : public IWbemCallSecurity
  39. {
  40. LONG m_lRef; // COM ref count
  41. HANDLE m_hThreadToken; // Client token for impersonation
  42. BOOL m_bWin9x; // TRUE if on a Win9x platform
  43. DWORD m_dwPotentialImpLevel; // Potential RPC_C_IMP_LEVEL_ or 0
  44. DWORD m_dwActiveImpLevel; // Active RPC_C_IMP_LEVEL_ or 0
  45. // IServerSecurity::QueryBlanket values
  46. DWORD m_dwAuthnSvc; // Authentication service
  47. DWORD m_dwAuthzSvc; // Authorization service
  48. DWORD m_dwAuthnLevel; // Authentication level
  49. LPWSTR m_pServerPrincNam; //
  50. LPWSTR m_pIdentity; // User identity
  51. CWbemCallSecurity();
  52. ~CWbemCallSecurity();
  53. void operator=(const CWbemCallSecurity& Other);
  54. HRESULT CloneThreadToken();
  55. public:
  56. static IWbemCallSecurity * CreateInst();
  57. const wchar_t *GetCallerIdentity() { return m_pIdentity; }
  58. void DumpCurrentContext();
  59. virtual DWORD GetAuthenticationId(LUID& rluid);
  60. virtual HANDLE GetToken();
  61. // IUnknown.
  62. // =========
  63. virtual ULONG STDMETHODCALLTYPE AddRef();
  64. virtual ULONG STDMETHODCALLTYPE Release();
  65. virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppv);
  66. // IServerSecurity.
  67. // ================
  68. virtual HRESULT STDMETHODCALLTYPE QueryBlanket(
  69. /* [out] */ DWORD __RPC_FAR *pAuthnSvc,
  70. /* [out] */ DWORD __RPC_FAR *pAuthzSvc,
  71. /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *pServerPrincName,
  72. /* [out] */ DWORD __RPC_FAR *pAuthnLevel,
  73. /* [out] */ DWORD __RPC_FAR *pImpLevel,
  74. /* [out] */ void __RPC_FAR *__RPC_FAR *pPrivs,
  75. /* [out] */ DWORD __RPC_FAR *pCapabilities
  76. );
  77. virtual HRESULT STDMETHODCALLTYPE ImpersonateClient( void);
  78. virtual HRESULT STDMETHODCALLTYPE RevertToSelf( void);
  79. virtual BOOL STDMETHODCALLTYPE IsImpersonating( void);
  80. // IWbemCallSecurity methods.
  81. // ============================
  82. virtual HRESULT GetPotentialImpersonation();
  83. // Tells what the impersonation level would be if
  84. // this object were applied to a thread.
  85. virtual HRESULT GetActiveImpersonation();
  86. // Tells the true level of impersonation in the
  87. // executing thread.
  88. virtual HRESULT CloneThreadContext(BOOL bInternallyIssued);
  89. // Called to clone the execution context of the calling thread.
  90. static RELEASE_ME CWbemCallSecurity* MakeInternalCopyOfThread();
  91. };
  92. class POLARITY CDerivedObjectSecurity
  93. {
  94. protected:
  95. CNtSid m_sidUser;
  96. CNtSid m_sidSystem;
  97. BOOL m_bValid;
  98. BOOL m_bEnabled;
  99. protected:
  100. static HRESULT RetrieveSidFromToken(HANDLE hTokeni, CNtSid* psid);
  101. public:
  102. CDerivedObjectSecurity();
  103. ~CDerivedObjectSecurity();
  104. static HRESULT RetrieveSidFromCall(CNtSid* psid);
  105. BOOL AccessCheck();
  106. };
  107. #endif