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.

150 lines
4.3 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // ntsamauth.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // Declares the class NTSamAuthentication.
  12. //
  13. ///////////////////////////////////////////////////////////////////////////////
  14. #ifndef NTSAMAUTH_H
  15. #define NTSAMAUTH_H
  16. #include <iastl.h>
  17. namespace IASTL
  18. {
  19. class IASRequest;
  20. }
  21. ///////////////////////////////////////////////////////////////////////////////
  22. //
  23. // CLASS
  24. //
  25. // NTSamAuthentication
  26. //
  27. // DESCRIPTION
  28. //
  29. // This class implements a request handler for authenticating users against
  30. // the SAM database.
  31. //
  32. ///////////////////////////////////////////////////////////////////////////////
  33. class ATL_NO_VTABLE NTSamAuthentication
  34. : public IASTL::IASRequestHandlerSync,
  35. public CComCoClass<NTSamAuthentication, &__uuidof(NTSamAuthentication)>
  36. {
  37. public:
  38. IAS_DECLARE_REGISTRY(NTSamAuthentication, 1, 0, IASTypeLibrary)
  39. // IIasComponent
  40. STDMETHOD(Initialize)();
  41. STDMETHOD(Shutdown)();
  42. STDMETHOD(PutProperty)(LONG Id, VARIANT* pValue);
  43. // These functions are public so they can be used for change password.
  44. static bool enforceLmRestriction(
  45. IASTL::IASRequest& request
  46. );
  47. static void doMsChapAuthentication(
  48. IASTL::IASRequest& request,
  49. PCWSTR domainName,
  50. PCWSTR username,
  51. BYTE identity,
  52. PBYTE challenge,
  53. PBYTE ntResponse,
  54. PBYTE lmResponse
  55. );
  56. static void doMsChap2Authentication(
  57. IASTL::IASRequest& request,
  58. PCWSTR domainName,
  59. PCWSTR username,
  60. BYTE identity,
  61. IAS_OCTET_STRING& challenge,
  62. PBYTE response,
  63. PBYTE peerChallenge
  64. );
  65. private:
  66. virtual IASREQUESTSTATUS onSyncRequest(IRequest* pRequest) throw ();
  67. // Helper functions to store various attributes.
  68. static void storeAuthenticationType(
  69. IASTL::IASRequest& request,
  70. DWORD authType
  71. );
  72. static void storeLogonResult(
  73. IASTL::IASRequest& request,
  74. DWORD status,
  75. HANDLE token
  76. );
  77. static void storeTokenGroups(
  78. IASTL::IASRequest& request,
  79. HANDLE token
  80. );
  81. // Various flavors of MS-CHAPv1
  82. static bool tryMsChap(
  83. IASTL::IASRequest& request,
  84. PCWSTR domainName,
  85. PCWSTR username,
  86. PBYTE challenge
  87. );
  88. static bool tryMsChapCpw1(
  89. IASTL::IASRequest& request,
  90. PCWSTR domainName,
  91. PCWSTR username,
  92. PBYTE challenge
  93. );
  94. static bool tryMsChapCpw2(
  95. IASTL::IASRequest& request,
  96. PCWSTR domainName,
  97. PCWSTR username,
  98. PBYTE challenge
  99. );
  100. // Various flavors of MS-CHAPv2
  101. static bool tryMsChap2(
  102. IASTL::IASRequest& request,
  103. PCWSTR domainName,
  104. PCWSTR username,
  105. IAS_OCTET_STRING& challenge
  106. );
  107. static bool tryMsChap2Cpw(
  108. IASTL::IASRequest& request,
  109. PCWSTR domainName,
  110. PCWSTR username,
  111. IAS_OCTET_STRING& challenge
  112. );
  113. // Various authentication types supported by NTLM.
  114. static bool tryMd5Chap(
  115. IASTL::IASRequest& request,
  116. PCWSTR domainName,
  117. PCWSTR username
  118. );
  119. static bool tryMsChapAll(
  120. IASTL::IASRequest& request,
  121. PCWSTR domainName,
  122. PCWSTR username
  123. );
  124. static bool tryMsChap2All(
  125. IASTL::IASRequest& request,
  126. PCWSTR domainName,
  127. PCWSTR username
  128. );
  129. static bool tryPap(
  130. IASTL::IASRequest& request,
  131. PCWSTR domainName,
  132. PCWSTR username
  133. );
  134. static bool allowLM;
  135. };
  136. #endif // NTSAMAUTH_H