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.

53 lines
1.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: permset.h
  8. //
  9. // This file contains the definition of the CPermissionSet class
  10. //
  11. //--------------------------------------------------------------------------
  12. #ifndef _PERMSET_H_
  13. #define _PERMSET_H_
  14. typedef struct _PERMISSION
  15. {
  16. ACCESS_MASK mask; // permission bits
  17. DWORD dwFlags; // AceFlags (e.g. inheritance bits)
  18. GUID guid; // often GUID_NULL
  19. } PERMISSION, *PPERMISSION;
  20. class CPermissionSet
  21. {
  22. private:
  23. HDSA m_hPermList; // Dynamic array of PERMISSION structures
  24. HDPA m_hAdvPermList; // Dynamic array of ACE pointers
  25. BOOL m_fObjectAcesPresent;
  26. public:
  27. CPermissionSet() : m_hPermList(NULL), m_hAdvPermList(NULL), m_fObjectAcesPresent(FALSE) {}
  28. ~CPermissionSet() { Reset(); }
  29. void Reset();
  30. void ResetAdvanced();
  31. BOOL AddAce(const GUID *pguid, ACCESS_MASK mask, DWORD dwFlags);
  32. BOOL AddPermission(PPERMISSION pPerm);
  33. BOOL AddAdvancedAce(PACE_HEADER pAce);
  34. UINT GetPermCount(BOOL fIncludeAdvAces = FALSE) const;
  35. PPERMISSION GetPermission(UINT i) const { if (m_hPermList) return (PPERMISSION)DSA_GetItemPtr(m_hPermList, i); return NULL; }
  36. PPERMISSION operator[](UINT i) const { return GetPermission(i); }
  37. ULONG GetAclLength(ULONG cbSid) const;
  38. BOOL AppendToAcl(PACL pAcl, PACE_HEADER *ppAcePos, PSID pSid, BOOL fAllowAce, DWORD dwFlags) const;
  39. void ConvertInheritedAces(CPermissionSet &permInherited);
  40. void RemovePermission(PPERMISSION pPerm, BOOL bInheritFlag = FALSE);
  41. };
  42. // Flags for AppendToAcl
  43. #define PS_NONOBJECT 0x00000001L
  44. #define PS_OBJECT 0x00000002L
  45. #endif // _PERMSET_H_