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.

127 lines
2.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000 - 2000
  5. //
  6. // File: SecUtil.h
  7. //
  8. // Contents: Utility functions for working with the security APIs
  9. //
  10. // History: 15-Sep-2000 JeffJon Created
  11. //
  12. //
  13. //--------------------------------------------------------------------------
  14. #ifndef _SECUTIL_H_
  15. #define _SECUTIL_H_
  16. extern const GUID GUID_CONTROL_UserChangePassword;
  17. //+--------------------------------------------------------------------------
  18. //
  19. // Class: CSimpleSecurityDescriptorHolder
  20. //
  21. // Purpose: Smart wrapper for a SecurityDescriptor
  22. //
  23. // History: 15-Sep-2000 JeffJon Created
  24. //
  25. //---------------------------------------------------------------------------
  26. class CSimpleSecurityDescriptorHolder
  27. {
  28. public:
  29. //
  30. // Constructor and Destructor
  31. //
  32. CSimpleSecurityDescriptorHolder();
  33. ~CSimpleSecurityDescriptorHolder();
  34. //
  35. // Public member data
  36. //
  37. PSECURITY_DESCRIPTOR m_pSD;
  38. private:
  39. CSimpleSecurityDescriptorHolder(const CSimpleSecurityDescriptorHolder&) {}
  40. CSimpleSecurityDescriptorHolder& operator=(const CSimpleSecurityDescriptorHolder&) {}
  41. };
  42. //+--------------------------------------------------------------------------
  43. //
  44. // Class: CSimpleAclHolder
  45. //
  46. // Purpose: Smart wrapper for a ACL
  47. //
  48. // History: 15-Sep-2000 JeffJon Created
  49. //
  50. //---------------------------------------------------------------------------
  51. class CSimpleAclHolder
  52. {
  53. public:
  54. CSimpleAclHolder()
  55. {
  56. m_pAcl = NULL;
  57. }
  58. ~CSimpleAclHolder()
  59. {
  60. if (m_pAcl != NULL)
  61. ::LocalFree(m_pAcl);
  62. }
  63. PACL m_pAcl;
  64. };
  65. //+--------------------------------------------------------------------------
  66. //
  67. // Class: CSidHolder
  68. //
  69. // Purpose: Smart wrapper for a SID
  70. //
  71. // History: 15-Sep-2000 JeffJon Created
  72. //
  73. //---------------------------------------------------------------------------
  74. class CSidHolder
  75. {
  76. public:
  77. //
  78. // Constructor and Destructor
  79. //
  80. CSidHolder();
  81. ~CSidHolder();
  82. //
  83. // Public methods
  84. //
  85. PSID Get();
  86. bool Copy(PSID p);
  87. void Attach(PSID p, bool bLocalAlloc);
  88. void Clear();
  89. private:
  90. //
  91. // Private methods
  92. //
  93. void _Init();
  94. void _Free();
  95. bool _Copy(PSID p);
  96. //
  97. // Private member data
  98. //
  99. PSID m_pSID;
  100. bool m_bLocalAlloc;
  101. };
  102. //
  103. //Function for reading and writing acl
  104. //
  105. HRESULT
  106. DSReadObjectSecurity(IN IDirectoryObject *pDsObject,
  107. OUT SECURITY_DESCRIPTOR_CONTROL * psdControl,
  108. OUT PACL *ppDacl);
  109. HRESULT
  110. DSWriteObjectSecurity(IN IDirectoryObject *pDsObject,
  111. IN SECURITY_DESCRIPTOR_CONTROL sdControl,
  112. PACL pDacl);
  113. #endif //_SECUTIL_H_