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.

135 lines
3.1 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. SamExtractor extractor(*identity);
  78. PCWSTR domain = extractor.getDomain();
  79. PCWSTR username = extractor.getUsername();
  80. IASTracePrintf("NT-SAM User Authorization handler received request "
  81. "for %S\\%S.", domain, username);
  82. //////////
  83. // Try each handler in order.
  84. //////////
  85. status = netp.processUser(request, domain, username);
  86. if (status != IAS_REQUEST_STATUS_INVALID) { goto done; }
  87. status = ntds.processUser(request, domain, username);
  88. if (status != IAS_REQUEST_STATUS_INVALID) { goto done; }
  89. status = ras.processUser(request, domain, username);
  90. if (status != IAS_REQUEST_STATUS_INVALID) { goto done; }
  91. //////////
  92. // Default is to just continue down the pipeline. Theoretically, we
  93. // should never get here.
  94. //////////
  95. status = IAS_REQUEST_STATUS_CONTINUE;
  96. }
  97. catch (const _com_error& ce)
  98. {
  99. IASTraceExcept();
  100. status = IASProcessFailure(pRequest, ce.Error());
  101. }
  102. done:
  103. return status;
  104. }