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.

279 lines
9.3 KiB

  1. #include "precomp.h"
  2. #include "rsop.h"
  3. #include <tchar.h>
  4. /////////////////////////////////////////////////////////////////////
  5. void InitSecAuthDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  6. {
  7. __try
  8. {
  9. BOOL bImport = FALSE;
  10. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  11. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass);
  12. if (SUCCEEDED(hr))
  13. {
  14. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  15. long nPSObjects = pDRD->GetPSObjCount();
  16. BOOL bImportHandled = FALSE;
  17. BOOL bEnableHandled = FALSE;
  18. for (long nObj = 0; nObj < nPSObjects; nObj++)
  19. {
  20. // importAuthenticodeSecurityInfo field
  21. _variant_t vtValue;
  22. if (!bImportHandled)
  23. {
  24. hr = paPSObj[nObj]->pObj->Get(L"importAuthenticodeSecurityInfo", 0, &vtValue, NULL, NULL);
  25. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  26. {
  27. //TODO: uncomment bImport = (bool)vtValue ? TRUE : FALSE;
  28. CheckRadioButton(hDlg, IDC_NOAUTH, IDC_IMPORTAUTH,
  29. (bool)vtValue ? IDC_IMPORTAUTH : IDC_NOAUTH);
  30. DWORD dwCurGPOPrec = GetGPOPrecedence(paPSObj[nObj]->pObj);
  31. pDRD->SetImportedAuthenticodePrec(dwCurGPOPrec);
  32. bImportHandled = TRUE;
  33. }
  34. }
  35. // enableTrustedPublisherLockdown field
  36. vtValue;
  37. if (!bEnableHandled)
  38. {
  39. hr = paPSObj[nObj]->pObj->Get(L"enableTrustedPublisherLockdown", 0, &vtValue, NULL, NULL);
  40. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  41. {
  42. if ((bool)vtValue)
  43. CheckDlgButton(hDlg, IDC_TPL, BST_CHECKED);
  44. bEnableHandled = TRUE;
  45. }
  46. }
  47. // no need to process other GPOs since enabled properties have been found
  48. if (bImportHandled && bEnableHandled)
  49. break;
  50. }
  51. }
  52. EnableDlgItem2(hDlg, IDC_NOAUTH, FALSE);
  53. EnableDlgItem2(hDlg, IDC_IMPORTAUTH, FALSE);
  54. EnableDlgItem2(hDlg, IDC_MODIFYAUTH, bImport);
  55. EnableDlgItem2(hDlg, IDC_TPL, FALSE);
  56. }
  57. __except(TRUE)
  58. {
  59. }
  60. }
  61. /////////////////////////////////////////////////////////////////////
  62. HRESULT InitSecAuthPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  63. {
  64. HRESULT hr = NOERROR;
  65. __try
  66. {
  67. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  68. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  69. if (SUCCEEDED(hr))
  70. {
  71. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  72. long nPSObjects = pDRD->GetPSObjCount();
  73. for (long nObj = 0; nObj < nPSObjects; nObj++)
  74. {
  75. _bstr_t bstrGPOName = pDRD->GetGPONameFromPS(paPSObj[nObj]->pObj);
  76. // importAuthenticodeSecurityInfo field
  77. BOOL bImport = FALSE;
  78. _variant_t vtValue;
  79. hr = paPSObj[nObj]->pObj->Get(L"importAuthenticodeSecurityInfo", 0, &vtValue, NULL, NULL);
  80. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  81. bImport = (bool)vtValue ? TRUE : FALSE;
  82. _bstr_t bstrSetting;
  83. if (bImport)
  84. {
  85. TCHAR szTemp[MAX_PATH];
  86. LoadString(g_hInstance, IDS_IMPORT_AUTHSEC_SETTING, szTemp, countof(szTemp));
  87. bstrSetting = szTemp;
  88. }
  89. else
  90. bstrSetting = GetDisabledString();
  91. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  92. }
  93. }
  94. }
  95. __except(TRUE)
  96. {
  97. }
  98. return hr;
  99. }
  100. /////////////////////////////////////////////////////////////////////
  101. HRESULT InitAuthLockdownPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  102. {
  103. HRESULT hr = NOERROR;
  104. __try
  105. {
  106. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  107. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  108. if (SUCCEEDED(hr))
  109. {
  110. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  111. long nPSObjects = pDRD->GetPSObjCount();
  112. for (long nObj = 0; nObj < nPSObjects; nObj++)
  113. {
  114. _bstr_t bstrGPOName = pDRD->GetGPONameFromPS(paPSObj[nObj]->pObj);
  115. // enableTrustedPublisherLockdown field
  116. BOOL bImport = FALSE;
  117. _variant_t vtValue;
  118. hr = paPSObj[nObj]->pObj->Get(L"enableTrustedPublisherLockdown", 0, &vtValue, NULL, NULL);
  119. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  120. bImport = (bool)vtValue ? TRUE : FALSE;
  121. _bstr_t bstrSetting;
  122. if (bImport)
  123. {
  124. TCHAR szTemp[MAX_PATH];
  125. LoadString(g_hInstance, IDS_ENABLE_PUB_LOCK_SETTING, szTemp, countof(szTemp));
  126. bstrSetting = szTemp;
  127. }
  128. else
  129. bstrSetting = GetDisabledString();
  130. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  131. }
  132. }
  133. }
  134. __except(TRUE)
  135. {
  136. }
  137. return hr;
  138. }
  139. /////////////////////////////////////////////////////////////////////
  140. INT_PTR CALLBACK SecurityAuthDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  141. {
  142. // Retrieve Property Sheet Page info for each call into dlg proc.
  143. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  144. TCHAR szWorkDir[MAX_PATH],
  145. szInf[MAX_PATH];
  146. BOOL fImport;
  147. switch (uMsg)
  148. {
  149. case WM_SETFONT:
  150. //a change to mmc requires us to do this logic for all our property pages that use common controls
  151. INITCOMMONCONTROLSEX iccx;
  152. iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
  153. iccx.dwICC = ICC_ANIMATE_CLASS | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES |ICC_TREEVIEW_CLASSES;
  154. InitCommonControlsEx(&iccx);
  155. break;
  156. case WM_INITDIALOG:
  157. SetPropSheetCookie(hDlg, lParam);
  158. // find out if this dlg is in RSoP mode
  159. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  160. if (psCookie->pCS->IsRSoP())
  161. {
  162. CheckRadioButton(hDlg, IDC_NOAUTH, IDC_IMPORTAUTH, IDC_NOAUTH);
  163. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  164. if (pDRD)
  165. InitSecAuthDlgInRSoPMode(hDlg, pDRD);
  166. }
  167. break;
  168. case WM_DESTROY:
  169. if (psCookie->pCS->IsRSoP())
  170. DestroyDlgRSoPData(hDlg);
  171. break;
  172. case WM_NOTIFY:
  173. switch (((LPNMHDR)lParam)->code)
  174. {
  175. case PSN_SETACTIVE:
  176. // don't do any of this stuff in RSoP mode
  177. if (!psCookie->pCS->IsRSoP())
  178. {
  179. // authenticode
  180. fImport = InsGetBool(IS_SITECERTS, TEXT("ImportAuthCode"), FALSE, GetInsFile(hDlg));
  181. CheckRadioButton(hDlg, IDC_NOAUTH, IDC_IMPORTAUTH, fImport ? IDC_IMPORTAUTH : IDC_NOAUTH);
  182. EnableDlgItem2(hDlg, IDC_MODIFYAUTH, fImport);
  183. ReadBoolAndCheckButton(IS_SITECERTS, IK_TRUSTPUBLOCK, FALSE, GetInsFile(hDlg), hDlg, IDC_TPL);
  184. }
  185. break;
  186. case PSN_APPLY:
  187. if (psCookie->pCS->IsRSoP())
  188. return FALSE;
  189. else
  190. {
  191. if (!AcquireWriteCriticalSection(hDlg))
  192. {
  193. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  194. break;
  195. }
  196. // process authenticode
  197. CreateWorkDir(GetInsFile(hDlg), IEAK_GPE_BRANDING_SUBDIR TEXT("\\AUTHCODE"), szWorkDir);
  198. PathCombine(szInf, szWorkDir, TEXT("authcode.inf"));
  199. ImportAuthCode(GetInsFile(hDlg), NULL, szInf, IsDlgButtonChecked(hDlg, IDC_IMPORTAUTH) == BST_CHECKED);
  200. if (PathIsDirectoryEmpty(szWorkDir))
  201. PathRemovePath(szWorkDir);
  202. InsWriteBoolEx(IS_SITECERTS, IK_TRUSTPUBLOCK, (IsDlgButtonChecked(hDlg, IDC_TPL) == BST_CHECKED), GetInsFile(hDlg));
  203. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  204. }
  205. break;
  206. case PSN_HELP:
  207. ShowHelpTopic(hDlg);
  208. break;
  209. default:
  210. return FALSE;
  211. }
  212. break;
  213. case WM_COMMAND:
  214. if (GET_WM_COMMAND_CMD(wParam, lParam) != BN_CLICKED)
  215. return FALSE;
  216. switch (GET_WM_COMMAND_ID(wParam, lParam))
  217. {
  218. case IDC_NOAUTH:
  219. DisableDlgItem(hDlg, IDC_MODIFYAUTH);
  220. break;
  221. case IDC_IMPORTAUTH:
  222. EnableDlgItem(hDlg, IDC_MODIFYAUTH);
  223. break;
  224. case IDC_MODIFYAUTH:
  225. ModifyAuthCode(hDlg);
  226. break;
  227. default:
  228. return FALSE;
  229. }
  230. break;
  231. case WM_HELP:
  232. ShowHelpTopic(hDlg);
  233. break;
  234. default:
  235. return FALSE;
  236. }
  237. return TRUE;
  238. }