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.

168 lines
2.6 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. CHAR * pszUserName,
  31. DWORD dwAuthType
  32. );
  33. WCHAR *
  34. QueryUserName(
  35. VOID
  36. )
  37. {
  38. return _strUserName.QueryStr();
  39. }
  40. BOOL
  41. QueryDelegatable(
  42. VOID
  43. )
  44. {
  45. return FALSE;
  46. }
  47. WCHAR *
  48. QueryPassword(
  49. VOID
  50. )
  51. {
  52. return L"";
  53. }
  54. DWORD
  55. QueryAuthType(
  56. VOID
  57. )
  58. {
  59. return _dwAuthType;
  60. }
  61. HANDLE
  62. QueryImpersonationToken(
  63. VOID
  64. )
  65. {
  66. return _hImpersonationToken;
  67. }
  68. HANDLE
  69. QueryPrimaryToken(
  70. VOID
  71. );
  72. PSID
  73. QuerySid(
  74. VOID
  75. )
  76. {
  77. return NULL;
  78. }
  79. private:
  80. HANDLE _hImpersonationToken;
  81. HANDLE _hPrimaryToken;
  82. DWORD _dwAuthType;
  83. STRU _strUserName;
  84. CSpinLock _Lock;
  85. };
  86. class CUSTOM_AUTH_PROVIDER : public AUTH_PROVIDER
  87. {
  88. public:
  89. CUSTOM_AUTH_PROVIDER()
  90. {
  91. }
  92. virtual ~CUSTOM_AUTH_PROVIDER()
  93. {
  94. }
  95. HRESULT
  96. Initialize(
  97. DWORD dwInternalId
  98. )
  99. {
  100. SetInternalId( dwInternalId );
  101. return NO_ERROR;
  102. }
  103. VOID
  104. Terminate(
  105. VOID
  106. )
  107. {
  108. }
  109. HRESULT
  110. DoesApply(
  111. W3_MAIN_CONTEXT * pMainContext,
  112. BOOL * pfApplies
  113. )
  114. {
  115. return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
  116. }
  117. HRESULT
  118. DoAuthenticate(
  119. W3_MAIN_CONTEXT * pMainContext
  120. )
  121. {
  122. return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
  123. }
  124. HRESULT
  125. OnAccessDenied(
  126. W3_MAIN_CONTEXT * pMainContext
  127. )
  128. {
  129. //
  130. // No headers for anonymous
  131. //
  132. return NO_ERROR;
  133. }
  134. DWORD
  135. QueryAuthType(
  136. VOID
  137. )
  138. {
  139. return MD_AUTH_ANONYMOUS;
  140. }
  141. };
  142. #endif