home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / winnt / cacls / accacc.hxx < prev    next >
Text File  |  1995-03-13  |  5KB  |  158 lines

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