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.

215 lines
9.8 KiB

  1. /*---------------------------------------------------------------------------
  2. File: TAcctReplNode.hpp
  3. Comments: implementation/Definition of the TAcctReplNode class.
  4. (c) Copyright 1999, Mission Critical Software, Inc., All Rights Reserved
  5. Proprietary and confidential to Mission Critical Software, Inc.
  6. REVISION LOG ENTRY
  7. Revision By: Sham Chauthani
  8. Revised on 07/02/99 12:40:00
  9. ---------------------------------------------------------------------------
  10. */
  11. #ifndef __TACCTREPLNODE_HPP__
  12. #define __TACCTREPLNODE_HPP__
  13. //#pragma title("TAcctReplNode.hpp- class definitions for Account replication code")
  14. #include <lmcons.h>
  15. #include "Common.hpp"
  16. #include "EaLen.hpp"
  17. #include "Err.hpp"
  18. #include "UString.hpp"
  19. #include "CommaLog.hpp"
  20. #include "WorkObj.h"
  21. #include <COMDEF.h>
  22. #include <map>
  23. #define AR_Status_Created (0x00000001)
  24. #define AR_Status_Replaced (0x00000002)
  25. #define AR_Status_AlreadyExisted (0x00000004)
  26. #define AR_Status_RightsUpdated (0x00000008)
  27. #define AR_Status_DomainChanged (0x00000010)
  28. #define AR_Status_Rebooted (0x00000020)
  29. #define AR_Status_Special (0x00000040)
  30. #define AR_Status_Critical (0x00000080)
  31. #define AR_Status_GroupScopeChanged (0x00000100)
  32. #define AR_Status_PasswordCopied (0x00000200)
  33. #define AR_Status_PasswordError (0x00000400)
  34. #define AR_Status_Warning (0x40000000)
  35. #define AR_Status_Error (0x80000000)
  36. // Opertation flags to be performed on the Account
  37. #define OPS_Create_Account (0x00000001)
  38. #define OPS_Copy_Properties (0x00000002)
  39. #define OPS_Process_Members (0x00000004)
  40. #define OPS_Process_MemberOf (0x00000008)
  41. #define OPS_Call_Extensions (0x00000010)
  42. #define OPS_Move_Object (0x00000020)
  43. #define OPS_All OPS_Create_Account | OPS_Copy_Properties | OPS_Process_Members | OPS_Process_MemberOf | OPS_Call_Extensions
  44. #define OPS_Copy OPS_Create_Account | OPS_Copy_Properties
  45. typedef std::map<_bstr_t,_bstr_t> CGroupMemberMap;
  46. class TAcctReplNode:public TNode
  47. {
  48. _bstr_t name;
  49. _bstr_t newName;
  50. _bstr_t sourcePath;
  51. _bstr_t targetPath;
  52. _bstr_t type; // Account Type
  53. DWORD status;
  54. DWORD ridSrc;
  55. DWORD ridTgt;
  56. _bstr_t sSourceSamName;
  57. _bstr_t sTargetSamName;
  58. _bstr_t sSrcProfilePath;
  59. _bstr_t sTgtProfilePath;
  60. _bstr_t sTargetGUID;
  61. _bstr_t sSourceUPN;
  62. PSID srcSid;
  63. HRESULT hr;
  64. long lGroupType;
  65. public:
  66. DWORD operations; // BitMask Specifies what operations to perform on a pirticular account
  67. bool IsFilled; // Tells us if we need to process this account node any further to fill in required info
  68. bool IsProfPathFilled;
  69. bool bExpanded;
  70. bool bChangedType;
  71. // following map property is added to support UpdateMemberToGroups function to just be able to add
  72. // migrated objects to the groups that they belong to. This map contains all member name\type pair that are
  73. // members of this group account node
  74. CGroupMemberMap mapGrpMember;
  75. long lFlags;
  76. long lExpDate;
  77. BOOL bUPNConflicted;
  78. SAFEARRAY* psaUserRights;
  79. public:
  80. TAcctReplNode() :
  81. status(0),
  82. ridSrc(0),
  83. ridTgt(0),
  84. srcSid(NULL),
  85. hr(-1),
  86. lGroupType(0),
  87. operations(OPS_All),
  88. IsFilled(false),
  89. IsProfPathFilled(false),
  90. bExpanded(false),
  91. bChangedType(false),
  92. lFlags(0),
  93. lExpDate(0),
  94. bUPNConflicted(FALSE),
  95. psaUserRights(NULL)
  96. {
  97. //make sure the member map is empty
  98. mapGrpMember.clear();
  99. }
  100. TAcctReplNode(const TAcctReplNode *pAcctNode) :
  101. name(pAcctNode->name),
  102. newName(pAcctNode->newName),
  103. sourcePath(pAcctNode->sourcePath),
  104. targetPath(pAcctNode->targetPath),
  105. type(pAcctNode->type),
  106. status(pAcctNode->status),
  107. ridSrc(pAcctNode->ridSrc),
  108. ridTgt(pAcctNode->ridTgt),
  109. sSourceSamName(pAcctNode->sSourceSamName),
  110. sTargetSamName(pAcctNode->sTargetSamName),
  111. sSrcProfilePath(pAcctNode->sSrcProfilePath),
  112. sTgtProfilePath(pAcctNode->sTgtProfilePath),
  113. sTargetGUID(pAcctNode->sTargetGUID),
  114. sSourceUPN(pAcctNode->sSourceUPN),
  115. srcSid(pAcctNode->srcSid),
  116. hr(pAcctNode->hr),
  117. lGroupType(pAcctNode->lGroupType),
  118. operations(pAcctNode->operations),
  119. IsFilled(pAcctNode->IsFilled),
  120. IsProfPathFilled(pAcctNode->IsProfPathFilled),
  121. bExpanded(pAcctNode->bExpanded),
  122. bChangedType(pAcctNode->bChangedType),
  123. lFlags(pAcctNode->lFlags),
  124. lExpDate(pAcctNode->lExpDate),
  125. bUPNConflicted(pAcctNode->bUPNConflicted),
  126. psaUserRights(NULL)
  127. {
  128. //copy the member map
  129. mapGrpMember = pAcctNode->mapGrpMember;
  130. if (pAcctNode->psaUserRights)
  131. {
  132. SafeArrayCopy(pAcctNode->psaUserRights, &psaUserRights);
  133. }
  134. }
  135. ~TAcctReplNode()
  136. {
  137. if (psaUserRights)
  138. {
  139. SafeArrayDestroy(psaUserRights);
  140. }
  141. }
  142. WCHAR const * GetName() const { return !name ? L"" : name; }
  143. WCHAR const * GetTargetName() const { return !newName ? !name ? L"" : name : newName; }
  144. WCHAR const * GetTargetPath() const { return !targetPath ? L"" : targetPath; }
  145. WCHAR const * GetSourcePath() const { return !sourcePath ? L"" : sourcePath; }
  146. WCHAR const * GetType() const { return !type ? L"" : type; }
  147. WCHAR const * GetSourceSam() const { return !sSourceSamName ? L"" : sSourceSamName; }
  148. WCHAR const * GetTargetSam() const { return !sTargetSamName ? L"" : sTargetSamName; }
  149. WCHAR const * GetTargetProfile() const { return !sTgtProfilePath ? L"" : sTgtProfilePath; }
  150. WCHAR const * GetSourceProfile() const { return !sSrcProfilePath ? L"" : sSrcProfilePath; }
  151. WCHAR const * GetTargetGUID() const { return !sTargetGUID ? L"" : sTargetGUID; }
  152. WCHAR const * GetSourceUPN() const { return !sSourceUPN ? L"" : sSourceUPN; }
  153. PSID GetSourceSid() { return srcSid; }
  154. DWORD GetStatus() const { return status; }
  155. DWORD GetSourceRid() const { return ridSrc; }
  156. DWORD GetTargetRid() const { return ridTgt; }
  157. long GetGroupType() { return lGroupType; }
  158. HRESULT GetHr() const { return hr; }
  159. void SetName(const TCHAR * newname) { name = newname; }
  160. void SetTargetName(const WCHAR * name) { newName = name; }
  161. void SetTargetPath(const WCHAR * sPath) { targetPath = sPath; }
  162. void SetSourcePath(const WCHAR * sPath) { sourcePath = sPath; }
  163. void SetSourceSam(const WCHAR * sName) { sSourceSamName = sName; }
  164. void SetTargetSam(const WCHAR * sName) { sTargetSamName = sName; }
  165. void SetSourceProfile(const WCHAR * sPath) { sSrcProfilePath = sPath; IsProfPathFilled = true; }
  166. void SetTargetProfile(const WCHAR * sPath) { sTgtProfilePath = sPath; }
  167. void SetTargetGUID(const WCHAR * sGUID) { sTargetGUID = sGUID; }
  168. void SetType(const WCHAR * newtype) { type = newtype; }
  169. void SetSourceUPN(const WCHAR * sName) { sSourceUPN = sName; }
  170. void SetSourceSid(PSID sSid) { srcSid = sSid; }
  171. void SetStatus(DWORD val) { status = val; }
  172. void SetGroupType(long type) { lGroupType = type; }
  173. void SetSourceRid(DWORD val) { ridSrc = val; }
  174. void SetTargetRid(DWORD val) { ridTgt = val; }
  175. void SetHr(const HRESULT hrRes) { hr = hrRes; }
  176. void MarkCreated() { status |= AR_Status_Created; }
  177. void MarkReplaced() { status |= AR_Status_Replaced; }
  178. void MarkAlreadyThere() { status |= AR_Status_AlreadyExisted; }
  179. void MarkError() { status |= AR_Status_Error; }
  180. void MarkWarning() { status |= AR_Status_Warning; }
  181. void MarkRightsUpdated() { status |= AR_Status_RightsUpdated; }
  182. void MarkDomainChanged() { status |= AR_Status_DomainChanged; }
  183. void MarkRebooted() { status |= AR_Status_Rebooted; }
  184. void MarkCritical() { status = AR_Status_Critical; }
  185. void MarkGroupScopeChanged() { status |= AR_Status_GroupScopeChanged; }
  186. BOOL WasCreated() { return status & AR_Status_Created; }
  187. BOOL WasReplaced() { return status & AR_Status_Replaced; }
  188. BOOL IsCritical() { return status & AR_Status_Critical; }
  189. BOOL WasGroupScopeChanged() { return status & AR_Status_GroupScopeChanged; }
  190. BOOL CreateAccount() { return operations & OPS_Create_Account; }
  191. BOOL CopyProps() { return operations & OPS_Copy_Properties; }
  192. BOOL ProcessMem() { return operations & OPS_Process_Members; }
  193. BOOL ProcessMemOf() { return operations & OPS_Process_MemberOf; }
  194. BOOL CallExt() { return operations & OPS_Call_Extensions; }
  195. };
  196. #endif