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.

162 lines
2.6 KiB

  1. #ifndef _USERCONTEXT_HXX_
  2. #define _USERCONTEXT_HXX_
  3. class AUTH_PROVIDER;
  4. #define W3_USER_CONTEXT_SIGNATURE 'SCUW'
  5. #define W3_USER_CONTEXT_FREE_SIGNATURE 'fCUW'
  6. class W3_USER_CONTEXT
  7. {
  8. public:
  9. W3_USER_CONTEXT( AUTH_PROVIDER * pProvider )
  10. {
  11. _cRefs = 1;
  12. DBG_ASSERT( pProvider != NULL );
  13. _pProvider = pProvider;
  14. _dwSignature = W3_USER_CONTEXT_SIGNATURE;
  15. }
  16. virtual
  17. ~W3_USER_CONTEXT()
  18. {
  19. DBG_ASSERT( _cRefs == 0 );
  20. _dwSignature = W3_USER_CONTEXT_FREE_SIGNATURE;
  21. }
  22. virtual
  23. WCHAR *
  24. QueryUserName(
  25. VOID
  26. ) = 0;
  27. virtual
  28. WCHAR *
  29. QueryRemoteUserName(
  30. VOID
  31. )
  32. {
  33. return QueryUserName();
  34. }
  35. virtual
  36. BOOL
  37. QueryDelegatable(
  38. VOID
  39. ) = 0;
  40. virtual
  41. WCHAR *
  42. QueryPassword(
  43. VOID
  44. ) = 0;
  45. virtual
  46. DWORD
  47. QueryAuthType(
  48. VOID
  49. ) = 0;
  50. virtual
  51. HANDLE
  52. QueryImpersonationToken(
  53. VOID
  54. ) = 0;
  55. virtual
  56. HANDLE
  57. QueryPrimaryToken(
  58. VOID
  59. ) = 0;
  60. virtual
  61. LARGE_INTEGER *
  62. QueryExpiry(
  63. VOID
  64. )
  65. {
  66. return NULL;
  67. }
  68. virtual
  69. PSID
  70. QuerySid(
  71. VOID
  72. )
  73. {
  74. return NULL;
  75. }
  76. virtual
  77. HRESULT
  78. GetSspiInfo(
  79. BYTE * pCredHandle,
  80. DWORD cbCredHandle,
  81. BYTE * pCtxtHandle,
  82. DWORD cbCtxtHandle
  83. )
  84. {
  85. return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
  86. }
  87. VOID
  88. ReferenceUserContext(
  89. VOID
  90. )
  91. {
  92. ULONG cRefs = InterlockedIncrement( &_cRefs );
  93. if ( sm_pTraceLog != NULL )
  94. {
  95. WriteRefTraceLog( sm_pTraceLog,
  96. cRefs,
  97. this );
  98. }
  99. }
  100. VOID
  101. DereferenceUserContext(
  102. VOID
  103. )
  104. {
  105. ULONG cRefs = InterlockedDecrement( &_cRefs );
  106. if ( sm_pTraceLog != NULL )
  107. {
  108. WriteRefTraceLog( sm_pTraceLog,
  109. cRefs,
  110. this );
  111. }
  112. if (!cRefs)
  113. {
  114. delete this;
  115. }
  116. }
  117. AUTH_PROVIDER *
  118. QueryProvider(
  119. VOID
  120. ) const
  121. {
  122. return _pProvider;
  123. }
  124. BOOL
  125. CheckSignature(
  126. VOID
  127. ) const
  128. {
  129. return _dwSignature == W3_USER_CONTEXT_SIGNATURE;
  130. }
  131. static PTRACE_LOG sm_pTraceLog;
  132. private:
  133. DWORD _dwSignature;
  134. LONG _cRefs;
  135. AUTH_PROVIDER * _pProvider;
  136. };
  137. #endif