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.

155 lines
3.8 KiB

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