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.

229 lines
8.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: ServPerm.h
  7. //
  8. // Contents: definition of CSecurityInfo
  9. //
  10. //----------------------------------------------------------------------------
  11. #ifndef __SERVPERM_H_INCLUDED__
  12. #define __SERVPERM_H_INCLUDED__
  13. // #include "cookie.h"
  14. #define CONFIG_SECURITY_PAGE_READ_ONLY 1
  15. #define CONFIG_SECURITY_PAGE_NO_PROTECT 2
  16. #define CONFIG_SECURITY_PAGE 3
  17. #define CONFIG_SECURITY_PAGE_RO_NP 4
  18. #define ANALYSIS_SECURITY_PAGE_READ_ONLY 5
  19. #define ANALYSIS_SECURITY_PAGE_NO_PROTECT 6
  20. #define ANALYSIS_SECURITY_PAGE 7
  21. #define ANALYSIS_SECURITY_PAGE_RO_NP 8
  22. #define SECURITY_PAGE 9
  23. #define SECURITY_PAGE_NO_PROTECT 10
  24. #define SECURITY_PAGE_READ_ONLY 11
  25. #define SECURITY_PAGE_RO_NP 12
  26. //Bug 424909, Yanggao, 6/29/2001
  27. struct __declspec(uuid("965FC360-16FF-11d0-91CB-00AA00BBB723")) ISecurityInformation;
  28. #ifdef _ATL_DEBUG
  29. #define END_SEC_COM_MAP() {NULL, 0, 0}}; return &_entries[1];}
  30. #else
  31. #define END_SEC_COM_MAP() {NULL, 0, 0}}; return _entries;}
  32. #endif // _ATL_DEBUG
  33. class CSecurityInfo : public ISecurityInformation, public CComObjectRoot
  34. {
  35. DECLARE_NOT_AGGREGATABLE(CSecurityInfo)
  36. BEGIN_COM_MAP(CSecurityInfo)
  37. COM_INTERFACE_ENTRY(ISecurityInformation)
  38. END_COM_MAP()
  39. // *** ISecurityInformation methods ***
  40. STDMETHOD(GetObjectInformation) (PSI_OBJECT_INFO pObjectInfo );
  41. STDMETHOD(GetSecurity) (SECURITY_INFORMATION RequestedInformation,
  42. PSECURITY_DESCRIPTOR *ppSecurityDescriptor,
  43. BOOL fDefault );
  44. STDMETHOD(SetSecurity) (SECURITY_INFORMATION SecurityInformation,
  45. PSECURITY_DESCRIPTOR pSecurityDescriptor );
  46. STDMETHOD(GetAccessRights) (const GUID* pguidObjectType,
  47. DWORD dwFlags,
  48. PSI_ACCESS *ppAccess,
  49. ULONG *pcAccesses,
  50. ULONG *piDefaultAccess );
  51. STDMETHOD(MapGeneric) (const GUID *pguidObjectType,
  52. UCHAR *pAceFlags,
  53. ACCESS_MASK *pMask);
  54. STDMETHOD(GetInheritTypes) (PSI_INHERIT_TYPE *ppInheritTypes,
  55. ULONG *pcInheritTypes );
  56. STDMETHOD(PropertySheetPageCallback)(HWND hwnd, UINT uMsg, SI_PAGE_TYPE uPage );
  57. private:
  58. CString m_strMachineName;
  59. CString m_strObjectName;
  60. SE_OBJECT_TYPE m_SeType;
  61. HINSTANCE m_hInstance;
  62. protected:
  63. // CResult * m_pData;
  64. BOOL m_bIsContainer;
  65. int m_flag;
  66. PSECURITY_DESCRIPTOR *m_ppSD;
  67. SECURITY_INFORMATION *m_pSeInfo;
  68. HRESULT NewDefaultDescriptor(
  69. PSECURITY_DESCRIPTOR* ppsd,
  70. SECURITY_INFORMATION RequestedInformation);
  71. // this will throw a memory exception where appropriate
  72. // HRESULT MakeSelfRelativeCopy(
  73. // PSECURITY_DESCRIPTOR psdOriginal,
  74. // PSECURITY_DESCRIPTOR* ppsdNew );
  75. public:
  76. // void Initialize(CResult *pData, int flag);
  77. // void Initialize(CResult *pData, PSECURITY_DESCRIPTOR *ppSeDescriptor=NULL, SECURITY_INFORMATION *pSeInfo=NULL, int flag=0);
  78. void Initialize(BOOL bIsContainer, PSECURITY_DESCRIPTOR *ppSeDescriptor=NULL, SECURITY_INFORMATION *pSeInfo=NULL, int flag=0);
  79. void SetMachineName( LPCTSTR pszMachineName );
  80. void SetObjectName( LPCTSTR pszObjectName ) { m_strObjectName = pszObjectName; }
  81. void SetTypeInstance(SE_OBJECT_TYPE SeType, HINSTANCE hInstance)
  82. { m_SeType = SeType; m_hInstance = hInstance; }
  83. LPTSTR QueryMachineName()
  84. {
  85. return (m_strMachineName.IsEmpty())
  86. ? NULL
  87. : const_cast<LPTSTR>((LPCTSTR)m_strMachineName);
  88. }
  89. LPTSTR QueryObjectName()
  90. {
  91. return const_cast<LPTSTR>((LPCTSTR)m_strObjectName);
  92. }
  93. };
  94. class CDsSecInfo : public ISecurityInformation, public CComObjectRoot
  95. {
  96. DECLARE_NOT_AGGREGATABLE(CDsSecInfo)
  97. BEGIN_COM_MAP(CDsSecInfo)
  98. COM_INTERFACE_ENTRY(ISecurityInformation)
  99. END_SEC_COM_MAP()
  100. public:
  101. CDsSecInfo()
  102. {
  103. m_dwRefCount = 0;
  104. m_pISecInfo = NULL;
  105. }
  106. virtual ~CDsSecInfo()
  107. {
  108. ASSERT(m_dwRefCount == 0); //bogus assertion.
  109. if (m_pISecInfo != NULL)
  110. m_pISecInfo->Release();
  111. }
  112. public:
  113. // *** IUnknown methods ***
  114. STDMETHOD(QueryInterface) (REFIID riid, LPVOID * ppvObj)
  115. {
  116. return m_pISecInfo->QueryInterface(riid, ppvObj);
  117. }
  118. STDMETHOD_(ULONG,AddRef) ()
  119. {
  120. m_dwRefCount++;
  121. return m_pISecInfo->AddRef();
  122. }
  123. STDMETHOD_(ULONG,Release) ()
  124. {
  125. m_dwRefCount--;
  126. // this might be the last release on the page holder
  127. // which would cause the holder to delete itself and
  128. // "this" in the process (i.e. "this" no more valid when
  129. // returning from the m_pPageHolder->Release() call
  130. ISecurityInformation* pISecInfo = m_pISecInfo;
  131. return pISecInfo->Release();
  132. }
  133. // *** ISecurityInformation methods ***
  134. STDMETHOD(GetObjectInformation) (PSI_OBJECT_INFO pObjectInfo )
  135. {
  136. return m_pISecInfo->GetObjectInformation(pObjectInfo);
  137. }
  138. STDMETHOD(GetAccessRights) (const GUID* pguidObjectType,
  139. DWORD dwFlags, // SI_EDIT_AUDITS, SI_EDIT_PROPERTIES
  140. PSI_ACCESS *ppAccess,
  141. ULONG *pcAccesses,
  142. ULONG *piDefaultAccess )
  143. {
  144. return m_pISecInfo->GetAccessRights(pguidObjectType,
  145. dwFlags,
  146. ppAccess,
  147. pcAccesses,
  148. piDefaultAccess);
  149. }
  150. STDMETHOD(MapGeneric) (const GUID *pguidObjectType,
  151. UCHAR *pAceFlags,
  152. ACCESS_MASK *pMask)
  153. {
  154. return m_pISecInfo->MapGeneric(pguidObjectType,
  155. pAceFlags,
  156. pMask);
  157. }
  158. STDMETHOD(GetInheritTypes) (PSI_INHERIT_TYPE *ppInheritTypes,
  159. ULONG *pcInheritTypes )
  160. {
  161. return m_pISecInfo->GetInheritTypes(ppInheritTypes,
  162. pcInheritTypes);
  163. }
  164. STDMETHOD(PropertySheetPageCallback)(HWND hwnd, UINT uMsg, SI_PAGE_TYPE uPage )
  165. {
  166. return m_pISecInfo->PropertySheetPageCallback(hwnd, uMsg, uPage);
  167. }
  168. // *** ISecurityInformation methods ***
  169. STDMETHOD(GetSecurity) (SECURITY_INFORMATION RequestedInformation,
  170. PSECURITY_DESCRIPTOR *ppSecurityDescriptor,
  171. BOOL fDefault );
  172. STDMETHOD(SetSecurity) (SECURITY_INFORMATION SecurityInformation,
  173. PSECURITY_DESCRIPTOR pSecurityDescriptor );
  174. private:
  175. DWORD m_dwRefCount;
  176. ISecurityInformation* m_pISecInfo; // interface pointer to the wrapped interface
  177. protected:
  178. int m_flag;
  179. PSECURITY_DESCRIPTOR *m_ppSD;
  180. SECURITY_INFORMATION *m_pSeInfo;
  181. public:
  182. // void Initialize(CResult *pData, int flag);
  183. HRESULT Initialize(LPTSTR LdapName, PFNDSCREATEISECINFO pfnCreateDsPage,
  184. PSECURITY_DESCRIPTOR *ppSeDescriptor=NULL, SECURITY_INFORMATION *pSeInfo=NULL, int flag=0);
  185. };
  186. typedef CDsSecInfo *LPDSSECINFO;
  187. INT_PTR MyCreateSecurityPage2(
  188. BOOL bIsContainer, //CResult *pData,
  189. PSECURITY_DESCRIPTOR *ppSeDescriptor,
  190. SECURITY_INFORMATION *pSeInfo,
  191. LPCTSTR ObjectName,
  192. SE_OBJECT_TYPE SeType,
  193. int flag,
  194. HWND hwndParent,
  195. BOOL bModeless);
  196. INT_PTR MyCreateDsSecurityPage(
  197. LPDSSECINFO *ppSI,
  198. PFNDSCREATEISECINFO pfnCreateDsPage,
  199. PSECURITY_DESCRIPTOR *ppSeDescriptor,
  200. SECURITY_INFORMATION *pSeInfo,
  201. LPCTSTR ObjectName,
  202. int flag,
  203. HWND hwndParent);
  204. #endif // ~__PERMPAGE_H_INCLUDED__