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.

277 lines
9.3 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // AclBase.h
  7. //
  8. // Description:
  9. // Implementation of the ISecurityInformation interface. This interface
  10. // is the new common security UI in NT 5.0.
  11. //
  12. // Implementation File:
  13. // AclBase.cpp
  14. //
  15. // Author:
  16. // Galen Barbee (galenb) February 6, 1998
  17. // From \nt\private\admin\snapin\filemgmt\permpage.h
  18. // by JonN
  19. //
  20. // Revision History:
  21. //
  22. // Notes:
  23. //
  24. /////////////////////////////////////////////////////////////////////////////
  25. #ifndef _ACLBASE_H
  26. #define _ACLBASE_H
  27. /////////////////////////////////////////////////////////////////////////////
  28. // Include Files
  29. /////////////////////////////////////////////////////////////////////////////
  30. #ifndef _ACLUI_H_
  31. #include <aclui.h> // for ISecurityInformation
  32. #endif // _ACLUI_H_
  33. #include "CluAdmEx.h"
  34. #include <ObjSel.h>
  35. //
  36. // Stuff used for initializing the Object Picker below
  37. //
  38. #define DSOP_FILTER_COMMON1 ( DSOP_FILTER_INCLUDE_ADVANCED_VIEW \
  39. | DSOP_FILTER_USERS \
  40. | DSOP_FILTER_UNIVERSAL_GROUPS_SE \
  41. | DSOP_FILTER_GLOBAL_GROUPS_SE \
  42. | DSOP_FILTER_COMPUTERS \
  43. )
  44. #define DSOP_FILTER_COMMON2 ( DSOP_FILTER_COMMON1 \
  45. | DSOP_FILTER_WELL_KNOWN_PRINCIPALS \
  46. | DSOP_FILTER_DOMAIN_LOCAL_GROUPS_SE \
  47. )
  48. #define DSOP_FILTER_COMMON3 ( DSOP_FILTER_COMMON2 \
  49. | DSOP_FILTER_BUILTIN_GROUPS \
  50. )
  51. #define DSOP_FILTER_DL_COMMON1 ( DSOP_DOWNLEVEL_FILTER_USERS \
  52. | DSOP_DOWNLEVEL_FILTER_GLOBAL_GROUPS \
  53. )
  54. #define DSOP_FILTER_DL_COMMON2 ( DSOP_FILTER_DL_COMMON1 \
  55. | DSOP_DOWNLEVEL_FILTER_ALL_WELLKNOWN_SIDS \
  56. )
  57. #define DSOP_FILTER_DL_COMMON3 ( DSOP_FILTER_DL_COMMON2 \
  58. | DSOP_DOWNLEVEL_FILTER_LOCAL_GROUPS \
  59. )
  60. //
  61. // Documentation of the DSOP_SCOPE_INIT_INFO struct so you can see how the macros below
  62. // fill it in...
  63. //
  64. /*
  65. { // DSOP_SCOPE_INIT_INFO
  66. cbSize,
  67. flType,
  68. flScope,
  69. { // DSOP_FILTER_FLAGS
  70. { // DSOP_UPLEVEL_FILTER_FLAGS
  71. flBothModes,
  72. flMixedModeOnly,
  73. flNativeModeOnly
  74. },
  75. flDownlevel
  76. },
  77. pwzDcName,
  78. pwzADsPath,
  79. hr // OUT
  80. }
  81. */
  82. #define DECLARE_SCOPE(t,f,b,m,n,d) \
  83. { sizeof(DSOP_SCOPE_INIT_INFO), (t), (f|DSOP_SCOPE_FLAG_DEFAULT_FILTER_GROUPS|DSOP_SCOPE_FLAG_DEFAULT_FILTER_USERS), { { (b), (m), (n) }, (d) }, NULL, NULL, S_OK }
  84. //
  85. // The domain to which the target computer is joined.
  86. // Make 2 scopes, one for uplevel domains, the other for downlevel.
  87. //
  88. #define JOINED_DOMAIN_SCOPE(f) \
  89. DECLARE_SCOPE(DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN,(f),0,(DSOP_FILTER_COMMON2 & ~(DSOP_FILTER_UNIVERSAL_GROUPS_SE|DSOP_FILTER_DOMAIN_LOCAL_GROUPS_SE)),DSOP_FILTER_COMMON2,0), \
  90. DECLARE_SCOPE(DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN,(f),0,0,0,DSOP_FILTER_DL_COMMON2)
  91. //
  92. // The domain for which the target computer is a Domain Controller.
  93. // Make 2 scopes, one for uplevel domains, the other for downlevel.
  94. //
  95. #define JOINED_DOMAIN_SCOPE_DC(f) \
  96. DECLARE_SCOPE(DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN,(f),0,(DSOP_FILTER_COMMON3 & ~DSOP_FILTER_UNIVERSAL_GROUPS_SE),DSOP_FILTER_COMMON3,0), \
  97. DECLARE_SCOPE(DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN,(f),0,0,0,DSOP_FILTER_DL_COMMON3)
  98. //
  99. // Target computer scope. Computer scopes are always treated as
  100. // downlevel (i.e., they use the WinNT provider).
  101. //
  102. #define TARGET_COMPUTER_SCOPE(f)\
  103. DECLARE_SCOPE(DSOP_SCOPE_TYPE_TARGET_COMPUTER,(f),0,0,0,DSOP_FILTER_DL_COMMON3)
  104. //
  105. // The Global Catalog
  106. //
  107. #define GLOBAL_CATALOG_SCOPE(f) \
  108. DECLARE_SCOPE(DSOP_SCOPE_TYPE_GLOBAL_CATALOG,(f),DSOP_FILTER_COMMON1|DSOP_FILTER_WELL_KNOWN_PRINCIPALS,0,0,0)
  109. //
  110. // The domains in the same forest (enterprise) as the domain to which
  111. // the target machine is joined. Note these can only be DS-aware
  112. //
  113. #define ENTERPRISE_SCOPE(f) \
  114. DECLARE_SCOPE(DSOP_SCOPE_TYPE_ENTERPRISE_DOMAIN,(f),DSOP_FILTER_COMMON1,0,0,0)
  115. //
  116. // Domains external to the enterprise but trusted directly by the
  117. // domain to which the target machine is joined.
  118. //
  119. #define EXTERNAL_SCOPE(f) \
  120. DECLARE_SCOPE(DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN|DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN,\
  121. (f),DSOP_FILTER_COMMON1,0,0,DSOP_DOWNLEVEL_FILTER_USERS|DSOP_DOWNLEVEL_FILTER_GLOBAL_GROUPS)
  122. //
  123. // Workgroup scope. Only valid if the target computer is not joined
  124. // to a domain.
  125. //
  126. #define WORKGROUP_SCOPE(f) \
  127. DECLARE_SCOPE(DSOP_SCOPE_TYPE_WORKGROUP,(f),0,0,0, DSOP_FILTER_DL_COMMON1|DSOP_DOWNLEVEL_FILTER_LOCAL_GROUPS )
  128. //
  129. // Array of Default Scopes
  130. //
  131. static const DSOP_SCOPE_INIT_INFO g_aDefaultScopes[] =
  132. {
  133. JOINED_DOMAIN_SCOPE(DSOP_SCOPE_FLAG_STARTING_SCOPE),
  134. TARGET_COMPUTER_SCOPE(0),
  135. GLOBAL_CATALOG_SCOPE(0),
  136. ENTERPRISE_SCOPE(0),
  137. EXTERNAL_SCOPE(0),
  138. };
  139. //
  140. // Same as above, but without the Target Computer. Used when the target is a Domain Controller.
  141. //
  142. //
  143. // KB: 21-MAY-2002 GalenB
  144. //
  145. // This array of scopes is not currently being used since these scopes are only interestng for a mixed mode
  146. // domain where all of the member nodes of the cluster are domain controllers or backup domain controllers.
  147. // This is the only configuration where domain local groups can be used in a cluster SD when the default
  148. // scopes above will not allow the user to pick them.
  149. //
  150. /*
  151. static const DSOP_SCOPE_INIT_INFO g_aDCScopes[] =
  152. {
  153. JOINED_DOMAIN_SCOPE_DC(DSOP_SCOPE_FLAG_STARTING_SCOPE),
  154. GLOBAL_CATALOG_SCOPE(0),
  155. ENTERPRISE_SCOPE(0),
  156. EXTERNAL_SCOPE(0),
  157. };
  158. */
  159. /////////////////////////////////////////////////////////////////////////////
  160. // Forward Class Declarations
  161. /////////////////////////////////////////////////////////////////////////////
  162. class CSecurityInformation;
  163. /////////////////////////////////////////////////////////////////////////////
  164. // External Class Declarations
  165. /////////////////////////////////////////////////////////////////////////////
  166. /////////////////////////////////////////////////////////////////////////////
  167. // CSecurityInformation security wrapper
  168. /////////////////////////////////////////////////////////////////////////////
  169. class CSecurityInformation : public ISecurityInformation, public CComObjectRoot, public IDsObjectPicker
  170. {
  171. DECLARE_NOT_AGGREGATABLE(CSecurityInformation)
  172. BEGIN_COM_MAP(CSecurityInformation)
  173. COM_INTERFACE_ENTRY(ISecurityInformation)
  174. COM_INTERFACE_ENTRY(IDsObjectPicker)
  175. END_COM_MAP()
  176. #ifndef END_COM_MAP_ADDREF
  177. // *** IUnknown methods ***
  178. STDMETHOD_(ULONG, AddRef)( void )
  179. {
  180. return InternalAddRef();
  181. }
  182. STDMETHOD_(ULONG, Release)( void )
  183. {
  184. ULONG l = InternalRelease();
  185. if (l == 0)
  186. {
  187. delete this;
  188. }
  189. return l;
  190. }
  191. #endif
  192. // *** ISecurityInformation methods ***
  193. STDMETHOD(GetObjectInformation)( PSI_OBJECT_INFO pObjectInfo );
  194. STDMETHOD(GetSecurity)( SECURITY_INFORMATION RequestedInformation,
  195. PSECURITY_DESCRIPTOR * ppSecurityDescriptor,
  196. BOOL fDefault ) = 0;
  197. STDMETHOD(SetSecurity)( SECURITY_INFORMATION SecurityInformation,
  198. PSECURITY_DESCRIPTOR pSecurityDescriptor );
  199. STDMETHOD(GetAccessRights)( const GUID * pguidObjectType,
  200. DWORD dwFlags,
  201. PSI_ACCESS * ppAccess,
  202. ULONG * pcAccesses,
  203. ULONG * piDefaultAccess );
  204. STDMETHOD(MapGeneric)( const GUID * pguidObjectType,
  205. UCHAR * pAceFlags,
  206. ACCESS_MASK * pMask );
  207. STDMETHOD(GetInheritTypes)( PSI_INHERIT_TYPE * ppInheritTypes,
  208. ULONG * pcInheritTypes );
  209. STDMETHOD(PropertySheetPageCallback)( HWND hwnd, UINT uMsg, SI_PAGE_TYPE uPage );
  210. // IDsObjectPicker
  211. STDMETHODIMP Initialize( PDSOP_INIT_INFO pInitInfo );
  212. STDMETHODIMP InvokeDialog( HWND hwndParent, IDataObject ** ppdoSelection );
  213. protected:
  214. CSecurityInformation( void );
  215. ~CSecurityInformation( void );
  216. HRESULT HrLocalAccountsInSD( IN PSECURITY_DESCRIPTOR pSD, OUT PBOOL pFound );
  217. PGENERIC_MAPPING m_pShareMap;
  218. PSI_ACCESS m_psiAccess;
  219. int m_nDefAccess;
  220. int m_nAccessElems;
  221. DWORD m_dwFlags;
  222. CString m_strServer;
  223. CString m_strNode;
  224. int m_nLocalSIDErrorMessageID;
  225. IDsObjectPicker * m_pObjectPicker;
  226. LONG m_cRef;
  227. };
  228. #endif //_ACLBASE_H