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.

127 lines
3.4 KiB

  1. // TrustTst.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "driver.h"
  5. #include "TrustTst.h"
  6. //#import "\bin\TrustMgr.tlb" no_namespace
  7. #import "TrustMgr.tlb" no_namespace
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CTrustTst property page
  15. IMPLEMENT_DYNCREATE(CTrustTst, CPropertyPage)
  16. CTrustTst::CTrustTst() : CPropertyPage(CTrustTst::IDD)
  17. {
  18. //{{AFX_DATA_INIT(CTrustTst)
  19. m_Trusted = _T("DEVRAPTORW2K");
  20. m_Trusting = _T("MCSDEV");
  21. m_CredTrustedAccount = _T("Administrator");
  22. m_CredTrustedDomain = _T("DEVRAPTORW2K");
  23. m_CredTrustedPassword = _T("control");
  24. m_CredTrustingAccount = _T("");
  25. m_CredTrustingDomain = _T("");
  26. m_CredTrustingPassword = _T("");
  27. m_Bidirectional = FALSE;
  28. //}}AFX_DATA_INIT
  29. }
  30. CTrustTst::~CTrustTst()
  31. {
  32. }
  33. void CTrustTst::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CPropertyPage::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(CTrustTst)
  37. DDX_Text(pDX, IDC_TRUSTED, m_Trusted);
  38. DDX_Text(pDX, IDC_TRUSTING, m_Trusting);
  39. DDX_Text(pDX, IDC_CRED_ED_ACCOUNT, m_CredTrustedAccount);
  40. DDX_Text(pDX, IDC_CRED_ED_DOMAIN, m_CredTrustedDomain);
  41. DDX_Text(pDX, IDC_CRED_ED_PASSWORD, m_CredTrustedPassword);
  42. DDX_Text(pDX, IDC_CRED_ING_ACCOUNT, m_CredTrustingAccount);
  43. DDX_Text(pDX, IDC_CRED_ING_DOMAIN, m_CredTrustingDomain);
  44. DDX_Text(pDX, IDC_CRED_ING_PASSWORD, m_CredTrustingPassword);
  45. DDX_Check(pDX, IDC_BIDIR, m_Bidirectional);
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(CTrustTst, CPropertyPage)
  49. //{{AFX_MSG_MAP(CTrustTst)
  50. ON_BN_CLICKED(IDC_CREATE_TRUST, OnCreateTrust)
  51. ON_BN_CLICKED(IDC_CREATE_WITH_CREDS, OnCreateWithCreds)
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CTrustTst message handlers
  56. void CTrustTst::OnCreateTrust()
  57. {
  58. UpdateData(TRUE);
  59. CWaitCursor w;
  60. HRESULT hr;
  61. CString msg;
  62. ITrustPtr pEnum;
  63. hr = pEnum.CreateInstance(__uuidof(Trust));
  64. if ( SUCCEEDED(hr) )
  65. {
  66. hr = pEnum->raw_CreateTrust(m_Trusting.AllocSysString(),m_Trusted.AllocSysString(),m_Bidirectional);
  67. if ( SUCCEEDED(hr) )
  68. {
  69. msg = L"Succeeded!";
  70. }
  71. else
  72. {
  73. msg.Format(L"CreateTrust failed, hr=%lx",hr);
  74. }
  75. }
  76. else
  77. {
  78. msg.Format(L"Failed to create Trust Enumerator COM object,hr=%lx",hr);
  79. }
  80. MessageBox(msg);
  81. }
  82. void CTrustTst::OnCreateWithCreds()
  83. {
  84. UpdateData(TRUE);
  85. CWaitCursor w;
  86. HRESULT hr;
  87. CString msg;
  88. ITrustPtr pEnum;
  89. hr = pEnum.CreateInstance(__uuidof(Trust));
  90. if ( SUCCEEDED(hr) )
  91. {
  92. hr = pEnum->raw_CreateTrustWithCreds(m_Trusting.AllocSysString(),m_Trusted.AllocSysString(),
  93. m_CredTrustingDomain.AllocSysString(),m_CredTrustingAccount.AllocSysString(),m_CredTrustingPassword.AllocSysString(),
  94. m_CredTrustedDomain.AllocSysString(),m_CredTrustedAccount.AllocSysString(),m_CredTrustedPassword.AllocSysString(),
  95. m_Bidirectional);
  96. if ( SUCCEEDED(hr) )
  97. {
  98. msg = L"Succeeded!";
  99. }
  100. else
  101. {
  102. msg.Format(L"CreateTrust failed, hr=%lx",hr);
  103. }
  104. }
  105. else
  106. {
  107. msg.Format(L"Failed to create Trust Enumerator COM object,hr=%lx",hr);
  108. }
  109. MessageBox(msg);
  110. }