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.

159 lines
3.7 KiB

  1. /////////////////////////////////////////////////////////////////////////////// //
  2. // Copyright (c) Microsoft Corporation
  3. //
  4. // SYNOPSIS
  5. //
  6. // This file describes functions and macros common to all SAM handlers.
  7. //
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef SAMUTIL_H
  10. #define SAMUTIL_H
  11. #pragma once
  12. #include <ntdsapi.h>
  13. #include <iaspolcy.h>
  14. #include <iastl.h>
  15. #include <iastlutl.h>
  16. using namespace IASTL;
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //
  19. // FUNCTION
  20. //
  21. // IASStoreFQUserName
  22. //
  23. // DESCRIPTION
  24. //
  25. // Stores the Fully-Qualified-User-Name.
  26. //
  27. ///////////////////////////////////////////////////////////////////////////////
  28. HRESULT
  29. WINAPI
  30. IASStoreFQUserName(
  31. IAttributesRaw* request,
  32. DS_NAME_FORMAT format,
  33. PCWSTR fqdn
  34. );
  35. ///////////////////////////////////////////////////////////////////////////////
  36. //
  37. // FUNCTION
  38. //
  39. // IASEncryptBuffer
  40. //
  41. // DESCRIPTION
  42. //
  43. // Encrypts the buffer using the appropriate shared secret and authentictor
  44. // for 'request'.
  45. //
  46. ///////////////////////////////////////////////////////////////////////////////
  47. VOID
  48. WINAPI
  49. IASEncryptBuffer(
  50. IAttributesRaw* request,
  51. BOOL salted,
  52. PBYTE buf,
  53. ULONG buflen
  54. ) throw ();
  55. ///////////////////////////////////////////////////////////////////////////////
  56. //
  57. // FUNCTION
  58. //
  59. // IASProcessFailure
  60. //
  61. // DESCRIPTION
  62. //
  63. // Handles any failure during processing of an Access-Request. This function
  64. // will set the response code for the request based on hrReason and return
  65. // an appropriate request status. This ensures that all failures are
  66. // handled consistently across handlers.
  67. //
  68. ///////////////////////////////////////////////////////////////////////////////
  69. IASREQUESTSTATUS
  70. WINAPI
  71. IASProcessFailure(
  72. IRequest* pRequest,
  73. HRESULT hrReason
  74. ) throw ();
  75. ///////////////////////////////////////////////////////////////////////////////
  76. //
  77. // CLASS
  78. //
  79. // SamExtractor
  80. //
  81. // DESCRIPTION
  82. //
  83. // This class parses a NT4 Account Name of the form "<domain>\<username>"
  84. // into its separate components. Then replaces the backslash when it goes
  85. // out of scope.
  86. //
  87. ///////////////////////////////////////////////////////////////////////////////
  88. class SamExtractor
  89. {
  90. public:
  91. SamExtractor(const IASATTRIBUTE& identity);
  92. ~SamExtractor() throw ();
  93. const wchar_t* getDomain() const throw ();
  94. const wchar_t* getUsername() const throw ();
  95. private:
  96. wchar_t* begin;
  97. wchar_t* delim;
  98. // Not implemented
  99. SamExtractor(const SamExtractor&);
  100. SamExtractor& operator=(const SamExtractor&);
  101. };
  102. inline SamExtractor::~SamExtractor() throw ()
  103. {
  104. if (delim != 0)
  105. {
  106. *delim = L'\\';
  107. }
  108. }
  109. inline const wchar_t* SamExtractor::getDomain() const throw ()
  110. {
  111. return (delim != 0) ? begin : L"";
  112. }
  113. inline const wchar_t* SamExtractor::getUsername() const throw ()
  114. {
  115. return (delim != 0) ? (delim + 1) : begin;
  116. }
  117. ///////////////////////////////////////////////////////////////////////////////
  118. //
  119. // CLASS
  120. //
  121. // NtSamHandler
  122. //
  123. // DESCRIPTION
  124. //
  125. // Abstract base class for sub-handlers that process NT-SAM users.
  126. //
  127. ///////////////////////////////////////////////////////////////////////////////
  128. class __declspec(novtable) NtSamHandler
  129. {
  130. public:
  131. virtual ~NtSamHandler() throw ()
  132. { }
  133. virtual HRESULT initialize() throw ()
  134. { return S_OK; }
  135. virtual void finalize() throw ()
  136. { }
  137. };
  138. void InsertInternalTimeout(
  139. IASTL::IASRequest& request,
  140. const LARGE_INTEGER& kickOffTime
  141. );
  142. #endif // _SAMUTIL_H_