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.

267 lines
7.6 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993 - 1995.
  5. //
  6. // File: ACCACC.hxx
  7. //
  8. // Contents: class encapsulating NT security user ACCACC.
  9. //
  10. // Classes: CAccountAccess
  11. //
  12. // History: Nov-93 Created DaveMont
  13. //
  14. //--------------------------------------------------------------------
  15. #ifndef __ACCACC__
  16. #define __ACCACC__
  17. //+-------------------------------------------------------------------
  18. //
  19. // Class: CAccountAccess
  20. //
  21. // Purpose: encapsulation of class Account and NT access masks. Results
  22. // in an ACE. This
  23. // class interfaces with the security system to get SIDs from
  24. // usernames and vis-versa.
  25. //
  26. //--------------------------------------------------------------------
  27. class CAccountAccess
  28. {
  29. public:
  30. CAccountAccess();
  31. ~CAccountAccess();
  32. void * operator new(size_t size);
  33. void operator delete(void * p, size_t size);
  34. DWORD Init(LPWSTR name,
  35. LPWSTR system,
  36. ACCESS_MODE accessmode,
  37. ACCESS_MASK accessmask,
  38. DWORD aceflags,
  39. BOOL fSaveName);
  40. DWORD Init(PSID psid,
  41. LPWSTR system,
  42. ACCESS_MODE accessmode,
  43. ACCESS_MASK accessmask,
  44. DWORD aceflags,
  45. BOOL fSaveSid);
  46. DWORD Clone(CAccountAccess **clone);
  47. DWORD LookupName(LPWSTR *name);
  48. DWORD SetImpersonateSid(PSID psid);
  49. DWORD SetImpersonateName(LPWSTR name);
  50. inline PSID Sid();
  51. inline LPWSTR Name();
  52. inline LPWSTR Domain();
  53. inline ACCESS_MODE AccessMode();
  54. inline ACCESS_MASK AccessMask();
  55. inline DWORD AceFlags();
  56. inline SID_NAME_USE SidType();
  57. inline VOID SetAccessMask(ACCESS_MASK accessmask);
  58. inline VOID SetAccessMode(ACCESS_MODE accessmode);
  59. inline VOID SetAceFlags(DWORD aceflags);
  60. inline PSID ImpersonateSid();
  61. inline LPWSTR ImpersonateName();
  62. inline MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation();
  63. private:
  64. LPWSTR _principal;
  65. LPWSTR _system;
  66. LPWSTR _domain;
  67. PSID _psid;
  68. ACCESS_MASK _accessmask;
  69. ACCESS_MODE _accessmode;
  70. DWORD _aceflags;
  71. SID_NAME_USE _esidtype;
  72. BOOL _freedomain;
  73. BOOL _freename;
  74. BOOL _freesid;
  75. PSID _pimpersonatesid;
  76. LPWSTR _pimpersonatename;
  77. MULTIPLE_TRUSTEE_OPERATION _multipletrusteeoperation;
  78. };
  79. //+---------------------------------------------------------------------------
  80. //
  81. // Member: CAccountAccess::SID, public
  82. //
  83. // Synopsis: returns the principal for the class
  84. //
  85. // Arguments: OUT [psid] - address of the principal name
  86. //
  87. //----------------------------------------------------------------------------
  88. PSID CAccountAccess::Sid()
  89. {
  90. return(_psid);
  91. }
  92. //+---------------------------------------------------------------------------
  93. //
  94. // Member: CAccountAccess::SID, public
  95. //
  96. // Synopsis: returns the principal for the class
  97. //
  98. // Arguments: OUT [psid] - address of the principal name
  99. //
  100. //----------------------------------------------------------------------------
  101. LPWSTR CAccountAccess::Domain()
  102. {
  103. return(_domain);
  104. }
  105. //+---------------------------------------------------------------------------
  106. //
  107. // Member: CAccountAccess::SID, public
  108. //
  109. // Synopsis: returns the principal for the class
  110. //
  111. // Arguments: OUT [psid] - address of the principal name
  112. //
  113. //----------------------------------------------------------------------------
  114. LPWSTR CAccountAccess::Name()
  115. {
  116. return(_principal);
  117. }
  118. //+---------------------------------------------------------------------------
  119. //
  120. // Member: CAccountAccess::AccessMode, public
  121. //
  122. // Synopsis: returns the accessmode (GRANT, SET = allowed, DENY = denied, REVOKE)
  123. //
  124. // Arguments: none
  125. //
  126. //----------------------------------------------------------------------------
  127. ACCESS_MODE CAccountAccess::AccessMode()
  128. {
  129. return(_accessmode);
  130. }
  131. //+---------------------------------------------------------------------------
  132. //
  133. // Member: CAccountAccess::Mask, public
  134. //
  135. // Synopsis: returns the access mask
  136. //
  137. // Arguments: none
  138. //
  139. //----------------------------------------------------------------------------
  140. ACCESS_MASK CAccountAccess::AccessMask()
  141. {
  142. return(_accessmask);
  143. }
  144. //+---------------------------------------------------------------------------
  145. //
  146. // Member: CAccountAccess::AceFlags, public
  147. //
  148. // Synopsis: returns the access mask
  149. //
  150. // Arguments: none
  151. //
  152. //----------------------------------------------------------------------------
  153. DWORD CAccountAccess::AceFlags()
  154. {
  155. return(_aceflags);
  156. }
  157. //+---------------------------------------------------------------------------
  158. //
  159. // Member: CAccountAccess::SidType, public
  160. //
  161. // Synopsis: returns the sid type
  162. //
  163. // Arguments: none
  164. //
  165. //----------------------------------------------------------------------------
  166. SID_NAME_USE CAccountAccess::SidType()
  167. {
  168. return(_esidtype);
  169. }
  170. //+---------------------------------------------------------------------------
  171. //
  172. // Member: CAccountAccess::SetAccessMask, public
  173. //
  174. // Synopsis: sets the access mask
  175. //
  176. // Arguments: IN [am] - the accessmask to set
  177. //
  178. //----------------------------------------------------------------------------
  179. VOID CAccountAccess::SetAccessMask(ACCESS_MASK accessmask)
  180. {
  181. _accessmask = accessmask;
  182. }
  183. //+---------------------------------------------------------------------------
  184. //
  185. // Member: CAccountAccess::SetAccessMode, public
  186. //
  187. // Synopsis: sets the access type
  188. //
  189. // Arguments: IN [am] - the access type to set
  190. //
  191. //----------------------------------------------------------------------------
  192. VOID CAccountAccess::SetAccessMode(ACCESS_MODE accessmode)
  193. {
  194. _accessmode = accessmode;
  195. }
  196. //+---------------------------------------------------------------------------
  197. //
  198. // Member: CAccountAccess::SetAceFlags, public
  199. //
  200. // Synopsis: sets the access type
  201. //
  202. // Arguments: IN [am] - the access type to set
  203. //
  204. //----------------------------------------------------------------------------
  205. VOID CAccountAccess::SetAceFlags(DWORD aceflags)
  206. {
  207. _aceflags = aceflags;
  208. }
  209. //+---------------------------------------------------------------------------
  210. //
  211. // Member: CAccountAccess::ImpersonateSid, public
  212. //
  213. // Synopsis: returns the SID for the impersonating server
  214. //
  215. // Arguments: OUT [psid] - address of the sid
  216. //
  217. //----------------------------------------------------------------------------
  218. PSID CAccountAccess::ImpersonateSid()
  219. {
  220. return(_pimpersonatesid);
  221. }
  222. //+---------------------------------------------------------------------------
  223. //
  224. // Member: CAccountAccess::ImpersonateName, public
  225. //
  226. // Synopsis: returns the name of the impersonating servers' account
  227. //
  228. // Arguments: OUT [psid] - address of the server's name
  229. //
  230. //----------------------------------------------------------------------------
  231. LPWSTR CAccountAccess::ImpersonateName()
  232. {
  233. return(_pimpersonatename);
  234. }
  235. //+---------------------------------------------------------------------------
  236. //
  237. // Member: CAccountAccess::ImpersonateName, public
  238. //
  239. // Synopsis: returns the name of the impersonating servers' account
  240. //
  241. // Arguments: OUT [psid] - address of the server's name
  242. //
  243. //----------------------------------------------------------------------------
  244. MULTIPLE_TRUSTEE_OPERATION CAccountAccess::MultipleTrusteeOperation()
  245. {
  246. return(_multipletrusteeoperation);
  247. }
  248. #endif // __ACCACC__