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.

264 lines
12 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. SecurityLib.h
  5. Abstract:
  6. This file contains the declaration of the classes responsible for managing
  7. security settings.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 03/22/2000
  10. created
  11. ******************************************************************************/
  12. #if !defined(__INCLUDED___PCH___SECURITYLIB_H___)
  13. #define __INCLUDED___PCH___SECURITYLIB_H___
  14. #include <MPC_security.h>
  15. ////////////////////////////////////////////////////////////////////////////////
  16. class CPCHSecurityDescriptorDirect : public MPC::SecurityDescriptor
  17. {
  18. public:
  19. static HRESULT ConvertACEFromCOM( /*[in]*/ IPCHAccessControlEntry* pObj, /*[out]*/ PACL& pACL );
  20. static HRESULT ConvertACEToCOM ( /*[in]*/ IPCHAccessControlEntry* pObj, /*[in ]*/ const LPVOID pACE );
  21. static HRESULT ConvertACLFromCOM( /*[in]*/ IPCHAccessControlList* pObj, /*[out]*/ PACL& pACL );
  22. static HRESULT ConvertACLToCOM ( /*[in]*/ IPCHAccessControlList* pObj, /*[in ]*/ const PACL pACL );
  23. public:
  24. HRESULT ConvertSDToCOM ( /*[in]*/ IPCHSecurityDescriptor* pObj );
  25. HRESULT ConvertSDFromCOM( /*[in]*/ IPCHSecurityDescriptor* pObj );
  26. };
  27. ////////////////////////////////////////////////////////////////////////////////
  28. class ATL_NO_VTABLE CPCHAccessControlEntry : // Hungarian: pchace
  29. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  30. public IDispatchImpl< IPCHAccessControlEntry, &IID_IPCHAccessControlEntry, &LIBID_HelpServiceTypeLib >
  31. {
  32. DWORD m_dwAccessMask;
  33. DWORD m_dwAceFlags;
  34. DWORD m_dwAceType;
  35. DWORD m_dwFlags;
  36. CComBSTR m_bstrTrustee;
  37. CComBSTR m_bstrObjectType;
  38. CComBSTR m_bstrInheritedObjectType;
  39. HRESULT LoadPost( /*[in]*/ MPC::XmlUtil& xml );
  40. HRESULT SavePre ( /*[in]*/ MPC::XmlUtil& xml );
  41. public:
  42. BEGIN_COM_MAP(CPCHAccessControlEntry)
  43. COM_INTERFACE_ENTRY(IDispatch)
  44. COM_INTERFACE_ENTRY(IPCHAccessControlEntry)
  45. END_COM_MAP()
  46. CPCHAccessControlEntry();
  47. virtual ~CPCHAccessControlEntry();
  48. public:
  49. // IPCHAccessControlEntry
  50. STDMETHOD(get_AccessMask )( /*[out, retval]*/ long *pVal );
  51. STDMETHOD(put_AccessMask )( /*[in ]*/ long newVal );
  52. STDMETHOD(get_AceType )( /*[out, retval]*/ long *pVal );
  53. STDMETHOD(put_AceType )( /*[in ]*/ long newVal );
  54. STDMETHOD(get_AceFlags )( /*[out, retval]*/ long *pVal );
  55. STDMETHOD(put_AceFlags )( /*[in ]*/ long newVal );
  56. STDMETHOD(get_Flags )( /*[out, retval]*/ long *pVal );
  57. STDMETHOD(put_Flags )( /*[in ]*/ long newVal );
  58. STDMETHOD(get_Trustee )( /*[out, retval]*/ BSTR *pVal );
  59. STDMETHOD(put_Trustee )( /*[in ]*/ BSTR newVal );
  60. STDMETHOD(get_ObjectType )( /*[out, retval]*/ BSTR *pVal );
  61. STDMETHOD(put_ObjectType )( /*[in ]*/ BSTR newVal );
  62. STDMETHOD(get_InheritedObjectType)( /*[out, retval]*/ BSTR *pVal );
  63. STDMETHOD(put_InheritedObjectType)( /*[in ]*/ BSTR newVal );
  64. STDMETHOD(IsEquivalent)( /*[in]*/ IPCHAccessControlEntry* pAce, /*[out, retval]*/ VARIANT_BOOL *pVal );
  65. STDMETHOD(Clone)( /*[out, retval]*/ IPCHAccessControlEntry* *pVal );
  66. STDMETHOD(LoadXML )( /*[in]*/ IXMLDOMNode* xdnNode );
  67. STDMETHOD(LoadXMLAsString)( /*[in]*/ BSTR bstrVal );
  68. STDMETHOD(LoadXMLAsStream)( /*[in]*/ IUnknown* pStream );
  69. STDMETHOD(SaveXML )( /*[in]*/ IXMLDOMNode* xdnRoot, /*[out, retval]*/ IXMLDOMNode* *pxdnNode );
  70. STDMETHOD(SaveXMLAsString)( /*[out, retval]*/ BSTR *bstrVal );
  71. STDMETHOD(SaveXMLAsStream)( /*[out, retval]*/ IUnknown* *pStream );
  72. };
  73. ////////////////////////////////////////////////////////////////////////////////
  74. class ATL_NO_VTABLE CPCHAccessControlList : // Hungarian: pchacl
  75. public MPC::CComCollection< IPCHAccessControlList, &LIBID_HelpServiceTypeLib, MPC::CComSafeMultiThreadModel>
  76. {
  77. DWORD m_dwAclRevision;
  78. HRESULT LoadPost( /*[in]*/ MPC::XmlUtil& xml );
  79. HRESULT SavePre ( /*[in]*/ MPC::XmlUtil& xml );
  80. public:
  81. BEGIN_COM_MAP(CPCHAccessControlList)
  82. COM_INTERFACE_ENTRY(IDispatch)
  83. COM_INTERFACE_ENTRY(IPCHAccessControlList)
  84. END_COM_MAP()
  85. CPCHAccessControlList();
  86. virtual ~CPCHAccessControlList();
  87. HRESULT CreateItem( /*[out]*/ CPCHAccessControlEntry* *entry );
  88. public:
  89. // IPCHAccessControlList
  90. STDMETHOD(get_AclRevision)( /*[out, retval]*/ long *pVal );
  91. STDMETHOD(put_AclRevision)( /*[in ]*/ long newVal );
  92. STDMETHOD(AddAce )( /*[in]*/ IPCHAccessControlEntry* pAccessControlEntry );
  93. STDMETHOD(RemoveAce)( /*[in]*/ IPCHAccessControlEntry* pAccessControlEntry );
  94. STDMETHOD(Clone)( /*[out, retval]*/ IPCHAccessControlList* *pVal );
  95. STDMETHOD(LoadXML )( /*[in]*/ IXMLDOMNode* xdnNode );
  96. STDMETHOD(LoadXMLAsString)( /*[in]*/ BSTR bstrVal );
  97. STDMETHOD(LoadXMLAsStream)( /*[in]*/ IUnknown* pStream );
  98. STDMETHOD(SaveXML )( /*[in]*/ IXMLDOMNode* xdnRoot, /*[out, retval]*/ IXMLDOMNode* *pxdnNode );
  99. STDMETHOD(SaveXMLAsString)( /*[out, retval]*/ BSTR *bstrVal );
  100. STDMETHOD(SaveXMLAsStream)( /*[out, retval]*/ IUnknown* *pStream );
  101. };
  102. ////////////////////////////////////////////////////////////////////////////////
  103. class ATL_NO_VTABLE CPCHSecurityDescriptor : // Hungarian: pchsd
  104. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  105. public IDispatchImpl< IPCHSecurityDescriptor, &IID_IPCHSecurityDescriptor, &LIBID_HelpServiceTypeLib >
  106. {
  107. DWORD m_dwRevision;
  108. DWORD m_dwControl;
  109. CComBSTR m_bstrOwner;
  110. bool m_fOwnerDefaulted;
  111. CComBSTR m_bstrGroup;
  112. bool m_fGroupDefaulted;
  113. CComPtr<IPCHAccessControlList> m_DACL;
  114. bool m_fDaclDefaulted;
  115. CComPtr<IPCHAccessControlList> m_SACL;
  116. bool m_fSaclDefaulted;
  117. HRESULT LoadPost( /*[in]*/ MPC::XmlUtil& xml );
  118. HRESULT SavePre ( /*[in]*/ MPC::XmlUtil& xml );
  119. public:
  120. BEGIN_COM_MAP(CPCHSecurityDescriptor)
  121. COM_INTERFACE_ENTRY(IDispatch)
  122. COM_INTERFACE_ENTRY(IPCHSecurityDescriptor)
  123. END_COM_MAP()
  124. CPCHSecurityDescriptor();
  125. virtual ~CPCHSecurityDescriptor();
  126. static HRESULT GetForFile ( /*[in]*/ LPCWSTR szFilename, /*[out, retval]*/ IPCHSecurityDescriptor* *psd );
  127. static HRESULT SetForFile ( /*[in]*/ LPCWSTR szFilename, /*[in ]*/ IPCHSecurityDescriptor* sd );
  128. static HRESULT GetForRegistry( /*[in]*/ LPCWSTR szKey , /*[out, retval]*/ IPCHSecurityDescriptor* *psd );
  129. static HRESULT SetForRegistry( /*[in]*/ LPCWSTR szKey , /*[in ]*/ IPCHSecurityDescriptor* sd );
  130. public:
  131. // IPCHSecurityDescriptor
  132. STDMETHOD(get_Revision )( /*[out, retval]*/ long *pVal );
  133. STDMETHOD(put_Revision )( /*[in ]*/ long newVal );
  134. STDMETHOD(get_Control )( /*[out, retval]*/ long *pVal );
  135. STDMETHOD(put_Control )( /*[in ]*/ long newVal );
  136. STDMETHOD(get_Owner )( /*[out, retval]*/ BSTR *pVal );
  137. STDMETHOD(put_Owner )( /*[in ]*/ BSTR newVal );
  138. STDMETHOD(get_OwnerDefaulted )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  139. STDMETHOD(put_OwnerDefaulted )( /*[in ]*/ VARIANT_BOOL newVal );
  140. STDMETHOD(get_Group )( /*[out, retval]*/ BSTR *pVal );
  141. STDMETHOD(put_Group )( /*[in ]*/ BSTR newVal );
  142. STDMETHOD(get_GroupDefaulted )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  143. STDMETHOD(put_GroupDefaulted )( /*[in ]*/ VARIANT_BOOL newVal );
  144. STDMETHOD(get_DiscretionaryAcl )( /*[out, retval]*/ IPCHAccessControlList* *pVal );
  145. STDMETHOD(put_DiscretionaryAcl )( /*[in ]*/ IPCHAccessControlList* newVal );
  146. STDMETHOD(get_DaclDefaulted )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  147. STDMETHOD(put_DaclDefaulted )( /*[in ]*/ VARIANT_BOOL newVal );
  148. STDMETHOD(get_SystemAcl )( /*[out, retval]*/ IPCHAccessControlList* *pVal );
  149. STDMETHOD(put_SystemAcl )( /*[in ]*/ IPCHAccessControlList* newVal );
  150. STDMETHOD(get_SaclDefaulted )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  151. STDMETHOD(put_SaclDefaulted )( /*[in ]*/ VARIANT_BOOL newVal );
  152. STDMETHOD(Clone)( /*[out, retval]*/ IPCHSecurityDescriptor* *pVal );
  153. STDMETHOD(LoadXML )( /*[in]*/ IXMLDOMNode* xdnNode );
  154. STDMETHOD(LoadXMLAsString)( /*[in]*/ BSTR bstrVal );
  155. STDMETHOD(LoadXMLAsStream)( /*[in]*/ IUnknown* pStream );
  156. STDMETHOD(SaveXML )( /*[in]*/ IXMLDOMNode* xdnRoot, /*[out, retval]*/ IXMLDOMNode* *pxdnNode );
  157. STDMETHOD(SaveXMLAsString)( /*[out, retval]*/ BSTR *bstrVal );
  158. STDMETHOD(SaveXMLAsStream)( /*[out, retval]*/ IUnknown* *pStream );
  159. };
  160. ////////////////////////////////////////////////////////////////////////////////
  161. class ATL_NO_VTABLE CPCHSecurity : // Hungarian: pchs
  162. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  163. public IDispatchImpl< IPCHSecurity, &IID_IPCHSecurity, &LIBID_HelpServiceTypeLib >
  164. {
  165. HRESULT CheckAccess( /*[in]*/ VARIANT& vDesiredAccess ,
  166. /*[in]*/ MPC::SecurityDescriptor& sd ,
  167. /*[out]*/ VARIANT_BOOL& retVal );
  168. public:
  169. BEGIN_COM_MAP(CPCHSecurity)
  170. COM_INTERFACE_ENTRY(IDispatch)
  171. COM_INTERFACE_ENTRY(IPCHSecurity)
  172. END_COM_MAP()
  173. ////////////////////////////////////////////////////////////////////////////////
  174. static CPCHSecurity* s_GLOBAL;
  175. static HRESULT InitializeSystem();
  176. static void FinalizeSystem ();
  177. ////////////////////////////////////////////////////////////////////////////////
  178. public:
  179. // IPCHSecurity
  180. STDMETHOD(CreateObject_SecurityDescriptor)( /*[out, retval]*/ IPCHSecurityDescriptor* *pSD );
  181. STDMETHOD(CreateObject_AccessControlList )( /*[out, retval]*/ IPCHAccessControlList * *pACL );
  182. STDMETHOD(CreateObject_AccessControlEntry)( /*[out, retval]*/ IPCHAccessControlEntry* *pACE );
  183. STDMETHOD(GetUserName )( /*[in]*/ BSTR bstrPrincipal, /*[out, retval]*/ BSTR *retVal );
  184. STDMETHOD(GetUserDomain )( /*[in]*/ BSTR bstrPrincipal, /*[out, retval]*/ BSTR *retVal );
  185. STDMETHOD(GetUserDisplayName)( /*[in]*/ BSTR bstrPrincipal, /*[out, retval]*/ BSTR *retVal );
  186. STDMETHOD(CheckCredentials)( /*[in]*/ BSTR bstrCredentials, /*[out, retval]*/ VARIANT_BOOL *retVal );
  187. STDMETHOD(CheckAccessToSD )( /*[in]*/ VARIANT vDesiredAccess, /*[in]*/ IPCHSecurityDescriptor* sd , /*[out, retval]*/ VARIANT_BOOL *retVal );
  188. STDMETHOD(CheckAccessToFile )( /*[in]*/ VARIANT vDesiredAccess, /*[in]*/ BSTR bstrFilename, /*[out, retval]*/ VARIANT_BOOL *retVal );
  189. STDMETHOD(CheckAccessToRegistry)( /*[in]*/ VARIANT vDesiredAccess, /*[in]*/ BSTR bstrKey , /*[out, retval]*/ VARIANT_BOOL *retVal );
  190. STDMETHOD(GetFileSD)( /*[in]*/ BSTR bstrFilename, /*[out, retval]*/ IPCHSecurityDescriptor* *psd );
  191. STDMETHOD(SetFileSD)( /*[in]*/ BSTR bstrFilename, /*[in] */ IPCHSecurityDescriptor* sd );
  192. STDMETHOD(GetRegistrySD)( /*[in]*/ BSTR bstrKey, /*[out, retval]*/ IPCHSecurityDescriptor* *psd );
  193. STDMETHOD(SetRegistrySD)( /*[in]*/ BSTR bstrKey, /*[in] */ IPCHSecurityDescriptor* sd );
  194. };
  195. #endif // !defined(__INCLUDED___PCH___SECURITYLIB_H___)