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.

133 lines
7.8 KiB

  1. // IManageDB.h : Declaration of the CIManageDB
  2. #ifndef __IMANAGEDB_H_
  3. #define __IMANAGEDB_H_
  4. #include "resource.h" // main symbols
  5. #include "EaLen.hpp"
  6. #include "TReg.hpp"
  7. #include "Err.hpp"
  8. #include "ResStr.h"
  9. #include "folders.h"
  10. using namespace nsFolders;
  11. //#import "\bin\mcsvarsetmin.tlb" no_namespace
  12. #import "VarSet.tlb" no_namespace rename("property", "aproperty")
  13. #import "msado21.tlb" no_namespace no_implementation rename("EOF", "EndOfFile")
  14. #import "msadox.dll" no_implementation exclude("DataTypeEnum")
  15. //#import <msjro.dll> no_namespace no_implementation
  16. const _bstr_t sKeyBase = REGKEY_ADMT;
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CIManageDB
  19. typedef struct x
  20. {
  21. _bstr_t sReportName;
  22. _bstr_t arReportFields[10];
  23. int arReportSize[10];
  24. int colsFilled;
  25. } reportStruct;
  26. class ATL_NO_VTABLE CIManageDB :
  27. public CComObjectRootEx<CComMultiThreadModel>,
  28. public CComCoClass<CIManageDB, &CLSID_IManageDB>,
  29. public ISupportErrorInfoImpl<&IID_IIManageDB>,
  30. public IDispatchImpl<IIManageDB, &IID_IIManageDB, &LIBID_DBMANAGERLib>
  31. {
  32. public:
  33. CIManageDB();
  34. ~CIManageDB();
  35. HRESULT FinalConstruct();
  36. void FinalRelease();
  37. DECLARE_REGISTRY_RESOURCEID(IDR_IMANAGEDB)
  38. DECLARE_PROTECT_FINAL_CONSTRUCT()
  39. BEGIN_COM_MAP(CIManageDB)
  40. COM_INTERFACE_ENTRY(IIManageDB)
  41. COM_INTERFACE_ENTRY(IDispatch)
  42. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  43. END_COM_MAP()
  44. // IIManageDB
  45. public:
  46. STDMETHOD(GetUserProps)(/*[in]*/ BSTR sDom, /*[in]*/ BSTR sSam, /*[in,out]*/ IUnknown ** ppVs);
  47. STDMETHOD(SaveUserProps)(IUnknown * pVs);
  48. STDMETHOD(GetMigratedObjectBySourceDN)(/*[in]*/ BSTR sSourceDN, /*[in,out]*/ IUnknown ** ppUnk);
  49. STDMETHOD(GetActionHistoryKey)(/*[in]*/ long lActionID, /*[in]*/ BSTR sKeyName, /*[in,out]*/ VARIANT * pVar);
  50. STDMETHOD(AreThereAnyMigratedObjects)(/*[out]*/ long * count);
  51. STDMETHOD(CloseAccountsTable)();
  52. STDMETHOD(OpenAccountsTable)(/*[in]*/ LONG bSource);
  53. STDMETHOD(AddSourceObject)(/*[in]*/ BSTR sDomain, /*[in]*/ BSTR sSAMName, /*[in]*/ BSTR sType, /*[in]*/ BSTR sRDN, /*[in]*/ BSTR sCanonicalName, /*[in]*/ LONG bSource);
  54. STDMETHOD(AddAcctRef)(/*[in]*/ BSTR sDomain, /*[in]*/ BSTR sAcct, /*[in]*/ BSTR sAcctSid, /*[in]*/ BSTR sComp, /*[in]*/ long lCount, /*[in]*/ BSTR sType);
  55. STDMETHOD(CancelDistributedAction)(/*[in]*/ long lActionID, /*[in]*/ BSTR sComp);
  56. STDMETHOD(SetDistActionStatus)(/*[in]*/ long lActionID, /*[in]*/ BSTR sComp, /*[in]*/ long lStatus, BSTR sText);
  57. STDMETHOD(SetServiceAcctEntryStatus)(/*[in]*/ BSTR sComp, /*[in]*/ BSTR sSvc, /*[in]*/ BSTR sAcct, /*[in]*/ long Status);
  58. STDMETHOD(GetPasswordAge)(/*[in]*/ BSTR sDomain, /*[in]*/ BSTR sComp, /*[out]*/ BSTR * sDesc, /*[out]*/ long * lAge, /*[out]*/ long *lTime);
  59. STDMETHOD(SavePasswordAge)(/*[in]*/ BSTR sDomain, /*[in]*/ BSTR sComp, /*[in]*/ BSTR sDesc, /*[in]*/ long lAge);
  60. STDMETHOD(GetServiceAccount)(/*[in]*/ BSTR Account, /*[in,out]*/ IUnknown ** pUnk);
  61. STDMETHOD(SetServiceAccount)(/*[in]*/ BSTR System, /*[in]*/ BSTR Service, /*[in]*/ BSTR ServiceDisplayName,/*[in]*/ BSTR Account);
  62. STDMETHOD(GetFailedDistributedActions)(/*[in]*/ long lActionID, /*[in,out]*/ IUnknown ** pUnk);
  63. STDMETHOD(AddDistributedAction)(/*[in]*/ BSTR sServerName, /*[in]*/ BSTR sResultFile, /*[in]*/ long lStatus, BSTR sText);
  64. STDMETHOD(GenerateReport)(/*[in]*/ BSTR sReportName, /*[in]*/ BSTR sFileName, /*[in]*/ BSTR sSrcDomain, /*[in]*/ BSTR sTgtDomain, /*[in]*/ LONG bSourceNT4);
  65. STDMETHOD(GetAMigratedObject)(/*[in]*/ BSTR sSrcSamName, /*[in]*/ BSTR sSrcDomain, /*[in]*/ BSTR sTgtDomain, /*[in,out]*/ IUnknown ** ppUnk);
  66. STDMETHOD(GetCurrentActionID)(/*[out]*/ long * pActionID);
  67. STDMETHOD(ClearSCMPasswords)();
  68. STDMETHOD(GetSCMPasswords)(/*[out]*/ IUnknown ** ppUnk);
  69. STDMETHOD(SaveSCMPasswords)(/*[in]*/ IUnknown * pUnk);
  70. STDMETHOD(GetRSForReport)(/*[in]*/ BSTR sReport, /*[out,retval]*/ IUnknown ** pprsData);
  71. STDMETHOD(GetMigratedObjects)(/*[in]*/ long lActionID, /*[in,out]*/ IUnknown ** ppUnk);
  72. STDMETHOD(SaveMigratedObject)(/*[in]*/ long lActionID, /*[in]*/ IUnknown * pUnk);
  73. STDMETHOD(GetNextActionID)(/*[out]*/ long * pActionID);
  74. STDMETHOD(GetActionHistory)(/*[in]*/ long lActionID, /*[in,out]*/ IUnknown ** ppUnk);
  75. STDMETHOD(SetActionHistory)(/*[in]*/ long lActionID, /*[in]*/ IUnknown * pUnk);
  76. STDMETHOD(GetSettings)(/*[in,out]*/ IUnknown ** ppUnk);
  77. STDMETHOD(GetVarsetFromDB)(/*[in]*/ BSTR sTable, /*[in,out]*/ IUnknown ** ppVarset, /*[in,optional]*/ VARIANT ActionID = _variant_t(-1L));
  78. STDMETHOD(SaveSettings)(/*[in]*/ IUnknown * pUnk );
  79. STDMETHOD(ClearTable)(/*[in]*/ BSTR sTableName, /*[in,optional]*/ VARIANT Filter = _variant_t(L""));
  80. STDMETHOD(SetVarsetToDB)(/*[in]*/ IUnknown * pUnk, /*[in]*/ BSTR sTableName, /*[in,optional]*/ VARIANT ActionID = _variant_t(-1L));
  81. STDMETHOD(GetAMigratedObjectToAnyDomain)(/*[in]*/ BSTR sSrcSamName, /*[in]*/ BSTR sSrcDomain, /*[in,out]*/ IUnknown ** ppUnk);
  82. STDMETHOD(SrcSidColumnInMigratedObjectsTable)(/*[out, retval]*/ VARIANT_BOOL * pbFound);
  83. STDMETHOD(GetMigratedObjectsFromOldMOT)(/*[in]*/ long lActionID, /*[in,out]*/ IUnknown ** ppUnk);
  84. STDMETHOD(CreateSrcSidColumnInMOT)(/*[out, retval]*/ VARIANT_BOOL * pbCreated);
  85. STDMETHOD(PopulateSrcSidColumnByDomain)(/*[in]*/ BSTR sDomainName, /*[in]*/ BSTR sSid, /*[out, retval]*/ VARIANT_BOOL * pbPopulated);
  86. STDMETHOD(DeleteSrcSidColumnInMOT)(/*[out, retval]*/ VARIANT_BOOL * pbDeleted);
  87. STDMETHOD(GetMigratedObjectsWithSSid)(/*[in]*/ long lActionID, /*[in,out]*/ IUnknown ** ppUnk);
  88. STDMETHOD(CreateSidColumnInAR)();
  89. STDMETHOD(SidColumnInARTable)(/*[out, retval]*/ VARIANT_BOOL * pbFound);
  90. STDMETHOD(GetMigratedObjectByType)(/*[in]*/ long lActionID, /*[in]*/ BSTR sSrcDomain, /*[in]*/ BSTR sType, /*[in,out]*/ IUnknown ** ppUnk);
  91. STDMETHOD(GetAMigratedObjectBySidAndRid)(/*[in]*/ BSTR sSrcDomainSid, /*[in]*/ BSTR sRid, /*[in,out]*/ IUnknown ** ppUnk);
  92. STDMETHOD(GetMigratedObjectsByTarget)(/*[in]*/ BSTR sTargetDomain, /*[in]*/ BSTR sTargetSAM, /*[in,out]*/ IUnknown ** ppUnk);
  93. STDMETHOD(GetSourceDomainInfo)(/*[in]*/ BSTR sSourceDomainName, /*[out,retval]*/ IUnknown** ppunkVarSet);
  94. STDMETHOD(UpdateMigratedTargetObject)(/*[in]*/ IUnknown* punkVarSet);
  95. STDMETHOD(UpdateMigratedObjectStatus)(BSTR bstrGuid, long lStatus);
  96. STDMETHOD(GetMigratedObjectsForSecurityTranslation)(BSTR bstrSourceDomain, BSTR bstrTargetDomain, IUnknown* punkVarSet);
  97. STDMETHOD(GetDistributedActionStatus)(long lActionId, BSTR bstrServerName, long* plStatus);
  98. STDMETHOD(GetServerNamesFromActionHistory)(long lActionId, BSTR bstrServerName, BSTR* pbstrFlatName, BSTR* pbstrDnsName);
  99. protected:
  100. HRESULT PutVariantInDB( _RecordsetPtr pRs, _variant_t val );
  101. HRESULT GetVarFromDB(_RecordsetPtr pRec, _variant_t& val);
  102. void UpgradeDatabase(LPCTSTR pszFolder);
  103. void UpdateDomainAndServerColumnWidths(_ConnectionPtr spConnection);
  104. void UpdateDomainNames();
  105. _RecordsetPtr QueryUniqueColumnValues(PCTSTR pszTable, PCTSTR pszColumn);
  106. void UpdateColumnValues(PCTSTR pszTable, PCTSTR pszColumn, int nWidth, PCTSTR pszValueA, PCTSTR pszValueB);
  107. void CreateSettings2Table(_ConnectionPtr spConnection);
  108. private:
  109. void RestoreVarset(IVarSetPtr pVS);
  110. void ClipVarset(IVarSetPtr pVS);
  111. HRESULT ChangeNCTableColumns(BOOL bSource);
  112. BOOL NCTablesColumnsChanged(BOOL bSource);
  113. _ConnectionPtr m_cn;
  114. _variant_t m_vtConn;
  115. void SetActionIDInMigratedObjects(_bstr_t sFilter);
  116. IVarSetPtr m_pQueryMapping;
  117. _RecordsetPtr m_rsAccounts;
  118. };
  119. #endif //__IMANAGEDB_H_