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.

145 lines
2.9 KiB

  1. #include "StdAfx.h"
  2. #include "ADMTScript.h"
  3. #include "ServiceAccountEnumeration.h"
  4. #include "Error.h"
  5. #include "VarSetOptions.h"
  6. #include "VarSetAccountOptions.h"
  7. #include "VarSetSecurity.h"
  8. //---------------------------------------------------------------------------
  9. // Service Account Enumeration Class
  10. //---------------------------------------------------------------------------
  11. CServiceAccountEnumeration::CServiceAccountEnumeration()
  12. {
  13. }
  14. CServiceAccountEnumeration::~CServiceAccountEnumeration()
  15. {
  16. }
  17. // IServiceAccountEnumeration Implementation --------------------------------
  18. // Enumerate Method
  19. STDMETHODIMP CServiceAccountEnumeration::Enumerate(long lOptions, VARIANT vntInclude, VARIANT vntExclude)
  20. {
  21. HRESULT hr = S_OK;
  22. MutexWait();
  23. bool bLogOpen = _Module.OpenLog();
  24. try
  25. {
  26. _Module.Log(ErrI, IDS_STARTED_SERVICE_ACCOUNT_ENUMERATION);
  27. InitSourceDomainAndContainer();
  28. DoOption(lOptions, vntInclude, vntExclude);
  29. }
  30. catch (_com_error& ce)
  31. {
  32. hr = AdmtSetError(CLSID_Migration, IID_IServiceAccountEnumeration, ce, IDS_E_CANT_ENUMERATE_SERVICE_ACCOUNTS);
  33. }
  34. catch (...)
  35. {
  36. hr = AdmtSetError(CLSID_Migration, IID_IServiceAccountEnumeration, E_FAIL, IDS_E_CANT_ENUMERATE_SERVICE_ACCOUNTS);
  37. }
  38. if (bLogOpen)
  39. {
  40. _Module.CloseLog();
  41. }
  42. MutexRelease();
  43. return hr;
  44. }
  45. // Implementation -----------------------------------------------------------
  46. // DoNames Method
  47. void CServiceAccountEnumeration::DoNames()
  48. {
  49. CDomainAccounts aComputers;
  50. m_SourceDomain.QueryComputersAcrossDomains(GetSourceContainer(), true, m_setIncludeNames, m_setExcludeNames, aComputers);
  51. DoComputers(aComputers);
  52. }
  53. // DoDomain Method
  54. void CServiceAccountEnumeration::DoDomain()
  55. {
  56. DoContainers(GetSourceContainer());
  57. }
  58. // DoContainers Method
  59. void CServiceAccountEnumeration::DoContainers(CContainer& rSource)
  60. {
  61. DoComputers(rSource);
  62. }
  63. // DoComputers Method
  64. void CServiceAccountEnumeration::DoComputers(CContainer& rSource)
  65. {
  66. CDomainAccounts aComputers;
  67. rSource.QueryComputers(true, m_nRecurseMaintain >= 1, m_setExcludeNames, aComputers);
  68. DoComputers(aComputers);
  69. }
  70. // DoComputers Method
  71. void CServiceAccountEnumeration::DoComputers(CDomainAccounts& rComputers)
  72. {
  73. if (rComputers.size() > 0)
  74. {
  75. CVarSet aVarSet;
  76. SetOptions(aVarSet);
  77. FillInVarSetForComputers(rComputers, false, false, false, 0, aVarSet);
  78. rComputers.clear();
  79. aVarSet.Put(_T("PlugIn.%ld"), 0, _T("{9CC87460-461D-11D3-99F3-0010A4F77383}"));
  80. PerformMigration(aVarSet);
  81. SaveSettings(aVarSet);
  82. }
  83. }
  84. // SetOptions Method
  85. void CServiceAccountEnumeration::SetOptions(CVarSet& rVarSet)
  86. {
  87. CVarSetOptions aOptions(rVarSet);
  88. aOptions.SetTest(m_spInternal->TestMigration ? true : false);
  89. aOptions.SetUndo(false);
  90. aOptions.SetWizard(_T("service"));
  91. aOptions.SetIntraForest(m_spInternal->IntraForest ? true : false);
  92. aOptions.SetSourceDomain(m_SourceDomain.NameFlat(), m_SourceDomain.NameDns());
  93. aOptions.SetTargetDomain(m_TargetDomain.NameFlat(), m_TargetDomain.NameDns());
  94. }