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.

147 lines
3.2 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. _Module.Log(ErrE, IDS_E_CANT_ENUMERATE_SERVICE_ACCOUNTS, ce);
  33. hr = AdmtSetError(CLSID_Migration, IID_IServiceAccountEnumeration, ce, IDS_E_CANT_ENUMERATE_SERVICE_ACCOUNTS);
  34. }
  35. catch (...)
  36. {
  37. _Module.Log(ErrE, IDS_E_CANT_ENUMERATE_SERVICE_ACCOUNTS, _com_error(E_FAIL));
  38. hr = AdmtSetError(CLSID_Migration, IID_IServiceAccountEnumeration, E_FAIL, IDS_E_CANT_ENUMERATE_SERVICE_ACCOUNTS);
  39. }
  40. if (bLogOpen)
  41. {
  42. _Module.CloseLog();
  43. }
  44. MutexRelease();
  45. return hr;
  46. }
  47. // Implementation -----------------------------------------------------------
  48. // DoNames Method
  49. void CServiceAccountEnumeration::DoNames()
  50. {
  51. CDomainAccounts aComputers;
  52. m_SourceDomain.QueryComputersAcrossDomains(GetSourceContainer(), true, m_setIncludeNames, m_setExcludeNames, aComputers);
  53. DoComputers(aComputers);
  54. }
  55. // DoDomain Method
  56. void CServiceAccountEnumeration::DoDomain()
  57. {
  58. DoContainers(GetSourceContainer());
  59. }
  60. // DoContainers Method
  61. void CServiceAccountEnumeration::DoContainers(CContainer& rSource)
  62. {
  63. DoComputers(rSource);
  64. }
  65. // DoComputers Method
  66. void CServiceAccountEnumeration::DoComputers(CContainer& rSource)
  67. {
  68. CDomainAccounts aComputers;
  69. rSource.QueryComputers(true, m_nRecurseMaintain >= 1, m_setExcludeNames, aComputers);
  70. DoComputers(aComputers);
  71. }
  72. // DoComputers Method
  73. void CServiceAccountEnumeration::DoComputers(CDomainAccounts& rComputers)
  74. {
  75. if (rComputers.size() > 0)
  76. {
  77. CVarSet aVarSet;
  78. SetOptions(aVarSet);
  79. FillInVarSetForComputers(rComputers, false, false, false, 0, aVarSet);
  80. rComputers.clear();
  81. aVarSet.Put(_T("PlugIn.%ld"), 0, _T("{9CC87460-461D-11D3-99F3-0010A4F77383}"));
  82. PerformMigration(aVarSet);
  83. SaveSettings(aVarSet);
  84. }
  85. }
  86. // SetOptions Method
  87. void CServiceAccountEnumeration::SetOptions(CVarSet& rVarSet)
  88. {
  89. CVarSetOptions aOptions(rVarSet);
  90. aOptions.SetTest(m_spInternal->TestMigration ? true : false);
  91. aOptions.SetUndo(false);
  92. aOptions.SetWizard(_T("service"));
  93. aOptions.SetIntraForest(m_spInternal->IntraForest ? true : false);
  94. aOptions.SetSourceDomain(m_SourceDomain.NameFlat(), m_SourceDomain.NameDns());
  95. aOptions.SetTargetDomain(m_TargetDomain.NameFlat(), m_TargetDomain.NameDns());
  96. }