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.

134 lines
3.0 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // peruser.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // Defines the class NTSamPerUser.
  12. //
  13. ///////////////////////////////////////////////////////////////////////////////
  14. #include <ias.h>
  15. #include <iaslsa.h>
  16. #include <samutil.h>
  17. #include <sdoias.h>
  18. #include <ntsamperuser.h>
  19. STDMETHODIMP NTSamPerUser::Initialize()
  20. {
  21. DWORD error = IASLsaInitialize();
  22. if (error != NO_ERROR) { return HRESULT_FROM_WIN32(error); }
  23. HRESULT hr;
  24. hr = netp.initialize();
  25. if (FAILED(hr)) { goto netp_failed; }
  26. hr = ntds.initialize();
  27. if (FAILED(hr)) { goto ntds_failed; }
  28. hr = ras.initialize();
  29. if (FAILED(hr)) { goto ras_failed; }
  30. return S_OK;
  31. ras_failed:
  32. ntds.finalize();
  33. ntds_failed:
  34. netp.finalize();
  35. netp_failed:
  36. IASLsaUninitialize();
  37. return hr;
  38. }
  39. STDMETHODIMP NTSamPerUser::Shutdown()
  40. {
  41. ras.finalize();
  42. ntds.finalize();
  43. netp.finalize();
  44. IASLsaUninitialize();
  45. return S_OK;
  46. }
  47. IASREQUESTSTATUS NTSamPerUser::onSyncRequest(IRequest* pRequest) throw ()
  48. {
  49. IASREQUESTSTATUS status;
  50. try
  51. {
  52. IASRequest request(pRequest);
  53. //////////
  54. // Should we process the request?
  55. //////////
  56. IASAttribute ignoreDialin;
  57. if (ignoreDialin.load(
  58. request,
  59. IAS_ATTRIBUTE_IGNORE_USER_DIALIN_PROPERTIES,
  60. IASTYPE_BOOLEAN
  61. ) &&
  62. ignoreDialin->Value.Boolean)
  63. {
  64. return IAS_REQUEST_STATUS_CONTINUE;
  65. }
  66. //////////
  67. // Extract the NT4-Account-Name attribute.
  68. //////////
  69. IASAttribute identity;
  70. if (!identity.load(request,
  71. IAS_ATTRIBUTE_NT4_ACCOUNT_NAME,
  72. IASTYPE_STRING))
  73. { return IAS_REQUEST_STATUS_CONTINUE; }
  74. //////////
  75. // Convert the User-Name to SAM format.
  76. //////////
  77. PCWSTR domain, username;
  78. EXTRACT_SAM_IDENTITY(identity->Value.String, domain, username);
  79. IASTracePrintf("NT-SAM User Authorization handler received request "
  80. "for %S\\%S.", domain, username);
  81. //////////
  82. // Try each handler in order.
  83. //////////
  84. status = netp.processUser(request, domain, username);
  85. if (status != IAS_REQUEST_STATUS_INVALID) { goto done; }
  86. status = ntds.processUser(request, domain, username);
  87. if (status != IAS_REQUEST_STATUS_INVALID) { goto done; }
  88. status = ras.processUser(request, domain, username);
  89. if (status != IAS_REQUEST_STATUS_INVALID) { goto done; }
  90. //////////
  91. // Default is to just continue down the pipeline. Theoretically, we
  92. // should never get here.
  93. //////////
  94. status = IAS_REQUEST_STATUS_CONTINUE;
  95. }
  96. catch (const _com_error& ce)
  97. {
  98. IASTraceExcept();
  99. status = IASProcessFailure(pRequest, ce.Error());
  100. }
  101. done:
  102. return status;
  103. }