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.

102 lines
2.5 KiB

  1. // Copyright (c) 1996-1999 Microsoft Corporation
  2. //+============================================================================
  3. //
  4. // sid.cxx
  5. //
  6. // Implementation of CSID, which is a wrapper class for a SID.
  7. //
  8. //+============================================================================
  9. #include "pch.cxx"
  10. #pragma hdrstop
  11. #include "trkwks.hxx"
  12. //+----------------------------------------------------------------------------
  13. //
  14. // CSID::Initialize
  15. //
  16. // Alloc and initialize a SID
  17. //
  18. //+----------------------------------------------------------------------------
  19. VOID
  20. CSID::Initialize( enumCSIDAuthority enumcsidAuthority,
  21. BYTE cSubAuthorities ,
  22. DWORD dwSubAuthority0 = 0,
  23. DWORD dwSubAuthority1 = 0,
  24. DWORD dwSubAuthority2 = 0,
  25. DWORD dwSubAuthority3 = 0,
  26. DWORD dwSubAuthority4 = 0,
  27. DWORD dwSubAuthority5 = 0,
  28. DWORD dwSubAuthority6 = 0,
  29. DWORD dwSubAuthority7 = 0 )
  30. {
  31. SID_IDENTIFIER_AUTHORITY rgsid_identifier_authority[] = { SECURITY_NT_AUTHORITY };
  32. if( NULL != _psid )
  33. {
  34. FreeSid( _psid );
  35. _psid = NULL;
  36. }
  37. if( !AllocateAndInitializeSid( &rgsid_identifier_authority[ enumcsidAuthority ],
  38. cSubAuthorities,
  39. dwSubAuthority0,
  40. dwSubAuthority1,
  41. dwSubAuthority2,
  42. dwSubAuthority3,
  43. dwSubAuthority4,
  44. dwSubAuthority5,
  45. dwSubAuthority6,
  46. dwSubAuthority7,
  47. &_psid ))
  48. TrkRaiseLastError();
  49. _fInitialized = TRUE;
  50. }
  51. //+----------------------------------------------------------------------------
  52. //
  53. // CSID::operator PSID
  54. //
  55. // Return the SID
  56. //
  57. //+----------------------------------------------------------------------------
  58. CSID::operator PSID()
  59. {
  60. return( _psid );
  61. }
  62. //+----------------------------------------------------------------------------
  63. //
  64. // CSID::UnInitialize
  65. //
  66. // Free the SID.
  67. //
  68. //+----------------------------------------------------------------------------
  69. VOID
  70. CSID::UnInitialize()
  71. {
  72. if( _fInitialized )
  73. {
  74. if( NULL != _psid )
  75. {
  76. FreeSid( _psid );
  77. _psid = NULL;
  78. }
  79. _fInitialized = FALSE;
  80. }
  81. }