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.

1092 lines
30 KiB

  1. //+---------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993 - 1997.
  5. //
  6. // File: srvppg.cpp
  7. //
  8. // Contents: Implements the classes CServersPropertyPage,
  9. // CMachinePropertyPage and CDefaultSecurityPropertyPage to
  10. // manage the three property pages for top level info
  11. //
  12. // Classes:
  13. //
  14. // Methods: CServersPropertyPage::CServersPropertyPage
  15. // CServersPropertyPage::~CServersPropertyPage
  16. // CServersPropertyPage::OnProperties
  17. // CServersPropertyPage::DoDataExchange
  18. // CServersPropertyPage::OnServerProperties
  19. // CServersPropertyPage::OnInitDialog
  20. // CServersPropertyPage::FetchAndDisplayClasses
  21. // CServersPropertyPage::OnList1
  22. // CServersPropertyPage::OnDoubleclickedList1
  23. // CServersPropertyPage::OnButton2
  24. // CMachinePropertyPage::CMachinePropertyPage
  25. // CMachinePropertyPage::~CMachinePropertyPage
  26. // CMachinePropertyPage::DoDataExchange
  27. // CMachinePropertyPage::OnInitDialog
  28. // CMachinePropertyPage::OnCombo1
  29. // CMachinePropertyPage::OnCheck1
  30. // CMachinePropertyPage::OnCheck2
  31. // CMachinePropertyPage::OnEditchangeCombo1
  32. // CMachinePropertyPage::OnSelchangeCombo1
  33. // CMachinePropertyPage::OnEditchangeCombo2
  34. // CMachinePropertyPage::OnSelchangeCombo2
  35. // CDefaultSecurityPropertyPage::CDefaultSecurityPropertyPage
  36. // CDefaultSecurityPropertyPage::~CDefaultSecurityPropertyPage
  37. // CDefaultSecurityPropertyPage::DoDataExchange
  38. // CDefaultSecurityPropertyPage::OnInitDialog
  39. // CDefaultSecurityPropertyPage::OnButton1
  40. // CDefaultSecurityPropertyPage::OnButton2
  41. // CDefaultSecurityPropertyPage::OnButton3
  42. //
  43. // History: 23-Apr-96 BruceMa Created.
  44. //
  45. //----------------------------------------------------------------------
  46. #include "stdafx.h"
  47. #include "afxtempl.h"
  48. #include "assert.h"
  49. #include "resource.h"
  50. #include "CStrings.h"
  51. #include "CReg.h"
  52. #include "types.h"
  53. #include "SrvPPg.h"
  54. #include "ClsPSht.h"
  55. #include "newsrvr.h"
  56. #include "datapkt.h"
  57. #if !defined(STANDALONE_BUILD)
  58. extern "C"
  59. {
  60. #include <getuser.h>
  61. }
  62. #endif
  63. #include "util.h"
  64. #include "virtreg.h"
  65. #ifdef _DEBUG
  66. #define new DEBUG_NEW
  67. #undef THIS_FILE
  68. static char BASED_CODE THIS_FILE[] = __FILE__;
  69. #endif
  70. IMPLEMENT_DYNCREATE(CDefaultSecurityPropertyPage, CPropertyPage)
  71. IMPLEMENT_DYNCREATE(CServersPropertyPage, CPropertyPage)
  72. IMPLEMENT_DYNCREATE(CMachinePropertyPage, CPropertyPage)
  73. // The globals used for communicating arguments between dialog classes
  74. CUtility g_util;
  75. CVirtualRegistry g_virtreg;
  76. HKEY g_hAppid;
  77. HKEY *g_rghkCLSID;
  78. unsigned g_cCLSIDs;
  79. TCHAR *g_szAppTitle;
  80. BOOL g_fReboot = FALSE;
  81. TCHAR *g_szAppid;
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CServersPropertyPage property page
  84. CServersPropertyPage::CServersPropertyPage() : CPropertyPage(CServersPropertyPage::IDD)
  85. {
  86. //{{AFX_DATA_INIT(CServersPropertyPage)
  87. // NOTE: the ClassWizard will add member initialization here
  88. //}}AFX_DATA_INIT
  89. m_fApplications = TRUE;
  90. }
  91. CServersPropertyPage::~CServersPropertyPage()
  92. {
  93. }
  94. void CServersPropertyPage::OnProperties()
  95. {
  96. CClsidPropertySheet propSheet;
  97. SItem *pItem;
  98. HKEY hKey;
  99. HKEY *phClsids;
  100. TCHAR szBuf[128];
  101. // Get the selected item
  102. pItem = m_registry.GetItem((DWORD)m_classesLst.GetItemData(m_dwSelection));
  103. // Save the AppID
  104. g_szAppid = (TCHAR*)(LPCTSTR)pItem->szAppid;
  105. // Open the appid key
  106. _tcscpy(szBuf, TEXT("AppId\\"));
  107. _tcscat(szBuf, (LPCTSTR)(pItem->szAppid));
  108. if (RegOpenKeyEx(HKEY_CLASSES_ROOT, szBuf, 0, KEY_ALL_ACCESS, &hKey)
  109. != ERROR_SUCCESS)
  110. {
  111. g_util.PostErrorMessage();
  112. return;
  113. }
  114. // Open a key for each clsid associated with this appid
  115. phClsids = new HKEY[pItem->ulClsids];
  116. if (phClsids == NULL)
  117. {
  118. g_util.PostErrorMessage();
  119. return;
  120. }
  121. for (UINT ul = 0; ul < pItem->ulClsids; ul++)
  122. {
  123. _tcscpy(szBuf, TEXT("ClsId\\"));
  124. _tcscat(szBuf, pItem->ppszClsids[ul]);
  125. if (RegOpenKeyEx(HKEY_CLASSES_ROOT, szBuf, 0, KEY_ALL_ACCESS,
  126. &phClsids[ul])
  127. != ERROR_SUCCESS)
  128. {
  129. g_util.PostErrorMessage();
  130. RegCloseKey(hKey);
  131. for (UINT ul2 = 0; ul2 < ul; ul2++)
  132. {
  133. RegCloseKey(phClsids[ul2]);
  134. }
  135. delete phClsids;
  136. return;
  137. }
  138. }
  139. if (propSheet.InitData(m_szSelection, hKey, phClsids, pItem->ulClsids))
  140. {
  141. propSheet.DoModal();
  142. }
  143. // This is where you would retrieve information from the property
  144. // sheet if propSheet.DoModal() returned IDOK. We aren't doing
  145. // anything for simplicity.
  146. // Close the registry keys we opened for the ClsidPropertySheet
  147. RegCloseKey(hKey);
  148. for (ul = 0; ul < pItem->ulClsids; ul++)
  149. {
  150. RegCloseKey(phClsids[ul]);
  151. }
  152. delete phClsids;
  153. }
  154. void CServersPropertyPage::DoDataExchange(CDataExchange* pDX)
  155. {
  156. CPropertyPage::DoDataExchange(pDX);
  157. //{{AFX_DATA_MAP(CServersPropertyPage)
  158. DDX_Control(pDX, IDC_LIST1, m_classesLst);
  159. //}}AFX_DATA_MAP
  160. GotoDlgCtrl(GetDlgItem(IDC_BUTTON1));
  161. }
  162. BEGIN_MESSAGE_MAP(CServersPropertyPage, CPropertyPage)
  163. //{{AFX_MSG_MAP(CServersPropertyPage)
  164. ON_BN_CLICKED(IDC_BUTTON1, OnServerProperties)
  165. ON_LBN_SELCHANGE(IDC_LIST1, OnList1)
  166. ON_LBN_DBLCLK(IDC_LIST1, OnDoubleclickedList1)
  167. ON_BN_CLICKED(IDC_BUTTON2,OnButton2)
  168. ON_WM_HELPINFO()
  169. //}}AFX_MSG_MAP
  170. END_MESSAGE_MAP()
  171. void CServersPropertyPage::OnServerProperties()
  172. {
  173. m_dwSelection = m_classesLst.GetCurSel();
  174. m_classesLst.GetText(m_dwSelection, m_szSelection);
  175. OnProperties();
  176. }
  177. BOOL CServersPropertyPage::OnInitDialog()
  178. {
  179. // Disable property sheet help button
  180. // m_psp.dwFlags &= ~PSH_HASHELP;
  181. CPropertyPage::OnInitDialog();
  182. // Fetch and display the servers for the types specified
  183. FetchAndDisplayClasses();
  184. GotoDlgCtrl(GetDlgItem(IDC_BUTTON1));
  185. // Invoke the work-around to fix WM_HELP problem on subclassed controls
  186. g_util.FixHelp(this);
  187. return FALSE; // return TRUE unless you set the focus to a control
  188. // EXCEPTION: OCX Property Pages should return FALSE
  189. }
  190. void CServersPropertyPage::FetchAndDisplayClasses(void)
  191. {
  192. // Collect applications
  193. m_registry.Init();
  194. // Clear the list box
  195. m_classesLst.ResetContent();
  196. // Store application names in the list box
  197. SItem *pItem;
  198. while (pItem = m_registry.GetNextItem())
  199. {
  200. if (!pItem->fDontDisplay)
  201. {
  202. if (!pItem->szTitle.IsEmpty())
  203. {
  204. m_classesLst.AddString(pItem->szTitle);
  205. }
  206. else if (!pItem->szItem.IsEmpty())
  207. {
  208. m_classesLst.AddString(pItem->szItem);
  209. }
  210. else
  211. {
  212. m_classesLst.AddString(pItem->szAppid);
  213. }
  214. }
  215. }
  216. // The list box sorted the items during the AddString's, so now we
  217. // have to associate each item with its index in CRegistry
  218. DWORD cbItems = m_registry.GetNumItems();
  219. for (DWORD k = 0; k < cbItems; k++)
  220. {
  221. SItem *pItem = m_registry.GetItem(k);
  222. int iLBItem;
  223. if (!pItem->fDontDisplay)
  224. {
  225. if (!pItem->szTitle.IsEmpty())
  226. {
  227. iLBItem = m_classesLst.FindStringExact(-1, pItem->szTitle);
  228. }
  229. else if (!pItem->szItem.IsEmpty())
  230. {
  231. iLBItem = m_classesLst.FindStringExact(-1, pItem->szItem);
  232. }
  233. else
  234. {
  235. iLBItem = m_classesLst.FindStringExact(-1, pItem->szAppid);
  236. }
  237. m_classesLst.SetItemData(iLBItem, k);
  238. }
  239. }
  240. // Select the first item
  241. m_classesLst.SetCurSel(0);
  242. OnList1();
  243. }
  244. void CServersPropertyPage::OnList1()
  245. {
  246. m_dwSelection = m_classesLst.GetCurSel();
  247. // enable or disable the properties button as necessary
  248. BOOL bEnableState = GetDlgItem(IDC_BUTTON1)->IsWindowEnabled();
  249. BOOL bNewEnableState = m_dwSelection != LB_ERR;
  250. if (bNewEnableState != bEnableState)
  251. GetDlgItem(IDC_BUTTON1)->EnableWindow(bNewEnableState);
  252. m_classesLst.GetText(m_dwSelection, m_szSelection);
  253. }
  254. void CServersPropertyPage::OnDoubleclickedList1()
  255. {
  256. m_dwSelection = m_classesLst.GetCurSel();
  257. m_classesLst.GetText(m_dwSelection, m_szSelection);
  258. OnProperties();
  259. }
  260. void CServersPropertyPage::OnButton2()
  261. {
  262. CNewServer newServerDialog;
  263. newServerDialog.DoModal();
  264. }
  265. /////////////////////////////////////////////////////////////////////////////
  266. // CMachinePropertyPage property page
  267. CMachinePropertyPage::CMachinePropertyPage() : CPropertyPage(CMachinePropertyPage::IDD)
  268. {
  269. //{{AFX_DATA_INIT(CMachinePropertyPage)
  270. //}}AFX_DATA_INIT
  271. m_fEnableDCOM = FALSE;
  272. m_fEnableDCOMIndex = -1;
  273. m_fEnableDCOMHTTP = FALSE;
  274. m_fEnableDCOMHTTPIndex = -1;
  275. m_fEnableRpcProxy = FALSE;
  276. m_fOriginalEnableRpcProxy = FALSE;
  277. m_fEnableRpcProxyIndex = -1;
  278. m_authLevel = Connect;
  279. m_authLevelIndex = -1;
  280. m_impersonateLevel = Identify;
  281. m_impersonateLevelIndex = -1;
  282. m_fLegacySecureReferences = FALSE;
  283. m_fLegacySecureReferencesIndex = -1;
  284. }
  285. CMachinePropertyPage::~CMachinePropertyPage()
  286. {
  287. }
  288. void CMachinePropertyPage::DoDataExchange(CDataExchange* pDX)
  289. {
  290. CPropertyPage::DoDataExchange(pDX);
  291. //{{AFX_DATA_MAP(CMachinePropertyPage)
  292. DDX_Control(pDX, IDC_ENABLEINTERNET, m_EnableDCOMInternet);
  293. DDX_Control(pDX, IDC_CHECK2, m_legacySecureReferencesChk);
  294. DDX_Control(pDX, IDC_CHECK1, m_EnableDCOMChk);
  295. DDX_Control(pDX, IDC_COMBO2, m_impersonateLevelCBox);
  296. DDX_Control(pDX, IDC_COMBO1, m_authLevelCBox);
  297. //}}AFX_DATA_MAP
  298. }
  299. BEGIN_MESSAGE_MAP(CMachinePropertyPage, CPropertyPage)
  300. //{{AFX_MSG_MAP(CMachinePropertyPage)
  301. ON_BN_CLICKED(IDC_COMBO1, OnCombo1)
  302. ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
  303. ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
  304. ON_CBN_EDITCHANGE(IDC_COMBO1, OnEditchangeCombo1)
  305. ON_CBN_EDITCHANGE(IDC_COMBO2, OnEditchangeCombo2)
  306. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  307. ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
  308. ON_WM_HELPINFO()
  309. ON_BN_CLICKED(IDC_ENABLEINTERNET, OnChkEnableInternet)
  310. //}}AFX_MSG_MAP
  311. END_MESSAGE_MAP()
  312. BOOL CMachinePropertyPage::OnInitDialog()
  313. {
  314. int iIndex;
  315. // Disable property sheet help button
  316. // m_psp.dwFlags &= ~PSH_HASHELP;
  317. CPropertyPage::OnInitDialog();
  318. // Populate the authentication combo boxe
  319. CString sTemp;
  320. m_authLevelCBox.ResetContent();
  321. // Associate values with entries
  322. sTemp.LoadString(IDS_DEFAULT);
  323. iIndex = m_authLevelCBox.AddString(sTemp);
  324. m_authLevelCBox.SetItemData(iIndex, Defaultx);
  325. sTemp.LoadString(IDS_NONE);
  326. iIndex = m_authLevelCBox.AddString(sTemp);
  327. m_authLevelCBox.SetItemData(iIndex, None);
  328. sTemp.LoadString(IDS_CONNECT);
  329. iIndex = m_authLevelCBox.AddString(sTemp);
  330. m_authLevelCBox.SetItemData(iIndex, Connect);
  331. sTemp.LoadString(IDS_CALL);
  332. iIndex = m_authLevelCBox.AddString(sTemp);
  333. m_authLevelCBox.SetItemData(iIndex, Call);
  334. sTemp.LoadString(IDS_PACKET);
  335. iIndex = m_authLevelCBox.AddString(sTemp);
  336. m_authLevelCBox.SetItemData(iIndex, Packet);
  337. sTemp.LoadString(IDS_PACKETINTEGRITY);
  338. iIndex = m_authLevelCBox.AddString(sTemp);
  339. m_authLevelCBox.SetItemData(iIndex, PacketIntegrity);
  340. sTemp.LoadString(IDS_PACKETPRIVACY);
  341. iIndex = m_authLevelCBox.AddString(sTemp);
  342. m_authLevelCBox.SetItemData(iIndex, PacketPrivacy);
  343. // Populate the impersonation level combo box
  344. m_impersonateLevelCBox.ResetContent();
  345. // Associate values with entries
  346. sTemp.LoadString(IDS_ANONYMOUS);
  347. iIndex = m_impersonateLevelCBox.AddString(sTemp);
  348. m_impersonateLevelCBox.SetItemData(iIndex, Anonymous);
  349. sTemp.LoadString(IDS_IDENTIFY);
  350. iIndex = m_impersonateLevelCBox.AddString(sTemp);
  351. m_impersonateLevelCBox.SetItemData(iIndex, Identify);
  352. sTemp.LoadString(IDS_IMPERSONATE);
  353. iIndex = m_impersonateLevelCBox.AddString(sTemp);
  354. m_impersonateLevelCBox.SetItemData(iIndex, Impersonate);
  355. sTemp.LoadString(IDS_DELEGATE);
  356. iIndex = m_impersonateLevelCBox.AddString(sTemp);
  357. m_impersonateLevelCBox.SetItemData(iIndex, Delegate);
  358. // Set defaults
  359. // EnableDCOM is unchecked initially
  360. m_authLevelCBox.SetCurSel(Connect);
  361. m_impersonateLevelCBox.SetCurSel(Identify);
  362. // Attempt to read HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLE.EnableDCOM
  363. int err;
  364. err = g_virtreg.ReadRegSzNamedValue(HKEY_LOCAL_MACHINE,
  365. TEXT("SOFTWARE\\Microsoft\\OLE"),
  366. TEXT("EnableDCOM"),
  367. &m_fEnableDCOMIndex);
  368. if (err == ERROR_SUCCESS)
  369. {
  370. CRegSzNamedValueDp * pCdp = (CRegSzNamedValueDp*)g_virtreg.GetAt(m_fEnableDCOMIndex);
  371. CString sTmp = pCdp->Value();
  372. if (sTmp[0] == TEXT('y') ||
  373. sTmp[0] == TEXT('Y'))
  374. {
  375. m_fEnableDCOM = TRUE;
  376. }
  377. }
  378. else if (err != ERROR_ACCESS_DENIED && err !=
  379. ERROR_FILE_NOT_FOUND)
  380. {
  381. g_util.PostErrorMessage();
  382. }
  383. // Attempt to read HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLE.EnableInternetDCOM
  384. err = g_virtreg.ReadRegSzNamedValue(HKEY_LOCAL_MACHINE,
  385. TEXT("SOFTWARE\\Microsoft\\OLE"),
  386. TEXT("EnableDCOMHTTP"),
  387. &m_fEnableDCOMHTTPIndex);
  388. if (err == ERROR_SUCCESS)
  389. {
  390. CRegSzNamedValueDp * pCdp = (CRegSzNamedValueDp*)g_virtreg.GetAt(m_fEnableDCOMHTTPIndex);
  391. CString sTmp = pCdp->Value();
  392. if (m_fEnableDCOM &&
  393. ((sTmp[0] == TEXT('y')) ||
  394. (sTmp[0] == TEXT('Y'))))
  395. {
  396. m_fEnableDCOMHTTP = TRUE;
  397. }
  398. }
  399. else if (err != ERROR_ACCESS_DENIED && err !=
  400. ERROR_FILE_NOT_FOUND)
  401. {
  402. g_util.PostErrorMessage();
  403. }
  404. // Attempt to read HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\RpcProxy\Enabled
  405. err = g_virtreg.ReadRegDwordNamedValue(HKEY_LOCAL_MACHINE,
  406. TEXT("SOFTWARE\\Microsoft\\Rpc\\RpcProxy"),
  407. TEXT("Enabled"),
  408. &m_fEnableRpcProxyIndex);
  409. if (err == ERROR_SUCCESS)
  410. {
  411. CDataPacket * pCdp = (CDataPacket*)g_virtreg.GetAt(m_fEnableRpcProxyIndex);
  412. DWORD dwTmp = pCdp -> GetDwordValue();
  413. if (dwTmp)
  414. {
  415. m_fEnableRpcProxy = TRUE;
  416. m_fOriginalEnableRpcProxy = TRUE;
  417. }
  418. }
  419. else if ((err != ERROR_ACCESS_DENIED) && (err != ERROR_FILE_NOT_FOUND))
  420. {
  421. g_util.PostErrorMessage();
  422. }
  423. // enable proxy if dcomhttp is enabled
  424. if (m_fEnableDCOMHTTP)
  425. {
  426. m_fEnableRpcProxy = TRUE;
  427. if (m_fEnableRpcProxyIndex == -1)
  428. {
  429. g_virtreg.NewRegDwordNamedValue(HKEY_LOCAL_MACHINE,
  430. TEXT("SOFTWARE\\Microsoft\\Rpc\\RpcProxy"),
  431. TEXT("Enabled"),
  432. 1,
  433. &m_fEnableRpcProxyIndex);
  434. }
  435. // Else simply update it in the virtual registry
  436. else
  437. {
  438. g_virtreg.ChgRegDwordNamedValue(m_fEnableRpcProxyIndex,1);
  439. }
  440. }
  441. // Attempt to read HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLE.
  442. // LegacyAuthenticationLevel
  443. err = g_virtreg.ReadRegDwordNamedValue(HKEY_LOCAL_MACHINE,
  444. TEXT("SOFTWARE\\Microsoft\\OLE"),
  445. TEXT("LegacyAuthenticationLevel"),
  446. &m_authLevelIndex);
  447. if (err == ERROR_SUCCESS)
  448. {
  449. CDataPacket * pCdp = g_virtreg.GetAt(m_authLevelIndex);
  450. m_authLevel = (AUTHENTICATIONLEVEL) pCdp->GetDwordValue();
  451. }
  452. else if (err != ERROR_ACCESS_DENIED && err !=
  453. ERROR_FILE_NOT_FOUND)
  454. {
  455. g_util.PostErrorMessage();
  456. }
  457. // Attempt to read HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLE.
  458. // LegacyImpersonationLevel
  459. err = g_virtreg.ReadRegDwordNamedValue(HKEY_LOCAL_MACHINE,
  460. TEXT("SOFTWARE\\Microsoft\\OLE"),
  461. TEXT("LegacyImpersonationLevel"),
  462. &m_impersonateLevelIndex);
  463. if (err == ERROR_SUCCESS)
  464. {
  465. CDataPacket * pCdp = g_virtreg.GetAt(m_impersonateLevelIndex);
  466. m_impersonateLevel = (IMPERSONATIONLEVEL) pCdp->GetDwordValue();
  467. }
  468. else if (err != ERROR_ACCESS_DENIED && err !=
  469. ERROR_FILE_NOT_FOUND)
  470. {
  471. g_util.PostErrorMessage();
  472. }
  473. // Attempt to read HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLE.
  474. // LegacySecureReferences
  475. err = g_virtreg.ReadRegSzNamedValue(HKEY_LOCAL_MACHINE,
  476. TEXT("SOFTWARE\\Microsoft\\OLE"),
  477. TEXT("LegacySecureReferences"),
  478. &m_fLegacySecureReferencesIndex );
  479. if (err == ERROR_SUCCESS)
  480. {
  481. CRegSzNamedValueDp * pCdp = (CRegSzNamedValueDp*)g_virtreg.GetAt(m_fLegacySecureReferencesIndex);
  482. CString sTmp = pCdp->Value();
  483. if (sTmp[0] == TEXT('y') ||
  484. sTmp[0] == TEXT('Y'))
  485. {
  486. m_fLegacySecureReferences = TRUE;
  487. }
  488. }
  489. else if (err != ERROR_ACCESS_DENIED && err !=
  490. ERROR_FILE_NOT_FOUND)
  491. {
  492. g_util.PostErrorMessage();
  493. }
  494. // Set the controls according to the current values
  495. // EnableDCOM
  496. if (m_fEnableDCOM)
  497. {
  498. m_EnableDCOMChk.SetCheck(1);
  499. GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
  500. GetDlgItem(IDC_COMBO2)->EnableWindow(TRUE);
  501. GetDlgItem(IDC_CHECK2)->EnableWindow(TRUE);
  502. GetDlgItem(IDC_ENABLEINTERNET)->EnableWindow(TRUE);
  503. }
  504. else
  505. {
  506. m_EnableDCOMChk.SetCheck(0);
  507. GetDlgItem(IDC_ENABLEINTERNET)->EnableWindow(FALSE);
  508. }
  509. m_EnableDCOMInternet.SetCheck(m_fEnableDCOMHTTP);
  510. // AuthenticationLevel
  511. for (int k = 0; k < m_authLevelCBox.GetCount(); k++)
  512. {
  513. if (((AUTHENTICATIONLEVEL) m_authLevelCBox.GetItemData(k)) ==
  514. m_authLevel)
  515. {
  516. m_authLevelCBox.SetCurSel(k);
  517. break;
  518. }
  519. }
  520. // ImpersonationLevel
  521. for (k = 0; k < m_impersonateLevelCBox.GetCount(); k++)
  522. {
  523. if (((AUTHENTICATIONLEVEL) m_impersonateLevelCBox.GetItemData(k)) ==
  524. m_impersonateLevel)
  525. {
  526. m_impersonateLevelCBox.SetCurSel(k);
  527. break;
  528. }
  529. }
  530. // LegacySecureReferences
  531. if (m_fLegacySecureReferences)
  532. {
  533. m_legacySecureReferencesChk.SetCheck(1);
  534. }
  535. else
  536. {
  537. m_legacySecureReferencesChk.SetCheck(0);
  538. }
  539. // Invoke the work-around to fix WM_HELP problem on subclassed controls
  540. g_util.FixHelp(this);
  541. return TRUE; // return TRUE unless you set the focus to a control
  542. // EXCEPTION: OCX Property Pages should return FALSE
  543. }
  544. void CMachinePropertyPage::OnCombo1()
  545. {
  546. m_authLevelCBox.ShowDropDown(TRUE);
  547. }
  548. void CMachinePropertyPage::OnCheck1()
  549. {
  550. // Flip the EnableDCOM flag
  551. m_fEnableDCOM ^= 1;
  552. // Disable or enable the other dialog controls:
  553. GetDlgItem(IDC_COMBO1)->EnableWindow(m_fEnableDCOM);
  554. GetDlgItem(IDC_COMBO2)->EnableWindow(m_fEnableDCOM);
  555. GetDlgItem(IDC_CHECK2)->EnableWindow(m_fEnableDCOM);
  556. GetDlgItem(IDC_ENABLEINTERNET)->EnableWindow(m_fEnableDCOM);
  557. // Virtually write it to the registry
  558. if (m_fEnableDCOMIndex == -1)
  559. {
  560. g_virtreg.NewRegSzNamedValue(HKEY_LOCAL_MACHINE,
  561. TEXT("SOFTWARE\\Microsoft\\OLE"),
  562. TEXT("EnableDCOM"),
  563. m_fEnableDCOM ? _T("Y") : _T("N"),
  564. &m_fEnableDCOMIndex);
  565. }
  566. // Else simply update it in the virtual registry
  567. else
  568. {
  569. g_virtreg.ChgRegSzNamedValue(m_fEnableDCOMIndex,
  570. m_fEnableDCOM ? _T("Y") : _T("N"));
  571. }
  572. // This is a reboot event
  573. g_fReboot = TRUE;
  574. // Enable the Apply button
  575. SetModified(TRUE);
  576. }
  577. void CMachinePropertyPage::OnChkEnableInternet()
  578. {
  579. // Flip the EnableDCOM flag
  580. m_fEnableDCOMHTTP ^= 1;
  581. // if Com Internet services are enable then enable proxy
  582. // otherwise set it to its original value in case non DCOM RPC application is using it
  583. if (m_fEnableDCOMHTTP)
  584. m_fEnableRpcProxy = TRUE;
  585. else
  586. m_fEnableRpcProxy = m_fOriginalEnableRpcProxy;
  587. // Virtually write it to the registry
  588. if (m_fEnableDCOMHTTPIndex == -1)
  589. {
  590. g_virtreg.NewRegSzNamedValue(HKEY_LOCAL_MACHINE,
  591. TEXT("SOFTWARE\\Microsoft\\OLE"),
  592. TEXT("EnableDCOMHTTP"),
  593. m_fEnableDCOMHTTP ? _T("Y") : _T("N"),
  594. &m_fEnableDCOMHTTPIndex);
  595. }
  596. // Else simply update it in the virtual registry
  597. else
  598. {
  599. g_virtreg.ChgRegSzNamedValue(m_fEnableDCOMHTTPIndex,
  600. m_fEnableDCOMHTTP ? _T("Y") : _T("N"));
  601. }
  602. if (m_fEnableRpcProxyIndex == -1)
  603. {
  604. g_virtreg.NewRegDwordNamedValue(HKEY_LOCAL_MACHINE,
  605. TEXT("SOFTWARE\\Microsoft\\Rpc\\RpcProxy"),
  606. TEXT("Enabled"),
  607. m_fEnableRpcProxy ? 1 : 0,
  608. &m_fEnableRpcProxyIndex);
  609. }
  610. // Else simply update it in the virtual registry
  611. else
  612. {
  613. g_virtreg.ChgRegDwordNamedValue(m_fEnableRpcProxyIndex,
  614. m_fEnableRpcProxy ? 1 : 0);
  615. }
  616. // This is a reboot event
  617. g_fReboot = TRUE;
  618. // Enable the Apply button
  619. SetModified(TRUE);
  620. }
  621. void CMachinePropertyPage::OnCheck2()
  622. {
  623. // Flip LegacySecureeferences flag
  624. m_fLegacySecureReferences ^= 1;
  625. // Virtually write it to the registry
  626. if (m_fLegacySecureReferencesIndex == -1)
  627. {
  628. g_virtreg.NewRegSzNamedValue(HKEY_LOCAL_MACHINE,
  629. TEXT("SOFTWARE\\Microsoft\\OLE"),
  630. TEXT("LegacySecureReferences"),
  631. m_fLegacySecureReferences ? _T("Y")
  632. : _T("N"),
  633. &m_fLegacySecureReferencesIndex);
  634. }
  635. // Else simply update it in the virtual registry
  636. else
  637. {
  638. g_virtreg.ChgRegSzNamedValue(m_fLegacySecureReferencesIndex,
  639. m_fLegacySecureReferences ? _T("Y") : _T("N"));
  640. }
  641. // This is a reboot event
  642. g_fReboot = TRUE;
  643. // Enable the Apply button
  644. SetModified(TRUE);
  645. }
  646. void CMachinePropertyPage::OnEditchangeCombo1()
  647. {
  648. }
  649. void CMachinePropertyPage::OnSelchangeCombo1()
  650. {
  651. int iSel;
  652. // Get the new selection
  653. iSel = m_authLevelCBox.GetCurSel();
  654. m_authLevel = (AUTHENTICATIONLEVEL) m_authLevelCBox.GetItemData(iSel);
  655. // Virtually write it to the registry
  656. if (m_authLevelIndex == -1)
  657. {
  658. g_virtreg.NewRegDwordNamedValue(HKEY_LOCAL_MACHINE,
  659. TEXT("SOFTWARE\\Microsoft\\OLE"),
  660. TEXT("LegacyAuthenticationLevel"),
  661. m_authLevel,
  662. &m_authLevelIndex);
  663. }
  664. else
  665. {
  666. g_virtreg.ChgRegDwordNamedValue(m_authLevelIndex,
  667. m_authLevel);
  668. }
  669. // This is a reboot event
  670. g_fReboot = TRUE;
  671. // Enable the Apply button
  672. SetModified(TRUE);
  673. }
  674. void CMachinePropertyPage::OnEditchangeCombo2()
  675. {
  676. }
  677. void CMachinePropertyPage::OnSelchangeCombo2()
  678. {
  679. int iSel;
  680. // Get the new selection
  681. iSel = m_impersonateLevelCBox.GetCurSel();
  682. m_impersonateLevel =
  683. (IMPERSONATIONLEVEL) m_impersonateLevelCBox.GetItemData(iSel);
  684. // Virtually write it to the registry
  685. if (m_impersonateLevelIndex == -1)
  686. {
  687. g_virtreg.NewRegDwordNamedValue(HKEY_LOCAL_MACHINE,
  688. TEXT("SOFTWARE\\Microsoft\\OLE"),
  689. TEXT("LegacyImpersonationLevel"),
  690. m_impersonateLevel,
  691. &m_impersonateLevelIndex);
  692. }
  693. else
  694. {
  695. g_virtreg.ChgRegDwordNamedValue(m_impersonateLevelIndex,
  696. m_impersonateLevel);
  697. }
  698. // This is a reboot event
  699. g_fReboot = TRUE;
  700. // Enable the Apply button
  701. SetModified(TRUE);
  702. }
  703. /////////////////////////////////////////////////////////////////////////////
  704. // CDefaultSecurityPropertyPage property page
  705. CDefaultSecurityPropertyPage::CDefaultSecurityPropertyPage() : CPropertyPage(CDefaultSecurityPropertyPage::IDD)
  706. {
  707. //{{AFX_DATA_INIT(CDefaultSecurityPropertyPage)
  708. // NOTE: the ClassWizard will add member initialization here
  709. //}}AFX_DATA_INIT
  710. m_accessPermissionIndex = -1;
  711. m_launchPermissionIndex = -1;
  712. m_configurationPermissionIndex = -1;
  713. m_fAccessChecked = FALSE;
  714. }
  715. CDefaultSecurityPropertyPage::~CDefaultSecurityPropertyPage()
  716. {
  717. }
  718. void CDefaultSecurityPropertyPage::DoDataExchange(CDataExchange* pDX)
  719. {
  720. CPropertyPage::DoDataExchange(pDX);
  721. //{{AFX_DATA_MAP(CDefaultSecurityPropertyPage)
  722. // NOTE: the ClassWizard will add DDX and DDV calls here
  723. //}}AFX_DATA_MAP
  724. }
  725. BEGIN_MESSAGE_MAP(CDefaultSecurityPropertyPage, CPropertyPage)
  726. //{{AFX_MSG_MAP(CDefaultSecurityPropertyPage)
  727. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  728. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  729. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  730. ON_WM_HELPINFO()
  731. //}}AFX_MSG_MAP
  732. END_MESSAGE_MAP()
  733. // Default access permissions
  734. BOOL CDefaultSecurityPropertyPage::OnInitDialog(void)
  735. {
  736. BOOL fPostMsg = FALSE;
  737. // Disable property sheet help button
  738. // m_psp.dwFlags &= ~PSH_HASHELP;
  739. if (!m_fAccessChecked)
  740. {
  741. // Check whether we are denied access to
  742. // HKEY_LOCAL_MACHINE
  743. if (!g_util.CkAccessRights(HKEY_LOCAL_MACHINE, NULL))
  744. {
  745. GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);
  746. fPostMsg = TRUE;
  747. }
  748. // Post a message to the user
  749. if (fPostMsg)
  750. {
  751. CString sMsg;
  752. CString sCaption;
  753. sMsg.LoadString(IDS_ACCESSDENIED);
  754. sCaption.LoadString(IDS_SYSTEMMESSAGE);
  755. MessageBox(sMsg, sCaption, MB_OK);
  756. }
  757. }
  758. m_fAccessChecked = TRUE;
  759. return TRUE;
  760. }
  761. // Default access permissions
  762. void CDefaultSecurityPropertyPage::OnButton1()
  763. {
  764. int err;
  765. // Invoke the ACL editor
  766. err = g_util.ACLEditor(m_hWnd,
  767. HKEY_LOCAL_MACHINE,
  768. TEXT("SOFTWARE\\Microsoft\\OLE"),
  769. TEXT("DefaultAccessPermission"),
  770. &m_accessPermissionIndex,
  771. SingleACL,
  772. dcomAclAccess);
  773. // Enable the Apply button
  774. if (err == ERROR_SUCCESS)
  775. {
  776. // This is a reboot event
  777. g_fReboot = TRUE;
  778. SetModified(TRUE);
  779. }
  780. }
  781. // Default launch permissions
  782. void CDefaultSecurityPropertyPage::OnButton2()
  783. {
  784. int err;
  785. // Invoke the ACL editor
  786. err = g_util.ACLEditor(m_hWnd,
  787. HKEY_LOCAL_MACHINE,
  788. TEXT("SOFTWARE\\Microsoft\\OLE"),
  789. TEXT("DefaultLaunchPermission"),
  790. &m_launchPermissionIndex,
  791. SingleACL,
  792. dcomAclLaunch);
  793. // Enable the Apply button
  794. if (err == ERROR_SUCCESS)
  795. {
  796. // This is a reboot event
  797. g_fReboot = TRUE;
  798. SetModified(TRUE);
  799. }
  800. }
  801. // Default configuration permissions
  802. void CDefaultSecurityPropertyPage::OnButton3()
  803. {
  804. int err;
  805. err = g_util.ACLEditor2(m_hWnd,
  806. HKEY_CLASSES_ROOT,
  807. NULL,
  808. 0,
  809. NULL,
  810. &m_configurationPermissionIndex,
  811. RegKeyACL);
  812. // Enable the Apply button
  813. if (err == ERROR_SUCCESS)
  814. SetModified(TRUE);
  815. }
  816. BOOL CDefaultSecurityPropertyPage::OnHelpInfo(HELPINFO* pHelpInfo)
  817. {
  818. if(-1 != pHelpInfo->iCtrlId)
  819. {
  820. WORD hiWord = 0x8000 | CDefaultSecurityPropertyPage::IDD;
  821. WORD loWord = (WORD) pHelpInfo->iCtrlId;
  822. DWORD dwLong = MAKELONG(loWord,hiWord);
  823. WinHelp(dwLong, HELP_CONTEXTPOPUP);
  824. return TRUE;
  825. }
  826. else
  827. {
  828. return CPropertyPage::OnHelpInfo(pHelpInfo);
  829. }
  830. return CPropertyPage::OnHelpInfo(pHelpInfo);
  831. }
  832. BOOL CMachinePropertyPage::OnHelpInfo(HELPINFO* pHelpInfo)
  833. {
  834. if(-1 != pHelpInfo->iCtrlId)
  835. {
  836. WORD hiWord = 0x8000 | CMachinePropertyPage::IDD;
  837. WORD loWord = (WORD) pHelpInfo->iCtrlId;
  838. DWORD dwLong = MAKELONG(loWord,hiWord);
  839. WinHelp(dwLong, HELP_CONTEXTPOPUP);
  840. return TRUE;
  841. }
  842. else
  843. {
  844. return CPropertyPage::OnHelpInfo(pHelpInfo);
  845. }
  846. }
  847. BOOL CServersPropertyPage::OnHelpInfo(HELPINFO* pHelpInfo)
  848. {
  849. if(-1 != pHelpInfo->iCtrlId)
  850. {
  851. WORD hiWord = 0x8000 | CServersPropertyPage::IDD;
  852. WORD loWord = (WORD) pHelpInfo->iCtrlId;
  853. DWORD dwLong = MAKELONG(loWord,hiWord);
  854. WinHelp(dwLong, HELP_CONTEXTPOPUP);
  855. return TRUE;
  856. }
  857. else
  858. {
  859. return CPropertyPage::OnHelpInfo(pHelpInfo);
  860. }
  861. }