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.

200 lines
4.7 KiB

  1. // AccessCheckTestDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Driver.h"
  5. #import "\bin\McsDctWorkerObjects.tlb" no_namespace, named_guids
  6. #include "AccChk.h"
  7. #include "sidflags.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CAccessCheckTestDlg property page
  15. IMPLEMENT_DYNCREATE(CAccessCheckTestDlg, CPropertyPage)
  16. CAccessCheckTestDlg::CAccessCheckTestDlg() : CPropertyPage(CAccessCheckTestDlg::IDD)
  17. {
  18. //{{AFX_DATA_INIT(CAccessCheckTestDlg)
  19. m_Computer = _T("");
  20. m_strTargetDomain = _T("");
  21. //}}AFX_DATA_INIT
  22. }
  23. CAccessCheckTestDlg::~CAccessCheckTestDlg()
  24. {
  25. }
  26. void CAccessCheckTestDlg::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CPropertyPage::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(CAccessCheckTestDlg)
  30. DDX_Text(pDX, IDC_COMPUTER, m_Computer);
  31. DDX_Text(pDX, IDC_COMPUTER2, m_strTargetDomain);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(CAccessCheckTestDlg, CPropertyPage)
  35. //{{AFX_MSG_MAP(CAccessCheckTestDlg)
  36. ON_BN_CLICKED(IDC_GET_OS_VERSION, OnGetOsVersion)
  37. ON_BN_CLICKED(IDC_IS_ADMIN, OnIsAdmin)
  38. ON_BN_CLICKED(IDC_IS_NATIVE_MODE, OnIsNativeMode)
  39. ON_BN_CLICKED(IDC_BUTTON1, OnInSameForest)
  40. ON_BN_CLICKED(IDC_IS_NATIVE_MODE2, OnIsNativeMode2)
  41. //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CAccessCheckTestDlg message handlers
  45. void CAccessCheckTestDlg::OnGetOsVersion()
  46. {
  47. UpdateData(TRUE);
  48. CWaitCursor w;
  49. HRESULT hr;
  50. CString info;
  51. unsigned long maj,min,sp;
  52. hr = pAC->raw_GetOsVersion(m_Computer.AllocSysString(),&maj,&min,&sp);
  53. if ( SUCCEEDED(hr) )
  54. {
  55. info.Format(L"The OS version for %ls is %ld.%ld",m_Computer,maj,min);
  56. }
  57. else
  58. {
  59. info.Format(L"Failed to get the OS version, hr=%lx",hr);
  60. }
  61. MessageBox(info);
  62. }
  63. void CAccessCheckTestDlg::OnIsAdmin()
  64. {
  65. UpdateData(TRUE);
  66. CWaitCursor w;
  67. HRESULT hr;
  68. CString info;
  69. long bIs;
  70. hr = pAC->raw_IsAdmin(NULL,m_Computer.AllocSysString(),&bIs);
  71. if ( SUCCEEDED(hr) )
  72. {
  73. if ( bIs != 0 )
  74. {
  75. info.Format(L"Yes");
  76. }
  77. else
  78. {
  79. info = L"No";
  80. }
  81. }
  82. else
  83. {
  84. info.Format(L"Failed to check for administrator permissions, hr=%lx",hr);
  85. }
  86. MessageBox(info);
  87. }
  88. void CAccessCheckTestDlg::OnIsNativeMode()
  89. {
  90. UpdateData(TRUE);
  91. CWaitCursor w;
  92. HRESULT hr = pAC->raw_AddLocalGroup(SysAllocString(L"devchild"),SysAllocString(L"\\\\bolesw2ktest"));
  93. if ( SUCCEEDED(hr) )
  94. {
  95. MessageBox(L"This function is not yet implemented.");
  96. }
  97. else
  98. {
  99. MessageBox(L"This function failed.");
  100. }
  101. }
  102. BOOL CAccessCheckTestDlg::OnSetActive()
  103. {
  104. HRESULT hr = pAC.CreateInstance(CLSID_AccessChecker);
  105. if ( FAILED(hr) )
  106. {
  107. CString s;
  108. s.Format(L"Failed to create AccessChecker COM object, hr=%lx",hr);
  109. }
  110. return CPropertyPage::OnSetActive();
  111. }
  112. void CAccessCheckTestDlg::OnInSameForest()
  113. {
  114. UpdateData(TRUE);
  115. CWaitCursor w;
  116. HRESULT hr;
  117. CString info;
  118. long bIs;
  119. hr = pAC->raw_IsInSameForest(m_Computer.AllocSysString(), m_strTargetDomain.AllocSysString(),&bIs);
  120. if ( SUCCEEDED(hr) )
  121. {
  122. if ( bIs != 0 )
  123. {
  124. info.Format(L"Yes");
  125. }
  126. else
  127. {
  128. info = L"No";
  129. }
  130. }
  131. else
  132. {
  133. info.Format(L"Failed to check for administrator permissions, hr=%lx",hr);
  134. }
  135. MessageBox(info);
  136. }
  137. void CAccessCheckTestDlg::OnIsNativeMode2()
  138. {
  139. UpdateData(TRUE);
  140. CWaitCursor w;
  141. HRESULT hr;
  142. CString info;
  143. long bIs;
  144. hr = pAC->raw_CanUseAddSidHistory(m_Computer.AllocSysString(), m_strTargetDomain.AllocSysString(),&bIs);
  145. if ( SUCCEEDED(hr) )
  146. {
  147. if ( bIs == 0 )
  148. {
  149. info.Format(L"Yes");
  150. }
  151. else
  152. {
  153. info = L"Following are the reasons why SID history will not work on these domains.\n";
  154. if ( bIs & F_WRONGOS )
  155. info += L" Target domain is not a native mode Win2k domain.\n";
  156. if ( bIs & F_NO_REG_KEY )
  157. info += L" TcpipControlSupport regkey is not set on the source domain\n";
  158. if ( bIs & F_NO_AUDITING_SOURCE )
  159. info += L" Auditing is turned off on the source domain.\n";
  160. if ( bIs & F_NO_AUDITING_TARGET )
  161. info += L" Auditing is turned off on the target domain.\n";
  162. if ( bIs & F_NO_LOCAL_GROUP )
  163. info += L" The <SourceDomain>$$$ local group does not exist.\n";
  164. }
  165. }
  166. else
  167. {
  168. info.Format(L"Failed to check for add sid history, hr=%lx",hr);
  169. }
  170. MessageBox(info);
  171. }