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.

187 lines
5.4 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // File: ACCACC.hxx
  4. //
  5. // Contents: class encapsulating NT security user ACCACC.
  6. //
  7. // Classes: CACCACC
  8. //
  9. // Functions:
  10. //
  11. // History: Nov-93 Created DaveMont
  12. //
  13. //--------------------------------------------------------------------
  14. #ifndef __ACCACC__
  15. #define __ACCACC__
  16. #include "t2.hxx"
  17. #include "account.hxx"
  18. //+-------------------------------------------------------------------
  19. //
  20. // Class: CAccountAccess
  21. //
  22. // Purpose: encapsulation of class Account and NT access masks. This
  23. // class interfaces with the security system to get SIDs from
  24. // usernames and vis-versa.
  25. //
  26. // this class has also been supplimented to contain information
  27. // about ACEs with the same SID in the ACL if a (edit) merge
  28. // operation is occuring
  29. //
  30. //--------------------------------------------------------------------
  31. class CAccountAccess: private CAccount
  32. {
  33. public:
  34. CAccountAccess(LPWSTR Name, LPWSTR System);
  35. ULONG Init(ULONG access, ULONG diraccess, BOOL filespecified);
  36. inline void ReInit();
  37. inline ULONG Sid(SID **psid);
  38. inline BYTE AceType();
  39. inline ACCESS_MASK AccessMask();
  40. inline ACCESS_MASK DirAccessMask();
  41. inline BOOL FileSpecified();
  42. inline void ClearAccessMask();
  43. void AddInheritance(BYTE Flags);
  44. inline ULONG TestInheritance();
  45. private:
  46. ACCESS_MASK _savemask; // saved requested mask (because _mask gets cleared if
  47. // the ace is not used).
  48. ACCESS_MASK _mask; // requested mask
  49. ACCESS_MASK _dirmask; // access mask for directories
  50. BOOL _filespecified;
  51. // set dir access without ACE for files
  52. BYTE _acetype;
  53. ULONG _foundinheritance; // contains the OR of all the inheritances from the original ACL
  54. };
  55. // this is used in conjunction with ACE inherit flags to indicate that access
  56. // rights in an ACE apply to the container as well
  57. #define APPLIES_TO_CONTAINER 0x4
  58. //+---------------------------------------------------------------------------
  59. //
  60. // Member: CAccountAccess::Init, public
  61. //
  62. // Synopsis: initializes access mask
  63. //
  64. // Arguments: IN [access] - access mask
  65. //
  66. //----------------------------------------------------------------------------
  67. void CAccountAccess::ReInit()
  68. {
  69. _mask = _savemask;
  70. }
  71. //+---------------------------------------------------------------------------
  72. //
  73. // Member: CAccountAccess::Sid, public
  74. //
  75. // Synopsis: returns the principal for the class
  76. //
  77. // Arguments: OUT [psid] - address of the principal name
  78. //
  79. //----------------------------------------------------------------------------
  80. ULONG CAccountAccess::Sid(SID **psid)
  81. {
  82. return(GetAccountSid(psid));
  83. }
  84. //+---------------------------------------------------------------------------
  85. //
  86. // Member: CAccountAccess::AceType, public
  87. //
  88. // Synopsis: returns the acetype (denied, allowed)
  89. //
  90. // Arguments: none
  91. //
  92. //----------------------------------------------------------------------------
  93. BYTE CAccountAccess::AceType()
  94. {
  95. return(_acetype);
  96. }
  97. //+---------------------------------------------------------------------------
  98. //
  99. // Member: CAccountAccess::AccessMask, public
  100. //
  101. // Synopsis: returns the access mask
  102. //
  103. // Arguments: none
  104. //
  105. //----------------------------------------------------------------------------
  106. ACCESS_MASK CAccountAccess::AccessMask()
  107. {
  108. return(_mask);
  109. }
  110. //+---------------------------------------------------------------------------
  111. //
  112. // Member: CAccountAccess::DirAccessMask, public
  113. //
  114. // Synopsis: returns the directory access mask
  115. //
  116. // Arguments: none
  117. //
  118. //----------------------------------------------------------------------------
  119. ACCESS_MASK CAccountAccess::DirAccessMask()
  120. {
  121. return(_dirmask);
  122. }
  123. //+---------------------------------------------------------------------------
  124. //
  125. // Member: CAccountAccess::FileSpecified, public
  126. //
  127. // Synopsis: returns if only Dir ACE should be set and no file ACE
  128. //
  129. // Arguments: none
  130. //
  131. //----------------------------------------------------------------------------
  132. BOOL CAccountAccess::FileSpecified()
  133. {
  134. return(_filespecified);
  135. }
  136. //+---------------------------------------------------------------------------
  137. //
  138. // Member: CAccountAccess::ClearAccessMask, public
  139. //
  140. // Synopsis: returns the access mask
  141. //
  142. // Arguments: none
  143. //
  144. //----------------------------------------------------------------------------
  145. void CAccountAccess::ClearAccessMask()
  146. {
  147. _mask = 0;
  148. }
  149. //+---------------------------------------------------------------------------
  150. //
  151. // Member: CAccountAccess::TestInheritance, public
  152. //
  153. // Synopsis: checks that the inheritance is valid,
  154. // that objects & containers inherit, and rights are applied to the object.
  155. //
  156. // Arguments: none
  157. //
  158. //--------------------------------------------------------------------
  159. ULONG CAccountAccess::TestInheritance()
  160. {
  161. if (_foundinheritance == ( OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | APPLIES_TO_CONTAINER))
  162. return(ERROR_SUCCESS);
  163. else
  164. return(ERROR_INVALID_DATA);
  165. }
  166. #endif // __ACCACC__