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.

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