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.

100 lines
2.2 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // AuthBase.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file defines the class AuthBase.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 02/12/1998 Original version.
  16. // 03/27/1998 Prevent attribute leak when component fails to initialize.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #include <ias.h>
  20. #include <iasutil.h>
  21. #include <sdoias.h>
  22. #include <authbase.h>
  23. HRESULT AuthBase::initialize() throw ()
  24. {
  25. return S_OK;
  26. }
  27. void AuthBase::finalize() throw ()
  28. {
  29. }
  30. void AuthBase::onAccept(IASRequest& request, HANDLE token)
  31. {
  32. DWORD returnLength;
  33. //////////
  34. // Determine the needed buffer size.
  35. //////////
  36. BOOL success = GetTokenInformation(
  37. token,
  38. TokenGroups,
  39. NULL,
  40. 0,
  41. &returnLength
  42. );
  43. DWORD status = GetLastError();
  44. // Should have failed with ERROR_INSUFFICIENT_BUFFER.
  45. if (success || status != ERROR_INSUFFICIENT_BUFFER)
  46. {
  47. IASTraceFailure("GetTokenInformation", status);
  48. _w32_issue_error(status);
  49. }
  50. //////////
  51. // Allocate an attribute.
  52. //////////
  53. IASAttribute groups(true);
  54. //////////
  55. // Allocate a buffer to hold the TOKEN_GROUPS array.
  56. //////////
  57. groups->Value.OctetString.lpValue = (PBYTE)CoTaskMemAlloc(returnLength);
  58. if (!groups->Value.OctetString.lpValue)
  59. {
  60. _com_issue_error(E_OUTOFMEMORY);
  61. }
  62. //////////
  63. // Get the Token Groups info.
  64. //////////
  65. GetTokenInformation(
  66. token,
  67. TokenGroups,
  68. groups->Value.OctetString.lpValue,
  69. returnLength,
  70. &groups->Value.OctetString.dwLength
  71. );
  72. //////////
  73. // Set the id and type of the initialized attribute.
  74. //////////
  75. groups->dwId = IAS_ATTRIBUTE_TOKEN_GROUPS;
  76. groups->Value.itType = IASTYPE_OCTET_STRING;
  77. //////////
  78. // Inject the Token-Groups into the request.
  79. //////////
  80. groups.store(request);
  81. }