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.

1519 lines
63 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 2001.
  5. //
  6. // File: delobjs.cpp
  7. //
  8. // Contents: Functions for handling the deletion of template objects
  9. //
  10. //---------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "afxdlgs.h"
  13. #include "cookie.h"
  14. #include "snapmgr.h"
  15. #include "wrapper.h"
  16. #include "util.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. HRESULT CSnapin::OnDeleteObjects(
  23. LPDATAOBJECT pDataObj,
  24. DATA_OBJECT_TYPES cctType,
  25. MMC_COOKIE cookie,
  26. LPARAM arg,
  27. LPARAM param)
  28. {
  29. if ( 0 == cookie)
  30. return S_OK;
  31. if (NULL == pDataObj)
  32. return S_OK;
  33. INTERNAL *pAllInternals, *pInternal;
  34. pAllInternals = ExtractInternalFormat( pDataObj );
  35. //
  36. // Find out if this is a mutli select item.
  37. //
  38. int iCnt = 1;
  39. pInternal = pAllInternals;
  40. if(!pInternal)
  41. return S_OK;
  42. if(pAllInternals && pAllInternals->m_cookie == (MMC_COOKIE)MMC_MULTI_SELECT_COOKIE)
  43. {
  44. pInternal = pAllInternals;
  45. iCnt = (int)pInternal->m_type;
  46. pInternal++;
  47. }
  48. CFolder *pFolder = m_pSelectedFolder;
  49. BOOL bAsk = TRUE;
  50. while( iCnt-- ){
  51. cookie = pInternal->m_cookie;
  52. cctType = pInternal->m_type;
  53. if ( cctType == CCT_RESULT ) {
  54. CResult* pResult = (CResult *)cookie;
  55. RESULT_TYPES rsltType = pResult->GetType();
  56. if ( rsltType == ITEM_PROF_GROUP ||
  57. rsltType == ITEM_PROF_REGSD ||
  58. rsltType == ITEM_PROF_FILESD
  59. ) {
  60. if(bAsk ){
  61. CString str,strFmt;
  62. //
  63. // The first cast asks the users if they wish to delete all selected items.
  64. // the second case asks to delete one file.
  65. //
  66. if(bAsk && iCnt > 1 ){
  67. str.LoadString( IDS_DELETE_ALL_ITEMS);
  68. } else {
  69. strFmt.LoadString(IDS_QUERY_DELETE);
  70. str.Format(strFmt,pResult->GetAttr());
  71. }
  72. //
  73. // Ask the question. We only want to ask the question once, so set
  74. // bAsk to false so that we neve enter this block again.
  75. //
  76. if ( IDNO == AfxMessageBox((LPCTSTR)str, MB_YESNO, 0) ) {
  77. iCnt = 0;
  78. continue;
  79. }
  80. bAsk = FALSE;
  81. }
  82. //
  83. // free memory associated with the item
  84. //
  85. BOOL bDelete=FALSE;
  86. TRACE(_T("CSnapin::OnDeleteObjects-pResult(%x)\n"),pResult);
  87. if ( rsltType == ITEM_PROF_GROUP ) {
  88. PSCE_GROUP_MEMBERSHIP pGroup, pParentGrp;
  89. PEDITTEMPLATE pTemplate;
  90. //
  91. // delete this group from the template
  92. //
  93. pTemplate = pResult->GetBaseProfile();
  94. if ( pResult->GetBase() != 0 && pTemplate && pTemplate->pTemplate &&
  95. pTemplate->pTemplate->pGroupMembership ) {
  96. for ( pGroup=pTemplate->pTemplate->pGroupMembership, pParentGrp=NULL;
  97. pGroup != NULL; pParentGrp=pGroup, pGroup=pGroup->Next ) {
  98. if ( pResult->GetBase() == (LONG_PTR)pGroup ) {
  99. //
  100. // remove this node from the list
  101. //
  102. if ( pParentGrp ) {
  103. pParentGrp->Next = pGroup->Next;
  104. } else {
  105. pTemplate->pTemplate->pGroupMembership = pGroup->Next;
  106. }
  107. pGroup->Next = NULL;
  108. TRACE(_T("CSnapin::OnDeleteObjects-pGroup(%x)\n"),pGroup);
  109. //
  110. // free the node
  111. //
  112. if ( pGroup ) {
  113. SceFreeMemory((PVOID)pGroup, SCE_STRUCT_GROUP);
  114. }
  115. break;
  116. }
  117. }
  118. }
  119. if ( pTemplate ) {
  120. (void)pTemplate->SetDirty(AREA_GROUP_MEMBERSHIP);
  121. }
  122. bDelete = TRUE;
  123. } else if ( rsltType == ITEM_PROF_REGSD ||
  124. rsltType == ITEM_PROF_FILESD
  125. ) {
  126. PSCE_OBJECT_SECURITY pObject;
  127. PSCE_OBJECT_ARRAY poa;
  128. DWORD i,j;
  129. PEDITTEMPLATE pTemplate;
  130. AREA_INFORMATION Area;
  131. pObject = (PSCE_OBJECT_SECURITY)(pResult->GetID());
  132. pTemplate = pResult->GetBaseProfile();
  133. if ( rsltType == ITEM_PROF_REGSD ) {
  134. poa = pTemplate->pTemplate->pRegistryKeys.pAllNodes;
  135. Area = AREA_REGISTRY_SECURITY;
  136. } else if ( rsltType == ITEM_PROF_FILESD ) {
  137. poa = pTemplate->pTemplate->pFiles.pAllNodes;
  138. Area = AREA_FILE_SECURITY;
  139. } else {
  140. poa = pTemplate->pTemplate->pDsObjects.pAllNodes;
  141. Area = AREA_DS_OBJECTS;
  142. }
  143. if ( pResult->GetID() != 0 && pTemplate &&
  144. pTemplate->pTemplate && poa ) {
  145. i=0;
  146. while ( i < poa->Count &&
  147. (pResult->GetID() != (LONG_PTR)(poa->pObjectArray[i])) )
  148. i++;
  149. if ( i < poa->Count ) {
  150. //
  151. // remove this node from the array, but the arry won't be reallocated
  152. //
  153. for ( j=i+1; j<poa->Count; j++ ) {
  154. poa->pObjectArray[j-1] = poa->pObjectArray[j];
  155. }
  156. poa->pObjectArray[poa->Count-1] = NULL;
  157. poa->Count--;
  158. //
  159. // free the node
  160. //
  161. TRACE(_T("CSnapin::OnDeleteObjects-pObject(%x)\n"),pObject);
  162. if ( pObject ) {
  163. if ( pObject->Name != NULL )
  164. LocalFree( pObject->Name );
  165. if ( pObject->pSecurityDescriptor != NULL )
  166. LocalFree(pObject->pSecurityDescriptor);
  167. LocalFree( pObject );
  168. }
  169. }
  170. }
  171. if ( pTemplate ) {
  172. (void)pTemplate->SetDirty(Area);
  173. }
  174. bDelete = TRUE;
  175. }
  176. if ( bDelete ) {
  177. //
  178. // delete from the result pane
  179. //
  180. HRESULTITEM hItem = NULL;
  181. if(m_pResult->FindItemByLParam( (LPARAM)pResult, &hItem) == S_OK){
  182. m_pResult->DeleteItem(hItem, 0);
  183. }
  184. //
  185. // delete the item from result list and free the buffer
  186. //
  187. POSITION pos=NULL;
  188. //if ( FindResult((long)cookie, &pos) ) {
  189. // if ( pos ) {
  190. if (m_pSelectedFolder->RemoveResultItem(
  191. m_resultItemHandle,
  192. pResult
  193. ) == ERROR_SUCCESS) {
  194. //
  195. // delete the node
  196. //
  197. delete pResult;
  198. }
  199. //
  200. // Notify any other views to also delete the item
  201. //
  202. m_pConsole->UpdateAllViews((LPDATAOBJECT)this, (LONG_PTR)pResult, UAV_RESULTITEM_REMOVE);
  203. }
  204. }
  205. }
  206. pInternal++;
  207. }
  208. if( pAllInternals )
  209. {
  210. FREE_INTERNAL(pAllInternals);
  211. }
  212. return S_OK;
  213. }
  214. CResult* CSnapin::FindResult(MMC_COOKIE cookie, POSITION* thePos)
  215. {
  216. POSITION pos = NULL; //m_resultItemList.GetHeadPosition();
  217. POSITION curPos;
  218. CResult* pResult = NULL;
  219. if(!m_pSelectedFolder || !m_resultItemHandle)
  220. {
  221. return NULL;
  222. }
  223. do {
  224. curPos = pos;
  225. if( m_pSelectedFolder->GetResultItem(
  226. m_resultItemHandle,
  227. pos,
  228. &pResult) != ERROR_SUCCESS )
  229. {
  230. break;
  231. }
  232. // pos is already updated to the next item after this call
  233. //pResult = m_resultItemList.GetNext(pos);
  234. // how to compare result item correctly ?
  235. // for now, let's compare the pointer address.
  236. if ((MMC_COOKIE)pResult == cookie)
  237. {
  238. if ( thePos )
  239. {
  240. *thePos = curPos;
  241. }
  242. return pResult;
  243. }
  244. } while( pos );
  245. if ( thePos )
  246. *thePos = NULL;
  247. return NULL;
  248. }
  249. void
  250. OnDeleteHelper(CRegKey& regkeySCE,CString tmpstr) {
  251. //
  252. // replace the "\" with "/" because registry does not take "\" in a single key
  253. //
  254. int npos = tmpstr.Find(L'\\');
  255. while (npos != -1) {
  256. *(tmpstr.GetBuffer(1)+npos) = L'/';
  257. npos = tmpstr.Find(L'\\');
  258. }
  259. regkeySCE.DeleteSubKey(tmpstr);
  260. regkeySCE.Close();
  261. }
  262. HRESULT CComponentDataImpl::OnDelete(LPDATAOBJECT lpDataObject, LPARAM arg, LPARAM param)
  263. {
  264. ASSERT(lpDataObject);
  265. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  266. if ( lpDataObject == NULL ) {
  267. return S_OK;
  268. }
  269. HRESULT hr = S_OK;
  270. INTERNAL* pInternal = ExtractInternalFormat(lpDataObject);
  271. if ( pInternal ) {
  272. MMC_COOKIE cookie = pInternal->m_cookie;
  273. CFolder* pFolder = (CFolder *)cookie;
  274. FOLDER_TYPES fldType = pFolder->GetType();
  275. if ( fldType == LOCATIONS ||
  276. fldType == PROFILE ) {
  277. CString str;
  278. str.Format(IDS_DELETE_CONFIRM,pFolder->GetName() );
  279. if ( IDYES == AfxMessageBox((LPCTSTR)str, MB_YESNO, 0) ) {
  280. //
  281. // delete the nodes and all related children info
  282. //
  283. if ( fldType == PROFILE ) {
  284. if (CAttribute::m_nDialogs > 0) {
  285. CString str;
  286. AfxFormatString1(str,IDS_CLOSE_PAGES,pFolder->GetName());
  287. AfxMessageBox(str,MB_OK);
  288. hr = S_FALSE;
  289. } else {
  290. //
  291. // delete a single inf file
  292. //
  293. DeleteFile(pFolder->GetInfFile());
  294. hr = DeleteOneTemplateNodes(cookie);
  295. }
  296. } else {
  297. //
  298. // delete a registry path from SCE
  299. //
  300. CRegKey regkeySCE;
  301. CString tmpstr;
  302. tmpstr.LoadString(IDS_TEMPLATE_LOCATION_KEY);
  303. LONG lRes;
  304. lRes = regkeySCE.Open(HKEY_LOCAL_MACHINE, tmpstr);
  305. if (lRes == ERROR_SUCCESS) {
  306. OnDeleteHelper(regkeySCE,pFolder->GetName());
  307. }
  308. //
  309. // Bug 375324: Delete from HKCU as well as HKLM
  310. //
  311. lRes = regkeySCE.Open(HKEY_CURRENT_USER, tmpstr);
  312. if (lRes == ERROR_SUCCESS) {
  313. OnDeleteHelper(regkeySCE,pFolder->GetName());
  314. }
  315. MMC_COOKIE FindCookie=FALSE;
  316. HSCOPEITEM pItemChild;
  317. pItemChild = NULL;
  318. hr = m_pScope->GetChildItem(pFolder->GetScopeItem()->ID, &pItemChild, &FindCookie);
  319. //
  320. // find a child item
  321. //
  322. while ( pItemChild ) {
  323. if ( FindCookie ) {
  324. //
  325. // find a template, delete it
  326. //
  327. DeleteOneTemplateNodes(FindCookie);
  328. }
  329. // get next pointer
  330. pItemChild = NULL;
  331. FindCookie = FALSE;
  332. hr = m_pScope->GetChildItem( pFolder->GetScopeItem()->ID, &pItemChild, &FindCookie);
  333. }
  334. //
  335. // delete this location node
  336. //
  337. DeleteThisNode(pFolder);
  338. }
  339. }
  340. }
  341. FREE_INTERNAL(pInternal);
  342. }
  343. return hr;
  344. }
  345. HRESULT CComponentDataImpl::DeleteOneTemplateNodes(MMC_COOKIE cookie)
  346. {
  347. if ( !cookie ) {
  348. return S_OK;
  349. }
  350. CFolder *pFolder = (CFolder *)cookie;
  351. //
  352. // delete the template info first, this will delete handles
  353. // associated with any extension services
  354. //
  355. if ( pFolder->GetInfFile() ) {
  356. DeleteTemplate(pFolder->GetInfFile());
  357. }
  358. //
  359. // delete the scope items and m_scopeItemList (for all children)
  360. //
  361. DeleteChildrenUnderNode(pFolder);
  362. //
  363. // delete this location node
  364. //
  365. DeleteThisNode(pFolder);
  366. return S_OK;
  367. }
  368. void CComponentDataImpl::DeleteTemplate(CString infFile)
  369. {
  370. PEDITTEMPLATE pTemplateInfo = NULL;
  371. CString stri = infFile;
  372. stri.MakeLower();
  373. if ( m_Templates.Lookup(stri, pTemplateInfo) ) {
  374. m_Templates.RemoveKey(stri);
  375. if ( pTemplateInfo ) {
  376. if ( pTemplateInfo->pTemplate )
  377. SceFreeProfileMemory(pTemplateInfo->pTemplate);
  378. delete pTemplateInfo;
  379. }
  380. }
  381. }
  382. void CSnapin::CreateProfilePolicyResultList(MMC_COOKIE cookie,
  383. FOLDER_TYPES type,
  384. PEDITTEMPLATE pSceInfo,
  385. LPDATAOBJECT pDataObj)
  386. {
  387. if ( !pSceInfo ) {
  388. return;
  389. }
  390. bool bVerify=false;
  391. UINT i;
  392. DWORD curVal;
  393. UINT IdsMax[]={IDS_SYS_LOG_MAX, IDS_SEC_LOG_MAX, IDS_APP_LOG_MAX};
  394. UINT IdsRet[]={IDS_SYS_LOG_RET, IDS_SEC_LOG_RET, IDS_APP_LOG_RET};
  395. UINT IdsDays[]={IDS_SYS_LOG_DAYS, IDS_SEC_LOG_DAYS, IDS_APP_LOG_DAYS};
  396. UINT IdsGuest[]={IDS_SYS_LOG_GUEST, IDS_SEC_LOG_GUEST, IDS_APP_LOG_GUEST};
  397. switch ( type ) {
  398. case POLICY_PASSWORD:
  399. // L"Maximum passage age", L"Days"
  400. AddResultItem(IDS_MAX_PAS_AGE, SCE_NO_VALUE,
  401. pSceInfo->pTemplate->MaximumPasswordAge, ITEM_PROF_DW, -1, cookie, bVerify,pSceInfo,pDataObj);
  402. // L"Minimum passage age", L"Days"
  403. AddResultItem(IDS_MIN_PAS_AGE, SCE_NO_VALUE,
  404. pSceInfo->pTemplate->MinimumPasswordAge, ITEM_PROF_DW, -1, cookie, bVerify,pSceInfo,pDataObj);
  405. // L"Minimum passage length", L"Characters"
  406. AddResultItem(IDS_MIN_PAS_LEN, SCE_NO_VALUE,
  407. pSceInfo->pTemplate->MinimumPasswordLength, ITEM_PROF_DW, -1, cookie, bVerify,pSceInfo,pDataObj);
  408. // L"Password history size", L"Passwords"
  409. AddResultItem(IDS_PAS_UNIQUENESS, SCE_NO_VALUE,
  410. pSceInfo->pTemplate->PasswordHistorySize, ITEM_PROF_DW, -1, cookie, bVerify,pSceInfo,pDataObj);
  411. // L"Password complexity", L""
  412. AddResultItem(IDS_PAS_COMPLEX, SCE_NO_VALUE,
  413. pSceInfo->pTemplate->PasswordComplexity, ITEM_PROF_BOOL, -1, cookie, bVerify,pSceInfo,pDataObj);
  414. // NT5 new flag
  415. // L"Clear Text Password", L""
  416. AddResultItem(IDS_CLEAR_PASSWORD, SCE_NO_VALUE,
  417. pSceInfo->pTemplate->ClearTextPassword, ITEM_PROF_BOOL, -1, cookie, bVerify,pSceInfo,pDataObj);
  418. #if defined(USE_REQ_LOGON_ITEM)
  419. // L"Require logon to change password", L""
  420. AddResultItem(IDS_REQ_LOGON, SCE_NO_VALUE,
  421. pSceInfo->pTemplate->RequireLogonToChangePassword, ITEM_PROF_BOOL, -1, cookie, bVerify,pSceInfo,pDataObj);
  422. #endif
  423. break;
  424. case POLICY_KERBEROS:
  425. if (!VerifyKerberosInfo(pSceInfo->pTemplate)) {
  426. AddResultItem(IDS_CANT_DISPLAY_ERROR_OOM,NULL,NULL,ITEM_OTHER,-1,cookie);
  427. break;
  428. }
  429. AddResultItem(IDS_KERBEROS_MAX_SERVICE,SCE_NO_VALUE,
  430. pSceInfo->pTemplate->pKerberosInfo->MaxServiceAge,
  431. ITEM_PROF_DW,-1,cookie,bVerify,pSceInfo,pDataObj);
  432. AddResultItem(IDS_KERBEROS_MAX_CLOCK,SCE_NO_VALUE,
  433. pSceInfo->pTemplate->pKerberosInfo->MaxClockSkew,
  434. ITEM_PROF_DW,-1,cookie,bVerify,pSceInfo,pDataObj);
  435. AddResultItem(IDS_KERBEROS_RENEWAL,SCE_NO_VALUE,
  436. pSceInfo->pTemplate->pKerberosInfo->MaxRenewAge,
  437. ITEM_PROF_DW,-1,cookie,bVerify,pSceInfo,pDataObj);
  438. AddResultItem(IDS_KERBEROS_MAX_AGE,SCE_NO_VALUE,
  439. pSceInfo->pTemplate->pKerberosInfo->MaxTicketAge,
  440. ITEM_PROF_DW,-1,cookie,bVerify,pSceInfo,pDataObj);
  441. AddResultItem(IDS_KERBEROS_VALIDATE_CLIENT,SCE_NO_VALUE,
  442. pSceInfo->pTemplate->pKerberosInfo->TicketValidateClient,
  443. ITEM_PROF_BOOL,-1,cookie,bVerify,pSceInfo,pDataObj);
  444. break;
  445. case POLICY_LOCKOUT:
  446. // L"Account lockout count", L"Attempts"
  447. AddResultItem(IDS_LOCK_COUNT, SCE_NO_VALUE,
  448. pSceInfo->pTemplate->LockoutBadCount, ITEM_PROF_DW, -1, cookie, bVerify,pSceInfo,pDataObj);
  449. // L"Reset lockout count after", L"Minutes"
  450. AddResultItem(IDS_LOCK_RESET_COUNT, SCE_NO_VALUE,
  451. pSceInfo->pTemplate->ResetLockoutCount, ITEM_PROF_DW, -1, cookie, bVerify,pSceInfo,pDataObj);
  452. // L"Lockout duration", L"Minutes"
  453. AddResultItem(IDS_LOCK_DURATION, SCE_NO_VALUE,
  454. pSceInfo->pTemplate->LockoutDuration, ITEM_PROF_DW, -1, cookie, bVerify,pSceInfo,pDataObj);
  455. break;
  456. case POLICY_AUDIT:
  457. //
  458. // Event auditing
  459. //
  460. // if ( pSceInfo->pTemplate->EventAuditingOnOff)
  461. // curVal = 1;
  462. // else
  463. // curVal = 0;
  464. // L"Event Auditing Mode",
  465. // AddResultItem(IDS_EVENT_ON, SCE_NO_VALUE,
  466. // pSceInfo->pTemplate->EventAuditingOnOff, ITEM_PROF_BON, -1, cookie, bVerify,pSceInfo,pDataObj);
  467. // L"Audit system events"
  468. AddResultItem(IDS_SYSTEM_EVENT, SCE_NO_VALUE,
  469. pSceInfo->pTemplate->AuditSystemEvents, ITEM_PROF_B2ON, -1, cookie, bVerify,pSceInfo,pDataObj);
  470. // L"Audit logon events"
  471. AddResultItem(IDS_LOGON_EVENT, SCE_NO_VALUE,
  472. pSceInfo->pTemplate->AuditLogonEvents, ITEM_PROF_B2ON, -1, cookie, bVerify,pSceInfo,pDataObj);
  473. // L"Audit Object Access"
  474. AddResultItem(IDS_OBJECT_ACCESS, SCE_NO_VALUE,
  475. pSceInfo->pTemplate->AuditObjectAccess, ITEM_PROF_B2ON, -1, cookie, bVerify,pSceInfo,pDataObj);
  476. // L"Audit Privilege Use"
  477. AddResultItem(IDS_PRIVILEGE_USE, SCE_NO_VALUE,
  478. pSceInfo->pTemplate->AuditPrivilegeUse, ITEM_PROF_B2ON, -1, cookie, bVerify,pSceInfo,pDataObj);
  479. // L"Audit policy change"
  480. AddResultItem(IDS_POLICY_CHANGE, SCE_NO_VALUE,
  481. pSceInfo->pTemplate->AuditPolicyChange, ITEM_PROF_B2ON, -1, cookie, bVerify,pSceInfo,pDataObj);
  482. // L"Audit Account Manage"
  483. AddResultItem(IDS_ACCOUNT_MANAGE, SCE_NO_VALUE,
  484. pSceInfo->pTemplate->AuditAccountManage, ITEM_PROF_B2ON, -1, cookie, bVerify,pSceInfo,pDataObj);
  485. // L"Audit process tracking"
  486. AddResultItem(IDS_PROCESS_TRACK, SCE_NO_VALUE,
  487. pSceInfo->pTemplate->AuditProcessTracking, ITEM_PROF_B2ON, -1, cookie, bVerify,pSceInfo,pDataObj);
  488. // L"Audit directory service access"
  489. AddResultItem(IDS_DIRECTORY_ACCESS, SCE_NO_VALUE,
  490. pSceInfo->pTemplate->AuditDSAccess, ITEM_PROF_B2ON, -1, cookie, bVerify,pSceInfo,pDataObj);
  491. // L"Audit Account Logon"
  492. AddResultItem(IDS_ACCOUNT_LOGON, SCE_NO_VALUE,
  493. pSceInfo->pTemplate->AuditAccountLogon, ITEM_PROF_B2ON, -1, cookie, bVerify,pSceInfo,pDataObj);
  494. break;
  495. case POLICY_OTHER:
  496. //
  497. // Account Logon category
  498. //
  499. // L"Force logoff when logon hour expire", L""
  500. AddResultItem(IDS_FORCE_LOGOFF, SCE_NO_VALUE,
  501. pSceInfo->pTemplate->ForceLogoffWhenHourExpire, ITEM_PROF_BOOL, -1, cookie, bVerify,pSceInfo,pDataObj);
  502. // L"Accounts: Administrator account status", L""
  503. AddResultItem(IDS_ENABLE_ADMIN, SCE_NO_VALUE,
  504. pSceInfo->pTemplate->EnableAdminAccount, ITEM_PROF_BOOL, -1, cookie, bVerify,pSceInfo,pDataObj);
  505. // L"Accounts: Guest account status", L""
  506. AddResultItem(IDS_ENABLE_GUEST, SCE_NO_VALUE,
  507. pSceInfo->pTemplate->EnableGuestAccount, ITEM_PROF_BOOL, -1, cookie, bVerify,pSceInfo,pDataObj);
  508. // L"New Administrator account name"
  509. AddResultItem(IDS_NEW_ADMIN, 0,
  510. (LONG_PTR)(LPCTSTR)pSceInfo->pTemplate->NewAdministratorName,
  511. ITEM_PROF_SZ, -1, cookie,bVerify,pSceInfo,pDataObj);
  512. // L"New Guest account name"
  513. AddResultItem(IDS_NEW_GUEST, NULL,
  514. (LONG_PTR)(LPCTSTR)pSceInfo->pTemplate->NewGuestName,
  515. ITEM_PROF_SZ, -1, cookie,bVerify,pSceInfo,pDataObj);
  516. // L"Network access: Allow anonymous SID/Name translation"
  517. AddResultItem(IDS_LSA_ANON_LOOKUP, SCE_NO_VALUE,
  518. pSceInfo->pTemplate->LSAAnonymousNameLookup, ITEM_PROF_BOOL, -1, cookie, bVerify,pSceInfo,pDataObj);
  519. CreateProfileRegValueList(cookie, pSceInfo, pDataObj);
  520. break;
  521. case POLICY_LOG:
  522. //
  523. // Event Log setting
  524. //
  525. for ( i=0; i<3; i++) {
  526. // L"... Log Maximum Size", L"KBytes"
  527. AddResultItem(IdsMax[i], SCE_NO_VALUE,
  528. pSceInfo->pTemplate->MaximumLogSize[i], ITEM_PROF_DW, -1, cookie, bVerify,pSceInfo,pDataObj);
  529. // L"... Log Retention Method",
  530. AddResultItem(IdsRet[i], SCE_NO_VALUE,
  531. pSceInfo->pTemplate->AuditLogRetentionPeriod[i], ITEM_PROF_RET, -1, cookie, bVerify,pSceInfo,pDataObj);
  532. //
  533. // AuditLogRetentionPeriod has already been interpreted by the
  534. // SCE engine into the RetentionDays setting. So, the RSOP UI
  535. // should display RetentionDays if it exists in the WMI db.
  536. //
  537. // if ( pSceInfo->pTemplate->AuditLogRetentionPeriod[i] == 1) {
  538. // curVal = pSceInfo->pTemplate->RetentionDays[i];
  539. // } else {
  540. // curVal = SCE_NO_VALUE;
  541. // }
  542. // L"... Log Retention days", "days"
  543. // AddResultItem(IdsDays[i], SCE_NO_VALUE, curVal, ITEM_PROF_DW, -1, cookie, bVerify,pSceInfo,pDataObj);
  544. AddResultItem(IdsDays[i], SCE_NO_VALUE,
  545. pSceInfo->pTemplate->RetentionDays[i], ITEM_PROF_DW, -1, cookie, bVerify,pSceInfo,pDataObj);
  546. // L"RestrictGuestAccess", L""
  547. AddResultItem(IdsGuest[i], SCE_NO_VALUE,
  548. pSceInfo->pTemplate->RestrictGuestAccess[i], ITEM_PROF_BOOL, -1, cookie, bVerify,pSceInfo,pDataObj);
  549. }
  550. break;
  551. }
  552. }
  553. void
  554. CSnapin::CreateAnalysisPolicyResultList(MMC_COOKIE cookie,
  555. FOLDER_TYPES type,
  556. PEDITTEMPLATE pSceInfo,
  557. PEDITTEMPLATE pBase,
  558. LPDATAOBJECT pDataObj )
  559. {
  560. if ( !pSceInfo || !pBase ) {
  561. AddResultItem(IDS_ERROR_NO_ANALYSIS_INFO,NULL,NULL,ITEM_OTHER,-1,cookie);
  562. return;
  563. }
  564. bool bVerify=true;
  565. UINT i;
  566. UINT IdsMax[]={IDS_SYS_LOG_MAX, IDS_SEC_LOG_MAX, IDS_APP_LOG_MAX};
  567. UINT IdsRet[]={IDS_SYS_LOG_RET, IDS_SEC_LOG_RET, IDS_APP_LOG_RET};
  568. UINT IdsDays[]={IDS_SYS_LOG_DAYS, IDS_SEC_LOG_DAYS, IDS_APP_LOG_DAYS};
  569. UINT IdsGuest[]={IDS_SYS_LOG_GUEST, IDS_SEC_LOG_GUEST, IDS_APP_LOG_GUEST};
  570. DWORD status;
  571. LONG_PTR setting;
  572. switch ( type ) {
  573. case POLICY_PASSWORD_ANALYSIS:
  574. //
  575. // password category
  576. //
  577. // L"Maximum passage age", L"Days"
  578. AddResultItem(IDS_MAX_PAS_AGE,
  579. pSceInfo->pTemplate->MaximumPasswordAge,
  580. pBase->pTemplate->MaximumPasswordAge,
  581. ITEM_DW,
  582. 1,
  583. cookie,
  584. bVerify,
  585. pBase, //The template to save this attribute in
  586. pDataObj); //The data object for the scope note who owns the result pane
  587. // L"Minimum passage age", L"Days"
  588. AddResultItem(IDS_MIN_PAS_AGE,
  589. pSceInfo->pTemplate->MinimumPasswordAge,
  590. pBase->pTemplate->MinimumPasswordAge,
  591. ITEM_DW,
  592. 1,
  593. cookie,
  594. bVerify,
  595. pBase, //The template to save this attribute in
  596. pDataObj); //The data object for the scope note who owns the result pane
  597. // L"Minimum passage length", L"Characters"
  598. AddResultItem(IDS_MIN_PAS_LEN,
  599. pSceInfo->pTemplate->MinimumPasswordLength,
  600. pBase->pTemplate->MinimumPasswordLength,
  601. ITEM_DW,
  602. 1,
  603. cookie,
  604. bVerify,
  605. pBase, //The template to save this attribute in
  606. pDataObj); //The data object for the scope note who owns the result pane
  607. // L"Password history size", L"Passwords"
  608. AddResultItem(IDS_PAS_UNIQUENESS,
  609. pSceInfo->pTemplate->PasswordHistorySize,
  610. pBase->pTemplate->PasswordHistorySize,
  611. ITEM_DW,
  612. 1,
  613. cookie,
  614. bVerify,
  615. pBase, //The template to save this attribute in
  616. pDataObj); //The data object for the scope note who owns the result pane
  617. // L"Password complexity", L""
  618. AddResultItem(IDS_PAS_COMPLEX,
  619. pSceInfo->pTemplate->PasswordComplexity,
  620. pBase->pTemplate->PasswordComplexity,
  621. ITEM_BOOL,
  622. 1,
  623. cookie,
  624. bVerify,
  625. pBase, //The template to save this attribute in
  626. pDataObj); //The data object for the scope note who owns the result pane
  627. // L"Clear Text Password", L""
  628. AddResultItem(IDS_CLEAR_PASSWORD,
  629. pSceInfo->pTemplate->ClearTextPassword,
  630. pBase->pTemplate->ClearTextPassword,
  631. ITEM_BOOL,
  632. 1,
  633. cookie,
  634. bVerify,
  635. pBase, //The template to save this attribute in
  636. pDataObj); //The data object for the scope note who owns the result pane
  637. #if defined(USE_REQ_LOGON_ITEM)
  638. // L"Require logon to change password", L""
  639. AddResultItem(IDS_REQ_LOGON,
  640. pSceInfo->pTemplate->RequireLogonToChangePassword,
  641. pBase->pTemplate->RequireLogonToChangePassword,
  642. ITEM_BOOL,
  643. 1,
  644. cookie,
  645. bVerify,
  646. pBase, //The template to save this attribute in
  647. pDataObj); //The data object for the scope note who owns the result pane
  648. #endif
  649. break;
  650. case POLICY_KERBEROS_ANALYSIS:
  651. if (!VerifyKerberosInfo(pSceInfo->pTemplate) ||
  652. !VerifyKerberosInfo(pBase->pTemplate)) {
  653. AddResultItem(IDS_CANT_DISPLAY_ERROR_OOM,NULL,NULL,ITEM_OTHER,-1,cookie);
  654. break;
  655. }
  656. AddResultItem(IDS_KERBEROS_MAX_SERVICE,
  657. pSceInfo->pTemplate->pKerberosInfo->MaxServiceAge,
  658. pBase->pTemplate->pKerberosInfo->MaxServiceAge,
  659. ITEM_DW,-1,cookie,bVerify,
  660. pBase, //The template to save this attribute in
  661. pDataObj); //The data object for the scope note who owns the result pane
  662. AddResultItem(IDS_KERBEROS_MAX_CLOCK,
  663. pSceInfo->pTemplate->pKerberosInfo->MaxClockSkew,
  664. pBase->pTemplate->pKerberosInfo->MaxClockSkew,
  665. ITEM_DW,-1,cookie,bVerify,
  666. pBase, //The template to save this attribute in
  667. pDataObj); //The data object for the scope note who owns the result pane
  668. AddResultItem(IDS_KERBEROS_VALIDATE_CLIENT,
  669. pSceInfo->pTemplate->pKerberosInfo->TicketValidateClient,
  670. pBase->pTemplate->pKerberosInfo->TicketValidateClient,
  671. ITEM_BOOL,-1,cookie,bVerify,
  672. pBase, //The template to save this attribute in
  673. pDataObj); //The data object for the scope note who owns the result pane
  674. AddResultItem(IDS_KERBEROS_RENEWAL,
  675. pSceInfo->pTemplate->pKerberosInfo->MaxRenewAge,
  676. pBase->pTemplate->pKerberosInfo->MaxRenewAge,
  677. ITEM_DW,-1,cookie,bVerify,
  678. pBase, //The template to save this attribute in
  679. pDataObj); //The data object for the scope note who owns the result pane
  680. AddResultItem(IDS_KERBEROS_MAX_AGE,
  681. pSceInfo->pTemplate->pKerberosInfo->MaxTicketAge,
  682. pBase->pTemplate->pKerberosInfo->MaxTicketAge,
  683. ITEM_DW,-1,cookie,bVerify,
  684. pBase, //The template to save this attribute in
  685. pDataObj); //The data object for the scope note who owns the result pane
  686. break;
  687. case POLICY_LOCKOUT_ANALYSIS:
  688. //
  689. // Account Lockout category
  690. //
  691. // L"Account lockout count", L"Attempts"
  692. AddResultItem(IDS_LOCK_COUNT, pSceInfo->pTemplate->LockoutBadCount,
  693. pBase->pTemplate->LockoutBadCount, ITEM_DW, 1, cookie, bVerify,
  694. pBase, //The template to save this attribute in
  695. pDataObj); //The data object for the scope note who owns the result pane
  696. // L"Reset lockout count after", L"Minutes"
  697. AddResultItem(IDS_LOCK_RESET_COUNT, pSceInfo->pTemplate->ResetLockoutCount,
  698. pBase->pTemplate->ResetLockoutCount, ITEM_DW, 1, cookie, bVerify,
  699. pBase, //The template to save this attribute in
  700. pDataObj); //The data object for the scope note who owns the result pane
  701. // L"Lockout duration", L"Minutes"
  702. AddResultItem(IDS_LOCK_DURATION, pSceInfo->pTemplate->LockoutDuration,
  703. pBase->pTemplate->LockoutDuration, ITEM_DW, 1, cookie, bVerify,
  704. pBase, //The template to save this attribute in
  705. pDataObj); //The data object for the scope note who owns the result pane
  706. break;
  707. case POLICY_AUDIT_ANALYSIS:
  708. //
  709. // Event auditing
  710. //
  711. // L"Event Auditing Mode",
  712. // AddResultItem(IDS_EVENT_ON, pSceInfo->pTemplate->EventAuditingOnOff,
  713. // pBase->pTemplate->EventAuditingOnOff, ITEM_BON, 1, cookie, bVerify);
  714. // L"Audit system events"
  715. AddResultItem(IDS_SYSTEM_EVENT, pSceInfo->pTemplate->AuditSystemEvents,
  716. pBase->pTemplate->AuditSystemEvents, ITEM_B2ON, 1, cookie, bVerify,
  717. pBase, //The template to save this attribute in
  718. pDataObj); //The data object for the scope note who owns the result pane
  719. // L"Audit logon events"
  720. AddResultItem(IDS_LOGON_EVENT, pSceInfo->pTemplate->AuditLogonEvents,
  721. pBase->pTemplate->AuditLogonEvents, ITEM_B2ON, 1, cookie, bVerify,
  722. pBase, //The template to save this attribute in
  723. pDataObj); //The data object for the scope note who owns the result pane
  724. // L"Audit Object Access"
  725. AddResultItem(IDS_OBJECT_ACCESS, pSceInfo->pTemplate->AuditObjectAccess,
  726. pBase->pTemplate->AuditObjectAccess, ITEM_B2ON, 1, cookie, bVerify,
  727. pBase, //The template to save this attribute in
  728. pDataObj); //The data object for the scope note who owns the result pane
  729. // L"Audit Privilege Use"
  730. AddResultItem(IDS_PRIVILEGE_USE, pSceInfo->pTemplate->AuditPrivilegeUse,
  731. pBase->pTemplate->AuditPrivilegeUse, ITEM_B2ON, 1, cookie, bVerify,
  732. pBase, //The template to save this attribute in
  733. pDataObj); //The data object for the scope note who owns the result pane
  734. // L"Audit policy change"
  735. AddResultItem(IDS_POLICY_CHANGE, pSceInfo->pTemplate->AuditPolicyChange,
  736. pBase->pTemplate->AuditPolicyChange, ITEM_B2ON, 1, cookie, bVerify,
  737. pBase, //The template to save this attribute in
  738. pDataObj); //The data object for the scope note who owns the result pane
  739. // L"Audit Account Manage"
  740. AddResultItem(IDS_ACCOUNT_MANAGE, pSceInfo->pTemplate->AuditAccountManage,
  741. pBase->pTemplate->AuditAccountManage, ITEM_B2ON, 1, cookie, bVerify,
  742. pBase, //The template to save this attribute in
  743. pDataObj); //The data object for the scope note who owns the result pane
  744. // L"Audit process tracking"
  745. AddResultItem(IDS_PROCESS_TRACK, pSceInfo->pTemplate->AuditProcessTracking,
  746. pBase->pTemplate->AuditProcessTracking, ITEM_B2ON, 1, cookie, bVerify,
  747. pBase, //The template to save this attribute in
  748. pDataObj); //The data object for the scope note who owns the result pane
  749. // L"Audit directory access "
  750. AddResultItem(IDS_DIRECTORY_ACCESS, pSceInfo->pTemplate->AuditDSAccess,
  751. pBase->pTemplate->AuditDSAccess, ITEM_B2ON, 1, cookie, bVerify,
  752. pBase, //The template to save this attribute in
  753. pDataObj); //The data object for the scope note who owns the result pane
  754. // L"Audit account logon"
  755. AddResultItem(IDS_ACCOUNT_LOGON, pSceInfo->pTemplate->AuditAccountLogon,
  756. pBase->pTemplate->AuditAccountLogon, ITEM_B2ON, 1, cookie, bVerify,
  757. pBase, //The template to save this attribute in
  758. pDataObj); //The data object for the scope note who owns the result pane
  759. break;
  760. case POLICY_LOG_ANALYSIS:
  761. //
  762. // Event Log setting
  763. //
  764. for ( i=0; i<3; i++) {
  765. // Maximum Log Size
  766. AddResultItem(IdsMax[i], pSceInfo->pTemplate->MaximumLogSize[i],
  767. pBase->pTemplate->MaximumLogSize[i], ITEM_DW, 1, cookie, bVerify,
  768. pBase, //The template to save this attribute in
  769. pDataObj); //The data object for the scope note who owns the result pane
  770. // L"... Log Retention Method",
  771. AddResultItem(IdsRet[i], pSceInfo->pTemplate->AuditLogRetentionPeriod[i],
  772. pBase->pTemplate->AuditLogRetentionPeriod[i], ITEM_RET, 1, cookie, bVerify,
  773. pBase, //The template to save this attribute in
  774. pDataObj); //The data object for the scope note who owns the result pane
  775. if ( pSceInfo->pTemplate->AuditLogRetentionPeriod[i] == 1 ||
  776. pBase->pTemplate->AuditLogRetentionPeriod[i] == 1)
  777. // L"... Log Retention days", "days"
  778. AddResultItem(IdsDays[i], pSceInfo->pTemplate->RetentionDays[i],
  779. pBase->pTemplate->RetentionDays[i], ITEM_DW, 1, cookie, bVerify,
  780. pBase, //The template to save this attribute in
  781. pDataObj); //The data object for the scope note who owns the result pane
  782. // L"RestrictGuestAccess", L""
  783. AddResultItem(IdsGuest[i], pSceInfo->pTemplate->RestrictGuestAccess[i],
  784. pBase->pTemplate->RestrictGuestAccess[i], ITEM_BOOL, 1, cookie, bVerify,
  785. pBase, //The template to save this attribute in
  786. pDataObj); //The data object for the scope note who owns the result pane
  787. }
  788. break;
  789. case POLICY_OTHER_ANALYSIS:
  790. // L"Force logoff when logon hour expire", L""
  791. AddResultItem(IDS_FORCE_LOGOFF, pSceInfo->pTemplate->ForceLogoffWhenHourExpire,
  792. pBase->pTemplate->ForceLogoffWhenHourExpire, ITEM_BOOL, 1, cookie, bVerify,
  793. pBase, //The template to save this attribute in
  794. pDataObj); //The data object for the scope note who owns the result pane
  795. // L"Accounts: Administrator account status", L""
  796. AddResultItem(IDS_ENABLE_ADMIN, pSceInfo->pTemplate->EnableAdminAccount,
  797. pBase->pTemplate->EnableAdminAccount, ITEM_BOOL, 1, cookie, bVerify,
  798. pBase, //The template to save this attribute in
  799. pDataObj); //The data object for the scope note who owns the result pane
  800. // L"Accounts: Guest account status", L""
  801. AddResultItem(IDS_ENABLE_GUEST, pSceInfo->pTemplate->EnableGuestAccount,
  802. pBase->pTemplate->EnableGuestAccount, ITEM_BOOL, 1, cookie, bVerify,
  803. pBase, //The template to save this attribute in
  804. pDataObj); //The data object for the scope note who owns the result pane
  805. // L"Network access: Allow anonymous SID/Name translation"
  806. AddResultItem(IDS_LSA_ANON_LOOKUP, pSceInfo->pTemplate->LSAAnonymousNameLookup,
  807. pBase->pTemplate->LSAAnonymousNameLookup, ITEM_BOOL, 1, cookie, bVerify,
  808. pBase, //The template to save this attribute in
  809. pDataObj); //The data object for the scope note who owns the result pane
  810. // L"New Administrator account name"
  811. setting = (LONG_PTR)(pSceInfo->pTemplate->NewAdministratorName);
  812. if ( !pBase->pTemplate->NewAdministratorName ) {
  813. status = SCE_STATUS_NOT_CONFIGURED;
  814. } else if ( pSceInfo->pTemplate->NewAdministratorName) {
  815. status = SCE_STATUS_MISMATCH;
  816. } else {
  817. setting = (LONG_PTR)(pBase->pTemplate->NewAdministratorName);
  818. status = SCE_STATUS_GOOD;
  819. }
  820. AddResultItem(IDS_NEW_ADMIN, setting,
  821. (LONG_PTR)(LPCTSTR)pBase->pTemplate->NewAdministratorName,
  822. ITEM_SZ, status, cookie,false,
  823. pBase, //The template to save this attribute in
  824. pDataObj); //The data object for the scope note who owns the result pane
  825. // L"New Guest account name"
  826. setting = (LONG_PTR)(pSceInfo->pTemplate->NewGuestName);
  827. if ( !pBase->pTemplate->NewGuestName ) {
  828. status = SCE_STATUS_NOT_CONFIGURED;
  829. } else if ( pSceInfo->pTemplate->NewGuestName) {
  830. status = SCE_STATUS_MISMATCH;
  831. } else {
  832. setting = (LONG_PTR)(pBase->pTemplate->NewGuestName);
  833. status = SCE_STATUS_GOOD;
  834. }
  835. AddResultItem(IDS_NEW_GUEST, setting,
  836. (LONG_PTR)(LPCTSTR)pBase->pTemplate->NewGuestName,
  837. ITEM_SZ, status, cookie,false,
  838. pBase, //The template to save this attribute in
  839. pDataObj); //The data object for the scope note who owns the result pane
  840. CreateAnalysisRegValueList(cookie, pSceInfo, pBase, pDataObj,ITEM_REGVALUE);
  841. break;
  842. }
  843. }
  844. void
  845. CSnapin::CreateLocalPolicyResultList(MMC_COOKIE cookie,
  846. FOLDER_TYPES type,
  847. PEDITTEMPLATE pLocal,
  848. PEDITTEMPLATE pEffective,
  849. LPDATAOBJECT pDataObj )
  850. {
  851. if ( !pLocal || !pEffective ) {
  852. AddResultItem(IDS_ERROR_NO_LOCAL_POLICY_INFO,NULL,NULL,ITEM_OTHER,-1,cookie);
  853. return;
  854. }
  855. bool bVerify= false;
  856. UINT i;
  857. UINT IdsMax[]={IDS_SYS_LOG_MAX, IDS_SEC_LOG_MAX, IDS_APP_LOG_MAX};
  858. UINT IdsRet[]={IDS_SYS_LOG_RET, IDS_SEC_LOG_RET, IDS_APP_LOG_RET};
  859. UINT IdsDays[]={IDS_SYS_LOG_DAYS, IDS_SEC_LOG_DAYS, IDS_APP_LOG_DAYS};
  860. UINT IdsGuest[]={IDS_SYS_LOG_GUEST, IDS_SEC_LOG_GUEST, IDS_APP_LOG_GUEST};
  861. DWORD status;
  862. LONG_PTR setting;
  863. switch ( type ) {
  864. case LOCALPOL_PASSWORD:
  865. //
  866. // password category
  867. //
  868. // L"Maximum passage age", L"Days"
  869. AddResultItem(IDS_MAX_PAS_AGE,
  870. pEffective->pTemplate->MaximumPasswordAge,
  871. pLocal->pTemplate->MaximumPasswordAge,
  872. ITEM_LOCALPOL_DW,
  873. 1,
  874. cookie,
  875. bVerify,
  876. pLocal, //The template to save this attribute in
  877. pDataObj); //The data object for the scope note who owns the result pane
  878. // L"Minimum passage age", L"Days"
  879. AddResultItem(IDS_MIN_PAS_AGE,
  880. pEffective->pTemplate->MinimumPasswordAge,
  881. pLocal->pTemplate->MinimumPasswordAge,
  882. ITEM_LOCALPOL_DW,
  883. 1,
  884. cookie,
  885. bVerify,
  886. pLocal, //The template to save this attribute in
  887. pDataObj); //The data object for the scope note who owns the result pane
  888. // L"Minimum passage length", L"Characters"
  889. AddResultItem(IDS_MIN_PAS_LEN,
  890. pEffective->pTemplate->MinimumPasswordLength,
  891. pLocal->pTemplate->MinimumPasswordLength,
  892. ITEM_LOCALPOL_DW,
  893. 1,
  894. cookie,
  895. bVerify,
  896. pLocal, //The template to save this attribute in
  897. pDataObj); //The data object for the scope note who owns the result pane
  898. // L"Password history size", L"Passwords"
  899. AddResultItem(IDS_PAS_UNIQUENESS,
  900. pEffective->pTemplate->PasswordHistorySize,
  901. pLocal->pTemplate->PasswordHistorySize,
  902. ITEM_LOCALPOL_DW,
  903. 1,
  904. cookie,
  905. bVerify,
  906. pLocal, //The template to save this attribute in
  907. pDataObj); //The data object for the scope note who owns the result pane
  908. // L"Password complexity", L""
  909. AddResultItem(IDS_PAS_COMPLEX,
  910. pEffective->pTemplate->PasswordComplexity,
  911. pLocal->pTemplate->PasswordComplexity,
  912. ITEM_LOCALPOL_BOOL,
  913. 1,
  914. cookie,
  915. bVerify,
  916. pLocal, //The template to save this attribute in
  917. pDataObj); //The data object for the scope note who owns the result pane
  918. // L"Clear Text Password", L""
  919. AddResultItem(IDS_CLEAR_PASSWORD,
  920. pEffective->pTemplate->ClearTextPassword,
  921. pLocal->pTemplate->ClearTextPassword,
  922. ITEM_LOCALPOL_BOOL,
  923. 1,
  924. cookie,
  925. bVerify,
  926. pLocal, //The template to save this attribute in
  927. pDataObj); //The data object for the scope note who owns the result pane
  928. #if defined(USE_REQ_LOGON_ITEM)
  929. // L"Require logon to change password", L""
  930. AddResultItem(IDS_REQ_LOGON,
  931. pEffective->pTemplate->RequireLogonToChangePassword,
  932. pLocal->pTemplate->RequireLogonToChangePassword,
  933. ITEM_LOCALPOL_BOOL,
  934. 1,
  935. cookie,
  936. bVerify,
  937. pLocal, //The template to save this attribute in
  938. pDataObj); //The data object for the scope note who owns the result pane
  939. #endif
  940. break;
  941. case LOCALPOL_KERBEROS:
  942. if (!VerifyKerberosInfo(pLocal->pTemplate) ||
  943. !VerifyKerberosInfo(pEffective->pTemplate)) {
  944. AddResultItem(IDS_CANT_DISPLAY_ERROR_OOM,NULL,NULL,ITEM_OTHER,-1,cookie);
  945. break;
  946. }
  947. AddResultItem(IDS_KERBEROS_MAX_SERVICE,
  948. pEffective->pTemplate->pKerberosInfo->MaxServiceAge,
  949. pLocal->pTemplate->pKerberosInfo->MaxServiceAge,
  950. ITEM_LOCALPOL_DW,-1,cookie,bVerify,
  951. pLocal, //The template to save this attribute in
  952. pDataObj); //The data object for the scope note who owns the result pane
  953. AddResultItem(IDS_KERBEROS_MAX_CLOCK,
  954. pEffective->pTemplate->pKerberosInfo->MaxClockSkew,
  955. pLocal->pTemplate->pKerberosInfo->MaxClockSkew,
  956. ITEM_LOCALPOL_DW,-1,cookie,bVerify,
  957. pLocal, //The template to save this attribute in
  958. pDataObj); //The data object for the scope note who owns the result pane
  959. AddResultItem(IDS_KERBEROS_VALIDATE_CLIENT,
  960. pEffective->pTemplate->pKerberosInfo->TicketValidateClient,
  961. pLocal->pTemplate->pKerberosInfo->TicketValidateClient,
  962. ITEM_LOCALPOL_BOOL,-1,cookie,bVerify,
  963. pLocal, //The template to save this attribute in
  964. pDataObj); //The data object for the scope note who owns the result pane
  965. AddResultItem(IDS_KERBEROS_RENEWAL,
  966. pEffective->pTemplate->pKerberosInfo->MaxRenewAge,
  967. pLocal->pTemplate->pKerberosInfo->MaxRenewAge,
  968. ITEM_LOCALPOL_DW,-1,cookie,bVerify,
  969. pLocal, //The template to save this attribute in
  970. pDataObj); //The data object for the scope note who owns the result pane
  971. AddResultItem(IDS_KERBEROS_MAX_AGE,
  972. pEffective->pTemplate->pKerberosInfo->MaxTicketAge,
  973. pLocal->pTemplate->pKerberosInfo->MaxTicketAge,
  974. ITEM_LOCALPOL_DW,-1,cookie,bVerify,
  975. pLocal, //The template to save this attribute in
  976. pDataObj); //The data object for the scope note who owns the result pane
  977. break;
  978. case LOCALPOL_LOCKOUT:
  979. //
  980. // Account Lockout category
  981. //
  982. // L"Account lockout count", L"Attempts"
  983. AddResultItem(IDS_LOCK_COUNT,
  984. pEffective->pTemplate->LockoutBadCount,
  985. pLocal->pTemplate->LockoutBadCount,ITEM_LOCALPOL_DW, 1, cookie, bVerify,
  986. pLocal, //The template to save this attribute in
  987. pDataObj); //The data object for the scope note who owns the result pane
  988. // L"Reset lockout count after", L"Minutes"
  989. AddResultItem(IDS_LOCK_RESET_COUNT,
  990. pEffective->pTemplate->ResetLockoutCount,
  991. pLocal->pTemplate->ResetLockoutCount,
  992. ITEM_LOCALPOL_DW, 1, cookie, bVerify,
  993. pLocal, //The template to save this attribute in
  994. pDataObj); //The data object for the scope note who owns the result pane
  995. // L"Lockout duration", L"Minutes"
  996. AddResultItem(IDS_LOCK_DURATION,
  997. pEffective->pTemplate->LockoutDuration,
  998. pLocal->pTemplate->LockoutDuration,
  999. ITEM_LOCALPOL_DW, 1, cookie, bVerify,
  1000. pLocal, //The template to save this attribute in
  1001. pDataObj); //The data object for the scope note who owns the result pane
  1002. break;
  1003. case LOCALPOL_AUDIT:
  1004. //
  1005. // Event auditing
  1006. //
  1007. // L"Event Auditing Mode",
  1008. // AddResultItem(IDS_EVENT_ON, pLocal->pTemplate->EventAuditingOnOff,
  1009. // pEffective->pTemplate->EventAuditingOnOff, ITEM_LOCALPOL_BON, 1, cookie, bVerify);
  1010. // L"Audit system events"
  1011. AddResultItem(IDS_SYSTEM_EVENT,
  1012. pEffective->pTemplate->AuditSystemEvents,
  1013. pLocal->pTemplate->AuditSystemEvents,
  1014. ITEM_LOCALPOL_B2ON, 1, cookie, bVerify,
  1015. pLocal, //The template to save this attribute in
  1016. pDataObj); //The data object for the scope note who owns the result pane
  1017. // L"Audit logon events"
  1018. AddResultItem(IDS_LOGON_EVENT,
  1019. pEffective->pTemplate->AuditLogonEvents,
  1020. pLocal->pTemplate->AuditLogonEvents,
  1021. ITEM_LOCALPOL_B2ON, 1, cookie, bVerify,
  1022. pLocal, //The template to save this attribute in
  1023. pDataObj); //The data object for the scope note who owns the result pane
  1024. // L"Audit Object Access"
  1025. AddResultItem(IDS_OBJECT_ACCESS,
  1026. pEffective->pTemplate->AuditObjectAccess,
  1027. pLocal->pTemplate->AuditObjectAccess,
  1028. ITEM_LOCALPOL_B2ON, 1, cookie, bVerify,
  1029. pLocal, //The template to save this attribute in
  1030. pDataObj); //The data object for the scope note who owns the result pane
  1031. // L"Audit Privilege Use"
  1032. AddResultItem(IDS_PRIVILEGE_USE,
  1033. pEffective->pTemplate->AuditPrivilegeUse,
  1034. pLocal->pTemplate->AuditPrivilegeUse,
  1035. ITEM_LOCALPOL_B2ON, 1, cookie, bVerify,
  1036. pLocal, //The template to save this attribute in
  1037. pDataObj); //The data object for the scope note who owns the result pane
  1038. // L"Audit policy change"
  1039. AddResultItem(IDS_POLICY_CHANGE,
  1040. pEffective->pTemplate->AuditPolicyChange,
  1041. pLocal->pTemplate->AuditPolicyChange,
  1042. ITEM_LOCALPOL_B2ON, 1, cookie, bVerify,
  1043. pLocal, //The template to save this attribute in
  1044. pDataObj); //The data object for the scope note who owns the result pane
  1045. // L"Audit Account Manage"
  1046. AddResultItem(IDS_ACCOUNT_MANAGE,
  1047. pEffective->pTemplate->AuditAccountManage,
  1048. pLocal->pTemplate->AuditAccountManage,
  1049. ITEM_LOCALPOL_B2ON, 1, cookie, bVerify,
  1050. pLocal, //The template to save this attribute in
  1051. pDataObj); //The data object for the scope note who owns the result pane
  1052. // L"Audit process tracking"
  1053. AddResultItem(IDS_PROCESS_TRACK,
  1054. pEffective->pTemplate->AuditProcessTracking,
  1055. pLocal->pTemplate->AuditProcessTracking,
  1056. ITEM_LOCALPOL_B2ON, 1, cookie, bVerify,
  1057. pLocal, //The template to save this attribute in
  1058. pDataObj); //The data object for the scope note who owns the result pane
  1059. // L"Audit directory access "
  1060. AddResultItem(IDS_DIRECTORY_ACCESS,
  1061. pEffective->pTemplate->AuditDSAccess,
  1062. pLocal->pTemplate->AuditDSAccess,
  1063. ITEM_LOCALPOL_B2ON, 1, cookie, bVerify,
  1064. pLocal, //The template to save this attribute in
  1065. pDataObj); //The data object for the scope note who owns the result pane
  1066. // L"Audit account logon"
  1067. AddResultItem(IDS_ACCOUNT_LOGON,
  1068. pEffective->pTemplate->AuditAccountLogon,
  1069. pLocal->pTemplate->AuditAccountLogon,
  1070. ITEM_LOCALPOL_B2ON, 1, cookie, bVerify,
  1071. pLocal, //The template to save this attribute in
  1072. pDataObj); //The data object for the scope note who owns the result pane
  1073. break;
  1074. case LOCALPOL_LOG:
  1075. //
  1076. // Event Log setting
  1077. //
  1078. for ( i=0; i<3; i++) {
  1079. // Maximum Log Size
  1080. AddResultItem(IdsMax[i],
  1081. pEffective->pTemplate->MaximumLogSize[i],
  1082. pLocal->pTemplate->MaximumLogSize[i],
  1083. ITEM_LOCALPOL_DW, 1, cookie, bVerify,
  1084. pLocal, //The template to save this attribute in
  1085. pDataObj); //The data object for the scope note who owns the result pane
  1086. // L"... Log Retention Method",
  1087. AddResultItem(IdsRet[i],
  1088. pEffective->pTemplate->AuditLogRetentionPeriod[i],
  1089. pLocal->pTemplate->AuditLogRetentionPeriod[i],
  1090. ITEM_LOCALPOL_RET, 1, cookie, bVerify,
  1091. pLocal, //The template to save this attribute in
  1092. pDataObj); //The data object for the scope note who owns the result pane
  1093. if ( pLocal->pTemplate->AuditLogRetentionPeriod[i] == 1 ||
  1094. pEffective->pTemplate->AuditLogRetentionPeriod[i] == 1)
  1095. // L"... Log Retention days", "days"
  1096. AddResultItem(IdsDays[i],
  1097. pEffective->pTemplate->RetentionDays[i],
  1098. pLocal->pTemplate->RetentionDays[i],
  1099. ITEM_LOCALPOL_DW, 1, cookie, bVerify,
  1100. pLocal, //The template to save this attribute in
  1101. pDataObj); //The data object for the scope note who owns the result pane
  1102. // L"RestrictGuestAccess", L""
  1103. AddResultItem(IdsGuest[i],
  1104. pEffective->pTemplate->RestrictGuestAccess[i],
  1105. pLocal->pTemplate->RestrictGuestAccess[i],
  1106. ITEM_LOCALPOL_BOOL, 1, cookie, bVerify,
  1107. pLocal, //The template to save this attribute in
  1108. pDataObj); //The data object for the scope note who owns the result pane
  1109. }
  1110. break;
  1111. case LOCALPOL_OTHER:
  1112. // L"Force logoff when logon hour expire", L""
  1113. AddResultItem(IDS_FORCE_LOGOFF,
  1114. pEffective->pTemplate->ForceLogoffWhenHourExpire,
  1115. pLocal->pTemplate->ForceLogoffWhenHourExpire,
  1116. ITEM_LOCALPOL_BOOL, 1, cookie, bVerify,
  1117. pLocal, //The template to save this attribute in
  1118. pDataObj); //The data object for the scope note who owns the result pane
  1119. // L"Accounts: Administrator account status", L""
  1120. AddResultItem(IDS_ENABLE_ADMIN,
  1121. pEffective->pTemplate->EnableAdminAccount,
  1122. pLocal->pTemplate->EnableAdminAccount,
  1123. ITEM_LOCALPOL_BOOL, 1, cookie, bVerify,
  1124. pLocal, //The template to save this attribute in
  1125. pDataObj); //The data object for the scope note who owns the result pane
  1126. // L"Accounts: Guest account status", L""
  1127. AddResultItem(IDS_ENABLE_GUEST,
  1128. pEffective->pTemplate->EnableGuestAccount,
  1129. pLocal->pTemplate->EnableGuestAccount,
  1130. ITEM_LOCALPOL_BOOL, 1, cookie, bVerify,
  1131. pLocal, //The template to save this attribute in
  1132. pDataObj); //The data object for the scope note who owns the result pane
  1133. // L"Network access: Allow anonymous SID/Name translation"
  1134. AddResultItem(IDS_LSA_ANON_LOOKUP,
  1135. pEffective->pTemplate->LSAAnonymousNameLookup,
  1136. pLocal->pTemplate->LSAAnonymousNameLookup,
  1137. ITEM_LOCALPOL_BOOL, 1, cookie, bVerify,
  1138. pLocal, //The template to save this attribute in
  1139. pDataObj); //The data object for the scope note who owns the result pane
  1140. // L"New Administrator account name"
  1141. setting = (LONG_PTR)(pEffective->pTemplate->NewAdministratorName);
  1142. if ( !pLocal->pTemplate->NewAdministratorName ) {
  1143. status = SCE_STATUS_NOT_CONFIGURED;
  1144. } else if ( pEffective->pTemplate->NewAdministratorName) {
  1145. status = SCE_STATUS_MISMATCH;
  1146. } else {
  1147. setting = (LONG_PTR)(pEffective->pTemplate->NewAdministratorName);
  1148. status = SCE_STATUS_GOOD;
  1149. }
  1150. AddResultItem(IDS_NEW_ADMIN, setting,
  1151. (LONG_PTR)(LPCTSTR)pLocal->pTemplate->NewAdministratorName,
  1152. ITEM_LOCALPOL_SZ, status, cookie,false,
  1153. pLocal, //The template to save this attribute in
  1154. pDataObj); //The data object for the scope note who owns the result pane
  1155. // L"New Guest account name"
  1156. setting = (LONG_PTR)(pEffective->pTemplate->NewGuestName);
  1157. if ( !pLocal->pTemplate->NewGuestName ) {
  1158. status = SCE_STATUS_NOT_CONFIGURED;
  1159. } else if ( pEffective->pTemplate->NewGuestName) {
  1160. status = SCE_STATUS_MISMATCH;
  1161. } else {
  1162. setting = (LONG_PTR)(pEffective->pTemplate->NewGuestName);
  1163. status = SCE_STATUS_GOOD;
  1164. }
  1165. AddResultItem(IDS_NEW_GUEST, setting,
  1166. (LONG_PTR)(LPCTSTR)pLocal->pTemplate->NewGuestName,
  1167. ITEM_LOCALPOL_SZ, status, cookie,false,
  1168. pLocal, //The template to save this attribute in
  1169. pDataObj); //The data object for the scope note who owns the result pane
  1170. CreateAnalysisRegValueList(cookie, pEffective, pLocal, pDataObj,ITEM_LOCALPOL_REGVALUE);
  1171. break;
  1172. case LOCALPOL_PRIVILEGE: {
  1173. // find in the current setting list
  1174. CString strDisp;
  1175. TCHAR szPriv[255];
  1176. TCHAR szDisp[255];
  1177. DWORD cbDisp;
  1178. DWORD dwMatch;
  1179. PSCE_PRIVILEGE_ASSIGNMENT pPrivLocal;
  1180. PSCE_PRIVILEGE_ASSIGNMENT pPrivEffective;
  1181. for ( int i=0; i<cPrivCnt; i++ ) {
  1182. cbDisp = 255;
  1183. if ( SCESTATUS_SUCCESS == SceLookupPrivRightName(i,szPriv, (PINT)&cbDisp) ) {
  1184. // find the local setting
  1185. for (pPrivLocal=pLocal->pTemplate->OtherInfo.sap.pPrivilegeAssignedTo;
  1186. pPrivLocal!=NULL;
  1187. pPrivLocal=pPrivLocal->Next) {
  1188. if ( _wcsicmp(szPriv, pPrivLocal->Name) == 0 ) {
  1189. break;
  1190. }
  1191. }
  1192. // find the effective setting
  1193. for (pPrivEffective=pEffective->pTemplate->OtherInfo.smp.pPrivilegeAssignedTo;
  1194. pPrivEffective!=NULL;
  1195. pPrivEffective=pPrivEffective->Next) {
  1196. if ( _wcsicmp(szPriv, pPrivEffective->Name) == 0 ) {
  1197. break;
  1198. }
  1199. }
  1200. cbDisp = 255;
  1201. GetRightDisplayName(NULL,(LPCTSTR)szPriv,szDisp,&cbDisp);
  1202. //
  1203. // Status field is not loaded for local policy mode, except for not configured
  1204. //
  1205. dwMatch = CEditTemplate::ComputeStatus( pPrivLocal, pPrivEffective );
  1206. CResult *pResult = AddResultItem(szDisp, // The name of the attribute being added
  1207. (LONG_PTR)pPrivEffective, // The local policy setting of the attribute
  1208. (LONG_PTR)pPrivLocal, // The effective policy setting of the attribute
  1209. ITEM_LOCALPOL_PRIVS, // The type of of the attribute's data
  1210. dwMatch, // The mismatch status of the attribute
  1211. cookie, // The cookie for the result item pane
  1212. FALSE, // True if the setting is set only if it differs from base (so copy the data)
  1213. szPriv, // The units the attribute is set in
  1214. 0, // An id to let us know where to save this attribute
  1215. pLocal, // The template to save this attribute in
  1216. pDataObj); // The data object for the scope note who owns the result pane
  1217. }
  1218. }
  1219. break;
  1220. }
  1221. }
  1222. }
  1223. //+--------------------------------------------------------------------------
  1224. //
  1225. // Method: TransferAnalysisName
  1226. //
  1227. // Synopsis: Copy a name data from the last inspection information to the
  1228. // computer template
  1229. //
  1230. // Arguments: [dwItem] - The id of the item to copy
  1231. //
  1232. // Returns: none
  1233. //
  1234. //---------------------------------------------------------------------------
  1235. void
  1236. CSnapin::TransferAnalysisName(LONG_PTR dwItem)
  1237. {
  1238. PEDITTEMPLATE pet;
  1239. PSCE_PROFILE_INFO pProfileInfo;
  1240. PSCE_PROFILE_INFO pBaseInfo;
  1241. pet = GetTemplate(GT_LAST_INSPECTION,AREA_SECURITY_POLICY);
  1242. if (!pet) {
  1243. return;
  1244. }
  1245. pProfileInfo = pet->pTemplate;
  1246. pet = GetTemplate(GT_COMPUTER_TEMPLATE,AREA_SECURITY_POLICY);
  1247. if (!pet) {
  1248. return;
  1249. }
  1250. pBaseInfo = pet->pTemplate;
  1251. switch ( dwItem ) {
  1252. case IDS_NEW_GUEST:
  1253. if ( pProfileInfo->NewGuestName ) {
  1254. LocalFree(pProfileInfo->NewGuestName);
  1255. }
  1256. pProfileInfo->NewGuestName = pBaseInfo->NewGuestName;
  1257. pBaseInfo->NewGuestName = NULL;
  1258. break;
  1259. case IDS_NEW_ADMIN:
  1260. if ( pProfileInfo->NewAdministratorName ) {
  1261. LocalFree(pProfileInfo->NewAdministratorName);
  1262. }
  1263. pProfileInfo->NewAdministratorName = pBaseInfo->NewAdministratorName;
  1264. pBaseInfo->NewAdministratorName = NULL;
  1265. break;
  1266. }
  1267. }