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.

169 lines
3.0 KiB

  1. #ifndef _CUSTOMPROVIDER_HXX_
  2. #define _CUSTOMPROVIDER_HXX_
  3. class CUSTOM_USER_CONTEXT : public W3_USER_CONTEXT
  4. {
  5. public:
  6. CUSTOM_USER_CONTEXT(
  7. AUTH_PROVIDER * pProvider
  8. ) : W3_USER_CONTEXT( pProvider ),
  9. _hImpersonationToken( NULL ),
  10. _hPrimaryToken( NULL ),
  11. _dwAuthType( 0 )
  12. {
  13. }
  14. virtual ~CUSTOM_USER_CONTEXT()
  15. {
  16. if ( _hImpersonationToken != NULL )
  17. {
  18. CloseHandle( _hImpersonationToken );
  19. _hImpersonationToken = NULL;
  20. }
  21. if ( _hPrimaryToken != NULL )
  22. {
  23. CloseHandle( _hPrimaryToken );
  24. _hPrimaryToken = NULL;
  25. }
  26. }
  27. HRESULT
  28. Create(
  29. HANDLE hImpersonationToken,
  30. BYTE * pszUserName,
  31. BOOL fIsUnicode,
  32. DWORD dwAuthType
  33. );
  34. WCHAR *
  35. QueryUserName(
  36. VOID
  37. )
  38. {
  39. return _strUserName.QueryStr();
  40. }
  41. WCHAR *
  42. QueryPassword(
  43. VOID
  44. )
  45. {
  46. return L"";
  47. }
  48. DWORD
  49. QueryAuthType(
  50. VOID
  51. )
  52. {
  53. return _dwAuthType;
  54. }
  55. HANDLE
  56. QueryImpersonationToken(
  57. VOID
  58. )
  59. {
  60. return _hImpersonationToken;
  61. }
  62. HANDLE
  63. QueryPrimaryToken(
  64. VOID
  65. );
  66. PSID
  67. QuerySid(
  68. VOID
  69. )
  70. {
  71. return NULL;
  72. }
  73. private:
  74. HANDLE _hImpersonationToken;
  75. HANDLE _hPrimaryToken;
  76. DWORD _dwAuthType;
  77. STRU _strUserName;
  78. CSpinLock _Lock;
  79. };
  80. class CUSTOM_AUTH_PROVIDER : public AUTH_PROVIDER
  81. {
  82. public:
  83. CUSTOM_AUTH_PROVIDER()
  84. {
  85. }
  86. virtual ~CUSTOM_AUTH_PROVIDER()
  87. {
  88. }
  89. HRESULT
  90. Initialize(
  91. DWORD dwInternalId
  92. )
  93. {
  94. SetInternalId( dwInternalId );
  95. return NO_ERROR;
  96. }
  97. VOID
  98. Terminate(
  99. VOID
  100. )
  101. {
  102. }
  103. HRESULT
  104. DoesApply(
  105. W3_MAIN_CONTEXT * pMainContext,
  106. BOOL * pfApplies
  107. )
  108. {
  109. UNREFERENCED_PARAMETER( pMainContext );
  110. UNREFERENCED_PARAMETER( pfApplies );
  111. return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
  112. }
  113. HRESULT
  114. DoAuthenticate(
  115. W3_MAIN_CONTEXT * pMainContext,
  116. BOOL * pfFilterFinished
  117. )
  118. {
  119. UNREFERENCED_PARAMETER( pMainContext );
  120. UNREFERENCED_PARAMETER( pfFilterFinished );
  121. return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
  122. }
  123. HRESULT
  124. OnAccessDenied(
  125. W3_MAIN_CONTEXT * pMainContext
  126. )
  127. {
  128. //
  129. // No headers for anonymous
  130. //
  131. UNREFERENCED_PARAMETER( pMainContext );
  132. return NO_ERROR;
  133. }
  134. DWORD
  135. QueryAuthType(
  136. VOID
  137. )
  138. {
  139. return MD_AUTH_ANONYMOUS;
  140. }
  141. };
  142. #endif