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.

142 lines
3.4 KiB

  1. // MoveTest.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "driver.h"
  5. #include "MoveTest.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CMoveTest property page
  13. IMPLEMENT_DYNCREATE(CMoveTest, CPropertyPage)
  14. CMoveTest::CMoveTest() : CPropertyPage(CMoveTest::IDD)
  15. {
  16. //{{AFX_DATA_INIT(CMoveTest)
  17. m_SourceComputer = _T("whqrdt");
  18. m_SourceDN = _T("CN=CBTest2,CN=Users,DC=devrdt,DC=com");
  19. m_TargetComputer = _T("bolesw2ktest");
  20. m_TargetContainer = _T("OU=Christy,DC=devchild,DC=devrdt,DC=com");
  21. m_Account = _T("Administrator");
  22. m_Password = _T("control");
  23. m_TgtAccount = _T("");
  24. m_Domain = _T("");
  25. m_TgtDomain = _T("");
  26. m_TgtPassword = _T("");
  27. //}}AFX_DATA_INIT
  28. }
  29. CMoveTest::~CMoveTest()
  30. {
  31. }
  32. void CMoveTest::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CPropertyPage::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CMoveTest)
  36. DDX_Text(pDX, IDC_Source, m_SourceComputer);
  37. DDX_Text(pDX, IDC_SOURCEDN, m_SourceDN);
  38. DDX_Text(pDX, IDC_Target, m_TargetComputer);
  39. DDX_Text(pDX, IDC_TARGET_CONTAINER, m_TargetContainer);
  40. DDX_Text(pDX, IDC_ACCOUNT, m_Account);
  41. DDX_Text(pDX, IDC_Password, m_Password);
  42. DDX_Text(pDX, IDC_ACCOUNT2, m_TgtAccount);
  43. DDX_Text(pDX, IDC_DOMAIN, m_Domain);
  44. DDX_Text(pDX, IDC_DOMAIN2, m_TgtDomain);
  45. DDX_Text(pDX, IDC_Password2, m_TgtPassword);
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(CMoveTest, CPropertyPage)
  49. //{{AFX_MSG_MAP(CMoveTest)
  50. ON_BN_CLICKED(IDC_MOVE, OnMove)
  51. ON_BN_CLICKED(IDC_CONNECT, OnConnect)
  52. ON_BN_CLICKED(IDC_CLOSE, OnClose)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CMoveTest message handlers
  57. void CMoveTest::OnMove()
  58. {
  59. UpdateData(TRUE);
  60. CWaitCursor w;
  61. HRESULT hr;
  62. CString msg;
  63. hr = m_pMover->raw_MoveObject(m_SourceDN.AllocSysString(),m_TargetContainer.AllocSysString());
  64. if ( SUCCEEDED(hr))
  65. {
  66. msg = L"Moved successfully!";
  67. }
  68. else
  69. {
  70. msg.Format(L"MoveObject failed, hr=%lx",hr);
  71. }
  72. MessageBox(msg);
  73. }
  74. BOOL CMoveTest::OnInitDialog()
  75. {
  76. CPropertyPage::OnInitDialog();
  77. HRESULT hr = m_pMover.CreateInstance(CLSID_Mover);
  78. if ( FAILED(hr) )
  79. {
  80. CString msg;
  81. msg.Format(L"CreateInstance(ObjectMover) failed, hr=%lx",hr);
  82. MessageBox(msg);
  83. }
  84. return TRUE; // return TRUE unless you set the focus to a control
  85. // EXCEPTION: OCX Property Pages should return FALSE
  86. }
  87. void CMoveTest::OnConnect()
  88. {
  89. UpdateData(TRUE);
  90. CWaitCursor w;
  91. HRESULT hr;
  92. CString msg;
  93. hr = m_pMover->raw_Connect(m_SourceComputer.AllocSysString(),m_TargetComputer.AllocSysString(),
  94. m_Domain.AllocSysString(),m_Account.AllocSysString(),m_Password.AllocSysString(),
  95. m_TgtDomain.AllocSysString(),m_TgtAccount.AllocSysString(),m_TgtPassword.AllocSysString());
  96. if ( SUCCEEDED(hr) )
  97. {
  98. msg = L"Connected successfully!";
  99. }
  100. else
  101. {
  102. msg.Format(L"Connect failed, hr=%lx",hr);
  103. }
  104. MessageBox(msg);
  105. }
  106. void CMoveTest::OnClose()
  107. {
  108. UpdateData(TRUE);
  109. CWaitCursor w;
  110. HRESULT hr;
  111. CString msg;
  112. hr = m_pMover->raw_Close();
  113. if ( SUCCEEDED(hr) )
  114. {
  115. msg = L"Closed successfully!";
  116. }
  117. else
  118. {
  119. msg.Format(L"Close() failed, hr=%lx",hr);
  120. }
  121. MessageBox(msg);
  122. }