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.

211 lines
9.6 KiB

  1. /*---------------------------------------------------------------------------
  2. File: AcctRepl.h
  3. Comments: Definition of account replicator COM object.
  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: Christy Boles
  8. Revised on 02/15/99 11:18:21
  9. ---------------------------------------------------------------------------
  10. */
  11. // AcctRepl.h : Declaration of the CAcctRepl
  12. #ifndef __ACCTREPL_H_
  13. #define __ACCTREPL_H_
  14. #include "resource.h" // main symbols
  15. #include "ProcExts.h"
  16. //#import "\bin\McsVarSetMin.tlb" no_namespace
  17. //#import "\bin\MoveObj.tlb" no_namespace
  18. //#import "VarSet.tlb" no_namespace rename("property", "aproperty")//already #imported by ProcExts.h
  19. #import "MoveObj.tlb" no_namespace
  20. #include "UserCopy.hpp"
  21. #include "TNode.hpp"
  22. #include "Err.hpp"
  23. #include "ResStr.h"
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CAcctRepl
  26. class ATL_NO_VTABLE CAcctRepl :
  27. public CComObjectRootEx<CComMultiThreadModel>,
  28. public CComCoClass<CAcctRepl, &CLSID_AcctRepl>,
  29. public IAcctRepl
  30. {
  31. public:
  32. CAcctRepl()
  33. {
  34. m_pUnkMarshaler = NULL;
  35. m_UpdateUserRights = FALSE;
  36. m_ChangeDomain = FALSE;
  37. m_Reboot = FALSE;
  38. m_RenameOnly = FALSE;
  39. m_pExt = NULL;
  40. }
  41. DECLARE_REGISTRY_RESOURCEID(IDR_ACCTREPL)
  42. /*
  43. static HRESULT WINAPI UpdateRegistry( BOOL bUpdateRegistry )
  44. {
  45. _bstr_t pid, pidver, name;
  46. pidver = GET_BSTR(IDS_COM_AcctReplPidVer);
  47. name = GET_BSTR(IDS_COM_AcctReplName);
  48. pid = GET_BSTR(IDS_COM_AcctReplPid);
  49. _ATL_REGMAP_ENTRY regMap[] =
  50. {
  51. { OLESTR("PIDVER"), pidver },
  52. { OLESTR("OBJNAME"), name },
  53. { OLESTR("PID"), pid },
  54. { 0, 0 }
  55. };
  56. return _Module.UpdateRegistryFromResourceD( IDR_ACCTREPL, bUpdateRegistry, regMap );
  57. }
  58. */
  59. DECLARE_NOT_AGGREGATABLE(CAcctRepl)
  60. DECLARE_GET_CONTROLLING_UNKNOWN()
  61. DECLARE_PROTECT_FINAL_CONSTRUCT()
  62. BEGIN_COM_MAP(CAcctRepl)
  63. COM_INTERFACE_ENTRY(IAcctRepl)
  64. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  65. END_COM_MAP()
  66. HRESULT FinalConstruct()
  67. {
  68. return CoCreateFreeThreadedMarshaler(
  69. GetControllingUnknown(), &m_pUnkMarshaler.p);
  70. }
  71. void FinalRelease()
  72. {
  73. m_pUnkMarshaler.Release();
  74. }
  75. CComPtr<IUnknown> m_pUnkMarshaler;
  76. // IAcctRepl
  77. public:
  78. HRESULT Create2KObj( TAcctReplNode * pAcct, Options * pOptions);
  79. STDMETHOD(Process)(IUnknown * pWorkItemIn);
  80. protected:
  81. HRESULT ResetMembersForUnivGlobGroups(Options * pOptions, TAcctReplNode * pAcct);
  82. HRESULT FillNodeFromPath( TAcctReplNode * pAcct, Options * pOptions, TNodeListSortable * acctList );
  83. Options opt;
  84. TNodeListSortable acctList;
  85. BOOL m_UpdateUserRights;
  86. BOOL m_ChangeDomain;
  87. BOOL m_Reboot;
  88. BOOL m_RenameOnly;
  89. void LoadOptionsFromVarSet(IVarSet * pVarSet);
  90. void LoadResultsToVarSet(IVarSet * pVarSet);
  91. DWORD PopulateAccountListFromVarSet(IVarSet * pVarSet);
  92. BOOL PopulateAccountListFromFile(WCHAR const * filename);
  93. DWORD UpdateUserRights(IStatusObj * pStatus);
  94. //void ReadPasswordPolicy();
  95. void WriteOptionsToLog();
  96. // DWORD GetAccountType(TAcctReplNode * pNode);
  97. int CopyObj(
  98. Options * options, // in -options
  99. TNodeListSortable * acctlist, // in -list of accounts to process
  100. ProgressFn * progress, // in -window to write progress messages to
  101. TError & error, // in -window to write error messages to
  102. IStatusObj * pStatus, // in -status object to support cancellation
  103. void WindowUpdate (void ) // in - window update function
  104. );
  105. int UndoCopy(
  106. Options * options, // in -options
  107. TNodeListSortable * acctlist, // in -list of accounts to process
  108. ProgressFn * progress, // in -window to write progress messages to
  109. TError & error, // in -window to write error messages to
  110. IStatusObj * pStatus, // in -status object to support cancellation
  111. void WindowUpdate (void ) // in - window update function
  112. );
  113. bool BothWin2K( Options * pOptions );
  114. int CopyObj2K( Options * pOptions, TNodeListSortable * acctList, ProgressFn * progress, IStatusObj * pStatus );
  115. int DeleteObject( Options * pOptions, TNodeListSortable * acctList, ProgressFn * progress, IStatusObj * pStatus );
  116. HRESULT UpdateGroupMembership(Options * pOptions, TNodeListSortable * acctlist,ProgressFn * progress, IStatusObj * pStatus );
  117. // HRESULT UpdateNT4GroupMembership(Options * pOptions, TNodeListSortable * acctlist,ProgressFn * progress, IStatusObj * pStatus, void WindowUpdate(void));
  118. private:
  119. HRESULT UpdateMemberToGroups(TNodeListSortable * acctList, Options * pOptions, BOOL bGrpsOnly);
  120. BOOL StuffComputerNameinLdapPath(WCHAR * sAdsPath, DWORD nPathLen, WCHAR * sSubPath, Options * pOptions, BOOL bTarget = TRUE);
  121. BOOL CheckBuiltInWithNTApi( PSID pSid, WCHAR * pNode, Options * pOptions );
  122. HRESULT GetTargetGroupType( WCHAR * sPath, DWORD& grpType);
  123. bool GetClosestDC( Options * pOpt, long flags = 0 );
  124. BOOL GetNt4Type( WCHAR const * sComp, WCHAR const * sAcct, WCHAR * sType);
  125. BOOL GetSamFromPath(_bstr_t sPath, _bstr_t& sSam, _bstr_t& sType, _bstr_t& sName, long& grpType, Options * pOptions);
  126. BOOL IsContainer( TAcctReplNode * pNode, IADsContainer ** ppCont);
  127. BOOL ExpandContainers( TNodeListSortable * acctlist, Options *pOptions, ProgressFn * progress );
  128. CProcessExtensions * m_pExt;
  129. HRESULT CAcctRepl::RemoveMembers(TAcctReplNode * pAcct, Options * pOptions);
  130. bool FillPathInfo(TAcctReplNode * pAcct,Options * pOptions);
  131. bool AcctReplFullPath(TAcctReplNode * pAcct, Options * pOptions);
  132. BOOL NeedToProcessAccount(TAcctReplNode * pAcct, Options * pOptions);
  133. BOOL ExpandMembership(TNodeListSortable *acctlist, Options *pOptions, TNodeListSortable *pNewAccts, ProgressFn * progress, BOOL bGrpsOnly);
  134. int MoveObj2K(Options * options, TNodeListSortable * acctlist, ProgressFn * progress, IStatusObj * pStatus);
  135. HRESULT ResetObjectsMembership(Options * pOptions, TNodeListSortable * pMember, IIManageDBPtr pDb);
  136. HRESULT RecordAndRemoveMemberOf ( Options * pOptions, TAcctReplNode * pAcct, TNodeListSortable * pMember);
  137. HRESULT RecordAndRemoveMember (Options * pOptions,TAcctReplNode * pAcct,TNodeListSortable * pMember);
  138. HRESULT MoveObject( TAcctReplNode * pAcct,Options * pOptions,IMoverPtr pMover);
  139. HRESULT ResetGroupsMembers( Options * pOptions, TAcctReplNode * pAcct, TNodeListSortable * pMember, IIManageDBPtr pDb );
  140. HRESULT ADsPathFromDN( Options * pOptions,_bstr_t sDN,WCHAR * sPath, bool bWantLDAP = true);
  141. void SimpleADsPathFromDN( Options * pOptions,WCHAR const * sDN,WCHAR * sPath);
  142. BOOL FillNamingContext(Options * pOptions);
  143. HRESULT MakeAcctListFromMigratedObjects(Options * pOptions, long lUndoActionID, TNodeListSortable *& pAcctList,BOOL bReverseDomains);
  144. void AddPrefixSuffix( TAcctReplNode * pNode, Options * pOptions );
  145. HRESULT LookupAccountInTarget(Options * pOptions, WCHAR * sSam, WCHAR * sPath);
  146. void UpdateMemberList(TNodeListSortable * pMemberList,TNodeListSortable * acctlist);
  147. void BuildTargetPath(WCHAR const * sCN, WCHAR const * tgtOU, WCHAR * stgtPath);
  148. HRESULT BetterHR(HRESULT hr);
  149. HRESULT BuildSidPath(
  150. WCHAR const * sPath, //in- path returned by the enumerator.
  151. WCHAR * sSidPath, //out-path to the LDAP://<SID=###> object
  152. WCHAR * sSam, //out-Sam name of the object
  153. WCHAR * sDomain, //out-Domain name where this object resides.
  154. Options * pOptions, //in- Options
  155. PSID * ppSid //out-Pointer to the binary sid
  156. );
  157. HRESULT CheckClosedSetGroups(
  158. Options * pOptions, // in - options for the migration
  159. TNodeListSortable * pAcctList, // in - list of accounts to migrate
  160. ProgressFn * progress, // in - progress function to display progress messages
  161. IStatusObj * pStatus // in - status object to support cancellation
  162. );
  163. BOOL CanMoveInMixedMode(TAcctReplNode *pAcct,TNodeListSortable * acctlist,Options * pOptions);
  164. HRESULT QueryPrimaryGroupMembers(BSTR cols, Options * pOptions, DWORD rid, IEnumVARIANT*& pEnum);
  165. bool GetRidForGroup(Options * pOptions, WCHAR * sGroupSam, DWORD& rid);
  166. HRESULT AddPrimaryGroupMembers(Options * pOptions, SAFEARRAY * multiVals, WCHAR * sGroupSam);
  167. HRESULT GetThePrimaryGroupMembers(Options * pOptions, WCHAR * sGroupSam, IEnumVARIANT *& pVar);
  168. BOOL TruncateSam(WCHAR * tgtname, TAcctReplNode * acct, Options * options, TNodeListSortable * acctList);
  169. BOOL DoesTargetObjectAlreadyExist(TAcctReplNode * pAcct, Options * pOptions);
  170. void GetAccountUPN(Options * pOptions, _bstr_t sSName, _bstr_t& sSUPN);
  171. HRESULT UpdateManagement(TNodeListSortable * acctList, Options * pOptions);
  172. _bstr_t GetUnEscapedNameWithFwdSlash(_bstr_t strName);
  173. _bstr_t GetCNFromPath(_bstr_t sPath);
  174. BOOL ReplaceSourceInLocalGroup(TNodeListSortable * acctList, Options * pOptions, IStatusObj *pStatus);
  175. _bstr_t GetDomainOfMigratedForeignSecPrincipal(_bstr_t sPath);
  176. void RemoveSourceAccountFromGroup(IADsGroup * pGroup, IVarSetPtr pMOTVarSet, Options * pOptions);
  177. };
  178. typedef void ProgressFn(WCHAR const * mesg);
  179. typedef HRESULT (CALLBACK * ADSGETOBJECT)(LPWSTR, REFIID, void**);
  180. extern ADSGETOBJECT ADsGetObject;
  181. #endif //__ACCTREPL_H_