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.

171 lines
5.3 KiB

  1. #ifndef __ACLPAGE_H__
  2. #define __ACLPAGE_H__
  3. #include "aclui.h"
  4. #define DONT_WANT_SHELLDEBUG
  5. #include "shlobj.h" // LPITEMIDLIST
  6. #include "shlobjp.h"
  7. #define SHARE_PERM_FULL_CONTROL FILE_ALL_ACCESS
  8. #define SHARE_PERM_READ_ONLY (FILE_GENERIC_READ | FILE_EXECUTE)
  9. #define SHARE_PERM_READ_WRITE (FILE_GENERIC_READ | FILE_EXECUTE | FILE_GENERIC_WRITE | DELETE)
  10. #define ACCOUNT_EVERYONE _T("everyone")
  11. #define ACCOUNT_ADMINISTRATORS _T("administrators")
  12. #define ACCOUNT_SBSFOLDEROPERATORS _T("SBS Folder Operators") // non-localizable according to SBS dev AaronN
  13. #define ACCOUNT_SYSTEM _T("system")
  14. #define ACCOUNT_INTERACTIVE _T("interactive")
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CPermEntry
  17. class CPermEntry
  18. {
  19. public:
  20. CPermEntry();
  21. ~CPermEntry();
  22. HRESULT Initialize(
  23. IN LPCTSTR lpszSystem,
  24. IN LPCTSTR lpszAccount,
  25. IN DWORD dwAccessMask
  26. );
  27. UINT GetLengthSid();
  28. HRESULT AddAccessAllowedAce(OUT PACL pACL);
  29. protected:
  30. CString m_cstrSystem;
  31. CString m_cstrAccount;
  32. DWORD m_dwAccessMask;
  33. PSID m_pSid;
  34. BOOL m_bWellKnownSid;
  35. };
  36. HRESULT
  37. BuildSecurityDescriptor(
  38. IN CPermEntry *pPermEntry, // an array of CPermEntry
  39. IN UINT cEntries, // number of entries in the array
  40. OUT PSECURITY_DESCRIPTOR *ppSelfRelativeSD // return a security descriptor in self-relative form
  41. );
  42. HRESULT
  43. GetAccountSID(
  44. IN LPCTSTR lpszSystem, // system where the account belongs to
  45. IN LPCTSTR lpszAccount, // account
  46. OUT PSID *ppSid, // return SID of the account
  47. OUT BOOL *pbWellKnownSID // return a BOOL, caller needs to call FreeSid() on a well-known SID
  48. );
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CShareSecurityInformation
  51. class CShareSecurityInformation : public ISecurityInformation
  52. {
  53. private:
  54. ULONG m_cRef;
  55. CString m_cstrComputerName;
  56. CString m_cstrShareName;
  57. CString m_cstrPageTitle;
  58. PSECURITY_DESCRIPTOR m_pDefaultDescriptor;
  59. BOOL m_bDefaultSD;
  60. public:
  61. CShareSecurityInformation(PSECURITY_DESCRIPTOR pSelfRelativeSD);
  62. ~CShareSecurityInformation();
  63. void Initialize(
  64. IN LPCTSTR lpszComputerName,
  65. IN LPCTSTR lpszShareName,
  66. IN LPCTSTR lpszPageTitle
  67. );
  68. // *** IUnknown methods ***
  69. STDMETHOD(QueryInterface)(REFIID, LPVOID *);
  70. STDMETHOD_(ULONG, AddRef)();
  71. STDMETHOD_(ULONG, Release)();
  72. // *** ISecurityInformation methods ***
  73. STDMETHOD(GetObjectInformation) (PSI_OBJECT_INFO pObjectInfo );
  74. STDMETHOD(GetSecurity) (SECURITY_INFORMATION RequestedInformation,
  75. PSECURITY_DESCRIPTOR *ppSecurityDescriptor,
  76. BOOL fDefault );
  77. STDMETHOD(SetSecurity) (SECURITY_INFORMATION SecurityInformation,
  78. PSECURITY_DESCRIPTOR pSecurityDescriptor );
  79. STDMETHOD(GetAccessRights)(
  80. const GUID *pguidObjectType,
  81. DWORD dwFlags,
  82. PSI_ACCESS *ppAccess,
  83. ULONG *pcAccesses,
  84. ULONG *piDefaultAccess
  85. );
  86. STDMETHOD(MapGeneric)(
  87. const GUID *pguidObjectType,
  88. UCHAR *pAceFlags,
  89. ACCESS_MASK *pMask
  90. );
  91. STDMETHOD(GetInheritTypes)(
  92. PSI_INHERIT_TYPE *ppInheritTypes,
  93. ULONG *pcInheritTypes
  94. );
  95. STDMETHOD(PropertySheetPageCallback)(
  96. HWND hwnd,
  97. UINT uMsg,
  98. SI_PAGE_TYPE uPage
  99. );
  100. protected:
  101. HRESULT GetDefaultSD(
  102. OUT PSECURITY_DESCRIPTOR *ppsd
  103. );
  104. HRESULT MakeSelfRelativeCopy(
  105. IN PSECURITY_DESCRIPTOR psdOriginal,
  106. OUT PSECURITY_DESCRIPTOR *ppsdNew
  107. );
  108. };
  109. /////////////////////////////////////////////////////////////////////////////
  110. // CFileSecurityDataObject
  111. class CFileSecurityDataObject: public IDataObject
  112. {
  113. protected:
  114. UINT m_cRef;
  115. CString m_cstrComputerName;
  116. CString m_cstrFolder;
  117. CString m_cstrPath;
  118. CLIPFORMAT m_cfIDList;
  119. public:
  120. CFileSecurityDataObject();
  121. ~CFileSecurityDataObject();
  122. void Initialize(
  123. IN LPCTSTR lpszComputerName,
  124. IN LPCTSTR lpszFolder
  125. );
  126. // *** IUnknown methods ***
  127. STDMETHOD(QueryInterface)(REFIID, LPVOID *);
  128. STDMETHOD_(ULONG, AddRef)();
  129. STDMETHOD_(ULONG, Release)();
  130. // *** IDataObject methods ***
  131. STDMETHOD(GetData)(LPFORMATETC pFEIn, LPSTGMEDIUM pSTM);
  132. inline STDMETHOD(GetDataHere)(LPFORMATETC pFE, LPSTGMEDIUM pSTM) {return E_NOTIMPL;}
  133. inline STDMETHOD(QueryGetData)(LPFORMATETC pFE) {return E_NOTIMPL;}
  134. inline STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC pFEIn, LPFORMATETC pFEOut) {return E_NOTIMPL;}
  135. inline STDMETHOD(SetData)(LPFORMATETC pFE, LPSTGMEDIUM pSTM, BOOL fRelease) {return E_NOTIMPL;}
  136. inline STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC *ppEnum) {return E_NOTIMPL;}
  137. inline STDMETHOD(DAdvise)(LPFORMATETC pFE, DWORD grfAdv, LPADVISESINK pAdvSink, LPDWORD pdwConnection) {return E_NOTIMPL;}
  138. inline STDMETHOD(DUnadvise)(DWORD dwConnection) {return E_NOTIMPL;}
  139. inline STDMETHOD(EnumDAdvise)(LPENUMSTATDATA *ppEnum) {return E_NOTIMPL;}
  140. HRESULT GetFolderPIDList(OUT LPITEMIDLIST *ppidl);
  141. };
  142. HRESULT
  143. CreateFileSecurityPropPage(
  144. HPROPSHEETPAGE *phOutPage,
  145. LPDATAOBJECT pDataObject
  146. );
  147. #endif // __ACLPAGE_H__