Source code of Windows XP (NT5)
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.

598 lines
22 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990, 1991 **/
  4. /**********************************************************************/
  5. /*
  6. SEDAPI.hxx
  7. This File contains the prototypes and descriptions for the interface to
  8. the generic security editor dialogs for NT objects.
  9. FILE HISTORY:
  10. Johnl 02-Aug-1991 Created
  11. Johnl 27-Dec-1991 Updated to reflect reality
  12. JohnL 25-Feb-1992 Nuked NewObjValidMask (new obj use generic/stan.
  13. only, Added GENERIC_MAPPING param.
  14. */
  15. #ifndef _SEDAPI_HXX_
  16. #define _SEDAPI_HXX_
  17. //
  18. // The following are status codes indicating the state of the permissions on
  19. // the resource we are setting permissions for.
  20. //
  21. #define SED_STATUS_MODIFIED (1)
  22. #define SED_STATUS_NOT_MODIFIED (2)
  23. #define SED_STATUS_NOT_ALL_MODIFIED (3)
  24. #define SED_STATUS_FAILED_TO_MODIFY (4)
  25. //
  26. // Current Security editor revision level.
  27. //
  28. #define SED_REVISION (1)
  29. #define SED_REVISION1 (1)
  30. //
  31. // This data type defines information related to a single class of object.
  32. // For example, a FILE object, or PRINT_QUEUE object would have a structure
  33. // like this defined.
  34. //
  35. typedef struct _SED_OBJECT_TYPE_DESCRIPTOR
  36. {
  37. //
  38. // The current revision level being used by the client. This is for
  39. // support in case structure definitions change. It should contain
  40. // the current revision supported.
  41. //
  42. UCHAR Revision ;
  43. //
  44. // Defines whether the object is a container or not.
  45. // TRUE indicates the object may contain other objects. Means the
  46. // user can Tree apply the permissions if desired.
  47. //
  48. BOOLEAN IsContainer;
  49. //
  50. // Defines whether "New Object" permissions can be assigned (i.e.,
  51. // a "New Object" is an object that will be created in the future).
  52. //
  53. // This field is ignored when editting Auditting permissions
  54. //
  55. BOOLEAN AllowNewObjectPerms ;
  56. //
  57. // A mask containing all valid access types for the object type.
  58. // Note that this mask is used to identify and create Deny All
  59. // ACEs.
  60. //
  61. ACCESS_MASK ValidAccessMask;
  62. //
  63. // The generic mapping for the object type.
  64. //
  65. // This is used for mapping the specific permissions to the generic
  66. // flags.
  67. //
  68. PGENERIC_MAPPING GenericMapping ;
  69. //
  70. // The (localized) name of the object type.
  71. // For example, "File", "Print Job" or "Directory".
  72. //
  73. LPTSTR ObjectTypeName;
  74. //
  75. // The (localized) title to display if protection/auditting can be applied
  76. // to sub-objects/sub-containers. This is essentially the Tree apply
  77. // option title.
  78. //
  79. // This string will be presented with a checkbox before it.
  80. // If this box is checked, then the callback entry point
  81. // will be called once if New objects are not supported. The
  82. // ApplyToSubContainers will be set to TRUE and ApplyToSubObjects
  83. // will be set to FALSE. If New objects are supported, then the
  84. // callback entry point will be called twice, once as just described,
  85. // and once with the ApplyToSubObjects set to TRUE and
  86. // ApplyToSubContainers set to FALSE. In each case, the security
  87. // descriptor will contain ACLs appropriate for the type of object
  88. // as determined by the SED_APPLICATION_ACCESSES defined by the client.
  89. //
  90. // This field is ignored if the IsContainer field is FALSE.
  91. //
  92. // As an example of how this field is used, the file browser may
  93. // specify the following string in the DIRECTORY object's
  94. // descriptor:
  95. //
  96. // "Replace Permissions on Existing Files/Subdirectories"
  97. //
  98. LPTSTR ApplyToSubContainerTitle;
  99. //
  100. // The (localized) text to display below the ApplyToSubContainerTitle
  101. // checkbox. This is simply explanatory text describing what will
  102. // happen if the user doesn't check the box.
  103. //
  104. // For directories, this text would be:
  105. //
  106. // "If this box is not checked, these permissions will apply
  107. // only to the directory and newly created
  108. // files/subdirectories."
  109. //
  110. LPTSTR ApplyToSubContainerHelpText ;
  111. //
  112. // The (localized) title to display in the "Type of Access" combo
  113. // that brings up the Special access dialog. This same title is
  114. // used for the title of this dialog except the "..." is stripped
  115. // from the end.
  116. //
  117. // This field is ignored if the System Acl editor was invoked.
  118. //
  119. // As an example of how this field is used, the file browser may
  120. // specify the following string in the DIRECTORY object's
  121. // descriptor:
  122. //
  123. // "Special Directory Access..."
  124. //
  125. LPTSTR SpecialObjectAccessTitle ;
  126. //
  127. // The (localized) title to display in the "Type of Access" combo
  128. // that brings up the Special new object access dialog. This same title
  129. // is used for the title of this dialog except the "..." is stripped
  130. // from the end.
  131. //
  132. // This item is required if AllowNewObjectPerms is TRUE, it is ignored
  133. // if AllowNewObjectPerms is FALSE or we are editting a SACL.
  134. //
  135. // As an example of how this field is used, the file browser may
  136. // specify the following string in the DIRECTORY object's
  137. // descriptor:
  138. //
  139. // "Special New File Access..."
  140. //
  141. LPTSTR SpecialNewObjectAccessTitle ;
  142. } SED_OBJECT_TYPE_DESCRIPTOR, *PSED_OBJECT_TYPE_DESCRIPTOR;
  143. //
  144. // It is desirable to display access names that are
  145. // meaningful in the context of the type of object whose ACL
  146. // is being worked on. For example, for a PRINT_QUEUE object type,
  147. // it may be desirable to display an access type named "Submit Print Jobs".
  148. // The following structures are used for defining these application defined
  149. // access groupings.
  150. //
  151. //
  152. // The following are the different permission description types that the user
  153. // will manipulate for setting permissions.
  154. //
  155. // SED_DESC_TYPE_RESOURCE - The SED_APPLICATION_ACCESS structure is describing
  156. // an object or container permission that will be displayed in the main
  157. // permissions listbox. These should be the permissions that the
  158. // user will use all the time and will generally be a conglomeration
  159. // of permissions (for example, "Edit" which would include Read, Write
  160. // and maybe delete).
  161. //
  162. // SED_DESC_TYPE_RESOURCE_SPECIAL - The structure is describing an object
  163. // or container permissions that will be displayed in the Special
  164. // access dialog. These are generally primitive permissions (such as
  165. // Read, Write, Execute, Set Permissions etc.). The permission names
  166. // will appear next to checkboxes, thus they should have the "&"
  167. // accelerator next to the appropriate letter.
  168. //
  169. // SED_DESC_TYPE_CONT_AND_NEW_OBJECT - The structure is describing a container
  170. // and new object permission that will be shown in the main permissions
  171. // listbox. The Container permission is contained in AccessMask1 and
  172. // the New Object resource is in AccessMask2. When the permission name
  173. // is selected by the user, the container access permissions *and* the
  174. // new object access permissions will be set to the corresponding access
  175. // mask. This is useful when inherittance can be used to set the New
  176. // Object Access permissions.
  177. //
  178. // SED_DESC_TYPE_NEW_OBJECT_SPECIAL - The structure is describing a new object
  179. // permission that will be shown in the Special New Object access
  180. // dialog. This is used the same way the SED_DESC_TYPE_RESOURCE_SPECIAL
  181. // type is used, that is, the permissions should be the primitive, per
  182. // bit permissions. The permission names
  183. // will appear next to checkboxes, thus they should have the "&"
  184. // accelerator next to the appropriate letter.
  185. //
  186. // SED_DESC_TYPE_AUDIT - The structure is describing an Audit access mask.
  187. // AccessMask1 contains the audit mask to be associated with the
  188. // permission title string. The title string will appear next to
  189. // a checkbox, thus they should have the "&" accelerator next to
  190. // the appropriate letter in the title string.
  191. //
  192. // Note that they cannot be freely intermixed, use the following table
  193. // as a guide for which ones to use where:
  194. //
  195. // IsContainer AllowNewObjectPerms
  196. // False False RESOURCE, RESOURCE_SPECIAL
  197. // True False RESOURCE, RESOURCE_SPECIAL
  198. // True True RESOURCE_SPECIAL, CONT_AND_NEW_OBJECT,
  199. // NEW_OBJECT_SPECIAL
  200. // True False SED_DESC_TYPE_AUDIT
  201. //
  202. // Note that in the third case (IsContainer && AllowNewObjectPerms) you
  203. // *cannot* use the RESOURCE permission description type, you must always
  204. // associate the permission on the resource with new object permissions.
  205. // If this is a problem, we can look at removing this obstacle.
  206. //
  207. #define SED_DESC_TYPE_RESOURCE (1)
  208. #define SED_DESC_TYPE_RESOURCE_SPECIAL (2)
  209. #define SED_DESC_TYPE_CONT_AND_NEW_OBJECT (3)
  210. #define SED_DESC_TYPE_NEW_OBJECT_SPECIAL (4)
  211. #define SED_DESC_TYPE_AUDIT (5)
  212. //
  213. // To describe the permissions to the ACL Editor, build an array consisting
  214. // of SED_APPLICATION_ACCESS structures. The use of each field is as follows:
  215. //
  216. // Type - Contains one of the SED_DESC_TYPE_* manifests, determines what the
  217. // rest of the fields in this structure mean. Specifically, if Type
  218. // equals:
  219. //
  220. // AccessMask1 AccessMask2 PermissionTitle
  221. // ============================================
  222. //SED_DESC_TYPE_RESOURCE Perm Not Used Name of this Perm
  223. //SED_DESC_TYPE_RESOURCE_SPECIAL Special Perm Not Used Name of this Perm
  224. //SED_DESC_TYPE_CONT_AND_NEW_OBJECT Perm Special Perm Name of this Perm
  225. //SED_DESC_TYPE_NEW_OBJECT_SPECIAL Special Perm Not Used Name of this Perm
  226. //SED_DESC_TYPE_AUDIT Audit Mask Not Used Name of this Audit mask
  227. //
  228. // AccessMask1 - Access mask to be associated with the PermissionTitle string,
  229. // see the table under Type for what this field contains.
  230. //
  231. // AccessMask2 - Either used for Special permissions or ignored.
  232. //
  233. // PermissionTitle - Title string this permission set is being associated with.
  234. typedef struct _SED_APPLICATION_ACCESS
  235. {
  236. UINT Type ;
  237. ACCESS_MASK AccessMask1 ;
  238. ACCESS_MASK AccessMask2 ;
  239. LPTSTR PermissionTitle ;
  240. } SED_APPLICATION_ACCESS, *PSED_APPLICATION_ACCESS;
  241. typedef struct _SED_APPLICATION_ACCESSES
  242. {
  243. //
  244. // The count field indicates how many application defined access groupings
  245. // are defined by this data structure. The AccessGroup[] array then
  246. // contains that number of elements.
  247. //
  248. ULONG Count;
  249. PSED_APPLICATION_ACCESS AccessGroup ;
  250. } SED_APPLICATION_ACCESSES, *PSED_APPLICATION_ACCESSES ;
  251. /*++
  252. Routine Description:
  253. This routine is provided by a caller of the graphical ACL editor.
  254. It is called by the ACL editor to apply security/auditting info to
  255. target object(s) when requested by the user.
  256. Parameters:
  257. CallbackContext - This is the value passed as the CallbackContext argument
  258. to the SedDiscretionaryAclEditor() or SedSystemAclEditor api when
  259. the graphical editor was invoked.
  260. SecDesc - This parameter points to a security descriptor
  261. that should be applied to this object/container and optionally
  262. sub-containers if the user selects the apply to tree option.
  263. SecDescNewObjects - This parameter is used only when operating on a
  264. resource that is a container and supports new objects (for
  265. example, directories). If the user chooses the apply to tree option,
  266. then this security descriptor will have all of the "New Object"
  267. permission ACEs contained in the primary container and the inherit
  268. bits will be set appropriately.
  269. ApplyToSubContainers - When TRUE, indicates that Dacl/Sacl is to be applied
  270. to sub-containers of the target container as well as the target container.
  271. This will only be TRUE if the target object is a container object.
  272. ApplyToSubObjects - When TRUE, indicates the Dacl/Sacl is to be applied to
  273. sub-objects of the target object. This will only be TRUE if
  274. the target object is a container object and supports new objects.
  275. The SecDescNewObjects should be used for applying the permissions
  276. in this instance.
  277. StatusReturn - This status flag indicates what condition the
  278. resources permissions were left in after an error occurred.
  279. SED_STATUS_MODIFIED - This (success) status code indicates the
  280. protection has successfully been modified.
  281. SED_STATUS_NOT_ALL_MODIFIED - This (warning) status code
  282. indicates an attempt to modify the resource permissions
  283. has only partially succeeded.
  284. SED_STATUS_FAILED_TO_MODIFY - This (error) status code indicates
  285. an attempt to modify the permissions has failed completely.
  286. Return Status:
  287. The return code is a standard Win32 error code or Lan Manager Network
  288. error code if a failure occurred, 0 if successful.
  289. --*/
  290. typedef DWORD (*PSED_FUNC_APPLY_SEC_CALLBACK)(
  291. ULONG_PTR CallbackContext,
  292. PSECURITY_DESCRIPTOR SecDesc,
  293. PSECURITY_DESCRIPTOR SecDescNewObjects,
  294. BOOLEAN ApplyToSubContainers,
  295. BOOLEAN ApplyToSubObjects,
  296. LPDWORD StatusReturn
  297. ) ;
  298. /*++
  299. Routine Description:
  300. This routine invokes the graphical Discretionary ACL editor DLL. The
  301. graphical DACL editor may be used to modify or create:
  302. - A default Discretionary ACL
  303. - A Discretionary ACL for a particular type of object.
  304. - A Discretionary ACL for a particular named instance of an
  305. object.
  306. Additionally, in the case where the ACl is that of a named object
  307. instance, and that object may contain other object instances, the
  308. user will be presented with the opportunity to apply the protection
  309. to the entire sub-tree of objects.
  310. If an error occurs, the user will be properly notified by the ACL
  311. editor.
  312. Parameters:
  313. Owner - Handle of the owner window the security editor should use for
  314. dialog creation and error messages. This will lock down the passed
  315. window.
  316. Server - The server name in the form "\\server" that the resource resides
  317. on. This is used for adding users, groups and aliases to the
  318. DACL and SACL. NULL indicates the local machine.
  319. ObjectType - This parameter is used to specify information
  320. about the type of object whose security is being edited. If the
  321. security does not relate to an instance of an object (such as for
  322. when default protection is being established), then NULL should be
  323. passed.
  324. ApplicationAccesses - This parameter is used to specify
  325. groupings of access types when operating
  326. on security for the specified object type. For example, it may be
  327. useful to define an access type called "Submit Print Job" for a
  328. PRINT_QUEUE class of object.
  329. ObjectName - This optional parameter is used to pass the name of the
  330. object whose security is being edited. If the security does not
  331. relate to an instance of an object (such as for when default
  332. protection is being established), then NULL should be passed.
  333. This parameter is ignored if the ObjectType parameter is not passed.
  334. ApplySecurityCallbackRoutine - This parameter is used to provide the
  335. address of a routine to be called to apply security to either the
  336. object specified, or, in the case that the object is a container,
  337. to sub-containers or sub-non-containers of that object.
  338. CallbackContext - This value is opaque to the DACL editor. Its only
  339. purpose is so that a context value may be passed back to the
  340. application via the ApplySecurityCallbackRoutine when that routine
  341. is invoked. This may be used by the application to re-locate
  342. context related to the edit session. For example, it may be a
  343. handle to the object whose security is being edited.
  344. SecurityDescriptor - This parameter points to a security descriptor
  345. containing the current discretionary ACL of the object. This
  346. security descriptor may, but does not have to, contain the owner
  347. and group of that object as well. Note that the security descriptor's
  348. DaclPresent flag may be FALSE, indicating either that the object
  349. had no protection, or that the user couldn't read the protection.
  350. This security descriptor will not be modified by the ACL editor.
  351. CouldntReadDacl - This boolean flag may be used to indicate that the
  352. user does not have read access to the target object's discretionary
  353. acl. In this case, a warning
  354. to the user will be presented along with the option to continue
  355. or cancel.
  356. Presumably the user does have write access to the DACL or
  357. there is no point in activating the editor.
  358. SEDStatusReturn - This status flag indicates what condition the
  359. resources permissions were left in after the ACL editor was
  360. dismissed. It may be one of:
  361. SED_STATUS_MODIFIED - This (success) status code indicates the
  362. editor has been exited and protection has successfully been
  363. modified.
  364. SED_STATUS_NOT_MODIFIED - This (success) status code indicates
  365. the editor has been exited without attempting to modify the
  366. protection.
  367. SED_STATUS_NOT_ALL_MODIFIED - This (warning) status code indicates
  368. the user requested the protection to be modified, but an attempt
  369. to do so only partially succeeded. The user has been notified
  370. of this situation.
  371. SED_STATUS_FAILED_TO_MODIFY - This (error) status code indicates
  372. the user requested the protection to be modified, but an
  373. attempt to do so has failed. The user has been notified of
  374. this situation.
  375. Return Code:
  376. A standard windows error return such as ERROR_NOT_ENOUGH_MEMORY. This
  377. means the ACL editor was never displayed. The user will be notified
  378. of the error before this procedure returns.
  379. --*/
  380. DWORD
  381. SedDiscretionaryAclEditor(
  382. HWND Owner,
  383. LPTSTR Server,
  384. PSED_OBJECT_TYPE_DESCRIPTOR ObjectType,
  385. PSED_APPLICATION_ACCESSES ApplicationAccesses,
  386. LPTSTR ObjectName,
  387. PSED_FUNC_APPLY_SEC_CALLBACK ApplySecurityCallbackRoutine,
  388. ULONG_PTR CallbackContext,
  389. PSECURITY_DESCRIPTOR SecurityDescriptor,
  390. BOOLEAN CouldntReadDacl,
  391. LPDWORD SEDStatusReturn
  392. ) ;
  393. //
  394. // The parameters for the SACL editor are exactly the same except where
  395. // noted as that of the SedDiscretionaryAclEditor.
  396. //
  397. DWORD
  398. SedSystemAclEditor(
  399. HWND Owner,
  400. LPTSTR Server,
  401. PSED_OBJECT_TYPE_DESCRIPTOR ObjectType,
  402. PSED_APPLICATION_ACCESSES ApplicationAccesses,
  403. LPTSTR ObjectName,
  404. PSED_FUNC_APPLY_SEC_CALLBACK ApplySecurityCallbackRoutine,
  405. ULONG_PTR CallbackContext,
  406. PSECURITY_DESCRIPTOR SecurityDescriptor,
  407. BOOLEAN CouldntReadSacl,
  408. LPDWORD SEDStatusReturn
  409. ) ;
  410. /*++
  411. Routine Description:
  412. This routine invokes the take ownership dialog which is used
  413. to view and/or set the owner of a security descriptor. The current owner
  414. is displayed along with an optional button for the currently logged
  415. on user to take ownership.
  416. If an error occurs, the user will be properly notified by the API.
  417. Parameters:
  418. Owner - Handle of the owner window the security editor should use for
  419. dialog creation and error messages. This will lock down the passed
  420. window.
  421. Server - The server name in the form "\\server" that the resource resides
  422. on. This may eventually be used for setting the owner to
  423. external groups. NULL indicates the local machine. This parameter
  424. is not currently used.
  425. ObjectTypeName - NT Resource type of object the user wants to look
  426. at the owner of.
  427. Examples for this parameter would be "File", "Directory"
  428. or "Files/Directories".
  429. ObjectName - This parameter is used to pass the name of the
  430. object whose security is being edited. This might be
  431. "C:\status.doc" or some other qualified name.
  432. CountOfObjects - The number of objects the user wants to change permissions
  433. on. If this number is greater then one, then the ObjectName is
  434. ignored and a message of the form "%d ObjectTypeName Selected".
  435. ApplySecurityCallbackRoutine - This parameter is used to provide the
  436. address of a routine to be called to apply the new security
  437. descriptor. The flags in the PSED_FUNC_APPLY_SEC_CALLBACK
  438. type are not used.
  439. CallbackContext - This value is opaque to this API. Its only
  440. purpose is so that a context value may be passed back to the
  441. application via the ApplySecurityCallbackRoutine when that routine
  442. is invoked. This may be used by the application to re-locate
  443. context related to the edit session. For example, it may be a
  444. handle to the object whose security is being edited.
  445. SecurityDescriptor - This parameter points to a security descriptor
  446. containing the current owner. May be NULL if CountOfObjects is
  447. greater then one because the Current Owner field is not displayed
  448. if CountOfObjects is greater then one.
  449. CouldntReadDacl - This boolean flag may be used to indicate that the
  450. user does not have read access to the target object's discretionary
  451. acl. In this case, a warning
  452. to the user will be presented along with the option to continue
  453. or cancel.
  454. Presumably the user does have write access to the owner or
  455. there is no point in activating the editor.
  456. SEDStatusReturn - This status flag indicates what condition the
  457. resources security descriptor were left in after the take ownership
  458. dialog was dismissed. It may be one of:
  459. SED_STATUS_MODIFIED - This (success) status code indicates the
  460. dialog has been exited and the new owner has successfully been
  461. modified.
  462. SED_STATUS_NOT_MODIFIED - This (success) status code indicates
  463. the dialog has been exited without attempting to modify the
  464. owner.
  465. SED_STATUS_NOT_ALL_MODIFIED - This (warning) status code indicates
  466. the user requested the owner to be modified, but an attempt
  467. to do so only partially succeeded. The user has been notified
  468. of this situation.
  469. SED_STATUS_FAILED_TO_MODIFY - This (error) status code indicates
  470. the user requested the owner to be modified, but an
  471. attempt to do so has failed. The user has been notified of
  472. this situation.
  473. Return Code:
  474. A standard windows error return such as ERROR_NOT_ENOUGH_MEMORY. This
  475. means the dialog was never displayed. The user will be notified
  476. of the error before this procedure returns.
  477. --*/
  478. DWORD
  479. SedTakeOwnership(
  480. HWND Owner,
  481. LPTSTR Server,
  482. LPTSTR ObjectTypeName,
  483. LPTSTR ObjectName,
  484. UINT CountOfObjects,
  485. PSED_FUNC_APPLY_SEC_CALLBACK ApplySecurityCallbackRoutine,
  486. ULONG_PTR CallbackContext,
  487. PSECURITY_DESCRIPTOR SecurityDescriptor,
  488. BOOLEAN CouldntReadOwner,
  489. LPDWORD SEDStatusReturn
  490. ) ;
  491. #endif //_SEDAPI_HXX_