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.

187 lines
5.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990, 1991 **/
  4. /**********************************************************************/
  5. /*
  6. accperm.hxx
  7. Header file for the ACCPERM class
  8. FILE HISTORY:
  9. Johnl 01-Aug-1991 Created (class name stolen from RustanL)
  10. */
  11. #ifndef _ACCPERM_HXX_
  12. #define _ACCPERM_HXX_
  13. #include <bitfield.hxx>
  14. #include <slist.hxx>
  15. #include "perm.hxx"
  16. #include "aclconv.hxx"
  17. /* There are two different types of permissions, the SPECIAL permission
  18. * only shows up in the SPECIAL dialog. The GENERAL type of permissions
  19. * are (possibly) a conglomeration of the special permissions that allow
  20. * a high level name/grouping to be used.
  21. */
  22. #define PERMTYPE_SPECIAL 3
  23. #define PERMTYPE_GENERAL 4
  24. DECLARE_SLIST_OF(ACCESS_PERMISSION)
  25. DECLARE_SLIST_OF(AUDIT_PERMISSION)
  26. /*************************************************************************
  27. NAME: ACCPERM
  28. SYNOPSIS: This class manipulates lists of PERMISSION objects
  29. INTERFACE:
  30. PARENT:
  31. USES:
  32. CAVEATS:
  33. NOTES:
  34. HISTORY:
  35. Johnl 01-Aug-1991 Created
  36. **************************************************************************/
  37. class ACCPERM : public BASE
  38. {
  39. friend class LM_ACL_TO_PERM_CONVERTER ;
  40. friend class NT_ACL_TO_PERM_CONVERTER ;
  41. private:
  42. SLIST_OF(ACCESS_PERMISSION) _slAccessPerms ;
  43. SLIST_OF(AUDIT_PERMISSION) _slAuditPerms ;
  44. /* These iterators support the enumeration methods.
  45. */
  46. ITER_SL_OF(ACCESS_PERMISSION) _iterslAccessPerms ;
  47. ITER_SL_OF(AUDIT_PERMISSION) _iterslAuditPerms ;
  48. //
  49. // Due to the behaviour of remove with an iterator, after we delete
  50. // an item, we shouldn't do a next because the remove bumped the
  51. // iterator already.
  52. //
  53. BOOL _fDidDeleteAccessPerms ;
  54. BOOL _fDidDeleteAuditPerms ;
  55. ACL_TO_PERM_CONVERTER * _paclconverter ;
  56. protected:
  57. SLIST_OF(ACCESS_PERMISSION) * QueryAccessPermissionList( void )
  58. { return &_slAccessPerms ; }
  59. SLIST_OF(AUDIT_PERMISSION) * QueryAuditPermissionList( void )
  60. { return &_slAuditPerms ; }
  61. public:
  62. /* Constructor:
  63. * psubjectOwner is the owner of this object. Maybe NULL if the owner
  64. * concept is not supported.
  65. */
  66. ACCPERM( ACL_TO_PERM_CONVERTER * paclconverter ) ;
  67. /* Get all of the ACCESS permissions or AUDIT permissions that are
  68. * contained in the resources ACL.
  69. *
  70. * ppAccessPermission - Pointer to a pointer to an Access/Audit
  71. * PERMISSION object. The client should not
  72. * reallocate/delete this pointer. When there
  73. * are no more permissions, *ppAccessPermission
  74. * will be set to NULL and FALSE will be returned.
  75. *
  76. * pfFromBeginning - Restart the enumeration from the beginning of the
  77. * list if *pfFromBeginning is TRUE, will be set
  78. * to FALSE automatically.
  79. */
  80. BOOL EnumAccessPermissions( ACCESS_PERMISSION * * ppAccessPermission,
  81. BOOL * pfFromBeginning ) ;
  82. BOOL EnumAuditPermissions( AUDIT_PERMISSION * * ppAuditPermission,
  83. BOOL * pfFromBeginning ) ;
  84. /* Permission manipulation routines:
  85. *
  86. * DeletePermission - Removes the Access/Audit permission from the
  87. * permission list.
  88. * ChangePermission - Lets the ACCPERM class know a permission has
  89. * changed. Should be called after a permission
  90. * has been modified (this is for future support
  91. * when we may add "Advanced" permissions).
  92. * AddPermission - Adds a permission to the permission list that
  93. * was created by ACL_TO_PERM_CONVERTR::CreatePermission
  94. */
  95. BOOL DeletePermission( ACCESS_PERMISSION * paccessperm ) ;
  96. BOOL ChangePermission( ACCESS_PERMISSION * paccessperm ) ;
  97. APIERR AddPermission ( ACCESS_PERMISSION * paccessperm ) ;
  98. BOOL DeletePermission( AUDIT_PERMISSION * pauditperm ) ;
  99. BOOL ChangePermission( AUDIT_PERMISSION * pauditperm ) ;
  100. APIERR AddPermission ( AUDIT_PERMISSION * pauditperm ) ;
  101. /* These correspond exactly with the same named methods in the
  102. * ACL_TO_PERM_CONVERTER class in functionality and return codes and
  103. * are provided merely for convenience.
  104. */
  105. APIERR GetPermissions( BOOL fAccessPerms )
  106. { return QueryAclConverter()->GetPermissions( this, fAccessPerms ) ; }
  107. APIERR GetBlankPermissions( void )
  108. { return QueryAclConverter()->GetBlankPermissions( this ) ; }
  109. APIERR WritePermissions( BOOL fApplyToSubContainers,
  110. BOOL fApplyToSubObjects,
  111. TREE_APPLY_FLAGS applyflags,
  112. BOOL *pfReportError )
  113. { return QueryAclConverter()->WritePermissions( *this,
  114. fApplyToSubContainers,
  115. fApplyToSubObjects,
  116. applyflags,
  117. pfReportError ) ; }
  118. APIERR QueryFailingSubject( NLS_STR * pnlsSubjUniqueName )
  119. { return QueryAclConverter()->QueryFailingSubject( pnlsSubjUniqueName ) ; }
  120. ACL_TO_PERM_CONVERTER * QueryAclConverter( void ) const
  121. { return _paclconverter ; }
  122. /* This method finds the subject who's name corresponds to the
  123. * passed name, and expunges this subject from both the
  124. * Access permission list and the Audit permission list.
  125. */
  126. APIERR DeleteSubject( NLS_STR * pnlsSubjUniqueName ) ;
  127. /* Looks at the access permission list and determines if there are
  128. * any "Everyone (None)" permissions.
  129. */
  130. APIERR AnyDenyAllsToEveryone( BOOL *pfDenyAll ) ;
  131. /* Returns TRUE if the object is a container object
  132. */
  133. BOOL IsContainer( void )
  134. { return QueryAclConverter()->IsContainer() ; }
  135. /* The following are not const because QueryNumElem is not const (can't
  136. * be const).
  137. */
  138. UINT QueryAccessPermCount( void )
  139. { return QueryAccessPermissionList()->QueryNumElem() ; }
  140. UINT QueryAuditPermCount( void )
  141. { return QueryAuditPermissionList()->QueryNumElem() ; }
  142. } ;
  143. #endif // _ACCPERM_HXX_