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.

204 lines
3.3 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. _fAuthNTLM = FALSE;
  15. _fCachedToken = FALSE;
  16. _dwSignature = W3_USER_CONTEXT_SIGNATURE;
  17. }
  18. virtual
  19. ~W3_USER_CONTEXT()
  20. {
  21. DBG_ASSERT( _cRefs == 0 );
  22. _dwSignature = W3_USER_CONTEXT_FREE_SIGNATURE;
  23. }
  24. virtual
  25. WCHAR *
  26. QueryUserName(
  27. VOID
  28. ) = 0;
  29. virtual
  30. WCHAR *
  31. QueryRemoteUserName(
  32. VOID
  33. )
  34. {
  35. return QueryUserName();
  36. }
  37. virtual
  38. WCHAR *
  39. QueryPassword(
  40. VOID
  41. ) = 0;
  42. virtual
  43. DWORD
  44. QueryAuthType(
  45. VOID
  46. ) = 0;
  47. virtual
  48. HANDLE
  49. QueryImpersonationToken(
  50. VOID
  51. ) = 0;
  52. virtual
  53. HANDLE
  54. QueryPrimaryToken(
  55. VOID
  56. ) = 0;
  57. virtual
  58. LARGE_INTEGER *
  59. QueryExpiry(
  60. VOID
  61. )
  62. {
  63. return NULL;
  64. }
  65. virtual
  66. PSID
  67. QuerySid(
  68. VOID
  69. )
  70. {
  71. return NULL;
  72. }
  73. virtual
  74. STRA *
  75. QueryAuthToken(
  76. VOID
  77. )
  78. {
  79. return NULL;
  80. }
  81. virtual
  82. TOKEN_CACHE_ENTRY *
  83. QueryCachedToken(
  84. VOID
  85. )
  86. {
  87. return NULL;
  88. }
  89. virtual
  90. HRESULT
  91. GetSspiInfo(
  92. BYTE *,
  93. DWORD,
  94. BYTE *,
  95. DWORD
  96. )
  97. {
  98. return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
  99. }
  100. VOID
  101. ReferenceUserContext(
  102. VOID
  103. )
  104. {
  105. ULONG cRefs = InterlockedIncrement( &_cRefs );
  106. if ( sm_pTraceLog != NULL )
  107. {
  108. WriteRefTraceLog( sm_pTraceLog,
  109. cRefs,
  110. this );
  111. }
  112. }
  113. VOID
  114. DereferenceUserContext(
  115. VOID
  116. )
  117. {
  118. ULONG cRefs = InterlockedDecrement( &_cRefs );
  119. if ( sm_pTraceLog != NULL )
  120. {
  121. WriteRefTraceLog( sm_pTraceLog,
  122. cRefs,
  123. this );
  124. }
  125. if (!cRefs)
  126. {
  127. delete this;
  128. }
  129. }
  130. AUTH_PROVIDER *
  131. QueryProvider(
  132. VOID
  133. ) const
  134. {
  135. return _pProvider;
  136. }
  137. BOOL
  138. QueryIsAuthNTLM(
  139. VOID
  140. ) const
  141. {
  142. return _fAuthNTLM;
  143. }
  144. BOOL
  145. QueryIsCachedToken(
  146. VOID
  147. )
  148. {
  149. return _fCachedToken;
  150. }
  151. VOID
  152. SetCachedToken(
  153. BOOL fCachedToken
  154. )
  155. {
  156. _fCachedToken = fCachedToken;
  157. }
  158. BOOL
  159. CheckSignature(
  160. VOID
  161. ) const
  162. {
  163. return _dwSignature == W3_USER_CONTEXT_SIGNATURE;
  164. }
  165. static PTRACE_LOG sm_pTraceLog;
  166. protected:
  167. BOOL _fAuthNTLM;
  168. private:
  169. DWORD _dwSignature;
  170. LONG _cRefs;
  171. AUTH_PROVIDER * _pProvider;
  172. BOOL _fCachedToken;
  173. };
  174. #endif