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.

151 lines
4.5 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 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. const LARGE_INTEGER& kickOffTime
  77. );
  78. static void storeTokenGroups(
  79. IASTL::IASRequest& request,
  80. HANDLE token
  81. );
  82. // Various flavors of MS-CHAPv1
  83. static bool tryMsChap(
  84. IASTL::IASRequest& request,
  85. PCWSTR domainName,
  86. PCWSTR username,
  87. PBYTE challenge
  88. );
  89. static bool tryMsChapCpw1(
  90. IASTL::IASRequest& request,
  91. PCWSTR domainName,
  92. PCWSTR username,
  93. PBYTE challenge
  94. );
  95. static bool tryMsChapCpw2(
  96. IASTL::IASRequest& request,
  97. PCWSTR domainName,
  98. PCWSTR username,
  99. PBYTE challenge
  100. );
  101. // Various flavors of MS-CHAPv2
  102. static bool tryMsChap2(
  103. IASTL::IASRequest& request,
  104. PCWSTR domainName,
  105. PCWSTR username,
  106. IAS_OCTET_STRING& challenge
  107. );
  108. static bool tryMsChap2Cpw(
  109. IASTL::IASRequest& request,
  110. PCWSTR domainName,
  111. PCWSTR username,
  112. IAS_OCTET_STRING& challenge
  113. );
  114. // Various authentication types supported by NTLM.
  115. static bool tryMd5Chap(
  116. IASTL::IASRequest& request,
  117. PCWSTR domainName,
  118. PCWSTR username
  119. );
  120. static bool tryMsChapAll(
  121. IASTL::IASRequest& request,
  122. PCWSTR domainName,
  123. PCWSTR username
  124. );
  125. static bool tryMsChap2All(
  126. IASTL::IASRequest& request,
  127. PCWSTR domainName,
  128. PCWSTR username
  129. );
  130. static bool tryPap(
  131. IASTL::IASRequest& request,
  132. PCWSTR domainName,
  133. PCWSTR username
  134. );
  135. static bool allowLM;
  136. };
  137. #endif // NTSAMAUTH_H