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.

800 lines
24 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: precdisp.cpp
  7. //
  8. // Contents: implementation of PRECEDENCEDISPLAY
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "wmihooks.h"
  13. #include "snapmgr.h"
  14. #include "cookie.h"
  15. #include "util.h"
  16. vector<PPRECEDENCEDISPLAY>* CResult::GetPrecedenceDisplays()
  17. {
  18. if (m_pvecPrecedenceDisplays)
  19. return m_pvecPrecedenceDisplays;
  20. switch(GetType())
  21. {
  22. case ITEM_PROF_BOOL:
  23. case ITEM_PROF_DW:
  24. case ITEM_PROF_SZ:
  25. case ITEM_PROF_RET:
  26. case ITEM_PROF_BON:
  27. case ITEM_PROF_B2ON:
  28. m_pvecPrecedenceDisplays = GetPolicyPrecedenceDisplays();
  29. break;
  30. case ITEM_PROF_REGVALUE:
  31. m_pvecPrecedenceDisplays = GetRegValuePrecedenceDisplays();
  32. break;
  33. case ITEM_PROF_PRIVS:
  34. m_pvecPrecedenceDisplays = GetPrivilegePrecedenceDisplays();
  35. break;
  36. case ITEM_PROF_GROUP:
  37. m_pvecPrecedenceDisplays = GetGroupPrecedenceDisplays();
  38. break;
  39. case ITEM_PROF_REGSD:
  40. m_pvecPrecedenceDisplays = GetRegistryPrecedenceDisplays();
  41. break;
  42. case ITEM_PROF_FILESD:
  43. m_pvecPrecedenceDisplays = GetFilePrecedenceDisplays();
  44. break;
  45. case ITEM_PROF_SERV:
  46. m_pvecPrecedenceDisplays = GetServicePrecedenceDisplays();
  47. break;
  48. default:
  49. // _ASSERT(0);
  50. break;
  51. }
  52. return m_pvecPrecedenceDisplays;
  53. }
  54. vector<PPRECEDENCEDISPLAY>* CResult::GetPolicyPrecedenceDisplays()
  55. {
  56. //
  57. // Get all of the RSOP info and loop through, collecting
  58. // the display info for the policy we care about.
  59. //
  60. CWMIRsop *pWMI = m_pSnapin->GetWMIRsop();
  61. ASSERT(pWMI);
  62. if (!pWMI)
  63. return NULL;
  64. vector<PPRECEDENCEDISPLAY> *pvecDisplay = new vector<PPRECEDENCEDISPLAY>;
  65. if (!pvecDisplay)
  66. return NULL;
  67. PPRECEDENCEDISPLAY ppd = NULL;
  68. vector<PWMI_SCE_PROFILE_INFO> vecInfo;
  69. if (FAILED(pWMI->GetAllRSOPInfo(&vecInfo)))
  70. {
  71. delete pvecDisplay;
  72. return NULL;
  73. }
  74. for(vector<PWMI_SCE_PROFILE_INFO>::iterator i = vecInfo.begin();
  75. i != vecInfo.end();
  76. ++i )
  77. {
  78. PWMI_SCE_PROFILE_INFO pspi = *i;
  79. ASSERT(pspi);
  80. if (!pspi)
  81. continue;
  82. LPTSTR szValue = NULL;
  83. LPTSTR szGPO = NULL;
  84. #define HANDLE_PROFILE_CASE(Y,X) \
  85. case Y: { \
  86. if (pspi->X == SCE_NO_VALUE) \
  87. continue; \
  88. else { \
  89. szValue = NULL; \
  90. szGPO = NULL; \
  91. TranslateSettingToString(pspi->X, GetUnits(), GetType(), &szValue); \
  92. if (szValue) \
  93. { \
  94. if (pspi->pRI##X && \
  95. SUCCEEDED(pWMI->GetGPOFriendlyName(pspi->pRI##X->pszGPOID,&szGPO))) \
  96. { \
  97. ULONG uStatus = pspi->pRI##X->status; \
  98. ULONG uError = pspi->pRI##X->error; \
  99. ppd = new PrecedenceDisplay(szGPO, \
  100. szValue, \
  101. uStatus, \
  102. uError); \
  103. if (ppd) \
  104. pvecDisplay->push_back(ppd); \
  105. LocalFree(szGPO); \
  106. } \
  107. delete [] szValue; \
  108. } \
  109. } \
  110. break; \
  111. }
  112. #define HANDLE_PROFILE_STRING_CASE(Y,X) \
  113. case Y: { \
  114. if (pspi->X == 0) { \
  115. continue; \
  116. } else { \
  117. szGPO = NULL; \
  118. if (pspi->pRI##X && \
  119. SUCCEEDED(pWMI->GetGPOFriendlyName(pspi->pRI##X->pszGPOID,&szGPO))) { \
  120. ULONG uStatus = pspi->pRI##X->status; \
  121. ULONG uError = pspi->pRI##X->error; \
  122. ppd = new PrecedenceDisplay(szGPO, \
  123. pspi->X, \
  124. uStatus, \
  125. uError); \
  126. if (ppd) \
  127. pvecDisplay->push_back(ppd); \
  128. LocalFree(szGPO); \
  129. } \
  130. } \
  131. break; \
  132. }
  133. LONG_PTR id = GetID ();
  134. switch (id)
  135. {
  136. // L"Maximum passage age", L"Days"
  137. HANDLE_PROFILE_CASE(IDS_MAX_PAS_AGE,MaximumPasswordAge);
  138. // L"Minimum passage age", L"Days"
  139. HANDLE_PROFILE_CASE(IDS_MIN_PAS_AGE,MinimumPasswordAge);
  140. // L"Minimum passage length", L"Characters"
  141. HANDLE_PROFILE_CASE(IDS_MIN_PAS_LEN,MinimumPasswordLength);
  142. // L"Password history size", L"Passwords"
  143. HANDLE_PROFILE_CASE(IDS_PAS_UNIQUENESS,PasswordHistorySize);
  144. // L"Password complexity", L""
  145. HANDLE_PROFILE_CASE(IDS_PAS_COMPLEX,PasswordComplexity);
  146. // L"Clear Text Password", L""
  147. HANDLE_PROFILE_CASE(IDS_CLEAR_PASSWORD,ClearTextPassword);
  148. // L"Require logon to change password", L""
  149. HANDLE_PROFILE_CASE(IDS_REQ_LOGON,RequireLogonToChangePassword);
  150. // L"Account lockout count", L"Attempts"
  151. HANDLE_PROFILE_CASE(IDS_LOCK_COUNT,LockoutBadCount);
  152. // L"Reset lockout count after", L"Minutes"
  153. HANDLE_PROFILE_CASE(IDS_LOCK_RESET_COUNT,ResetLockoutCount);
  154. // L"Lockout duration", L"Minutes"
  155. HANDLE_PROFILE_CASE(IDS_LOCK_DURATION,LockoutDuration);
  156. // L"Audit system events"
  157. HANDLE_PROFILE_CASE(IDS_SYSTEM_EVENT,AuditSystemEvents);
  158. // L"Audit logon events"
  159. HANDLE_PROFILE_CASE(IDS_LOGON_EVENT,AuditLogonEvents);
  160. // L"Audit Object Access"
  161. HANDLE_PROFILE_CASE(IDS_OBJECT_ACCESS,AuditObjectAccess);
  162. // L"Audit Privilege Use"
  163. HANDLE_PROFILE_CASE(IDS_PRIVILEGE_USE,AuditPrivilegeUse);
  164. // L"Audit policy change"
  165. HANDLE_PROFILE_CASE(IDS_POLICY_CHANGE,AuditPolicyChange);
  166. // L"Audit Account Manage"
  167. HANDLE_PROFILE_CASE(IDS_ACCOUNT_MANAGE,AuditAccountManage);
  168. // L"Audit process tracking"
  169. HANDLE_PROFILE_CASE(IDS_PROCESS_TRACK,AuditProcessTracking);
  170. // L"Audit directory service access"
  171. HANDLE_PROFILE_CASE(IDS_DIRECTORY_ACCESS,AuditDSAccess);
  172. // L"Audit Account Logon"
  173. HANDLE_PROFILE_CASE(IDS_ACCOUNT_LOGON,AuditAccountLogon);
  174. // L"Force logoff when logon hour expire", L""
  175. HANDLE_PROFILE_CASE(IDS_FORCE_LOGOFF,ForceLogoffWhenHourExpire);
  176. // L"Network access: Allow anonymous SID/Name translation"
  177. HANDLE_PROFILE_CASE(IDS_LSA_ANON_LOOKUP,LSAAnonymousNameLookup);
  178. // L"Accounts: Administrator account status", L""
  179. HANDLE_PROFILE_CASE(IDS_ENABLE_ADMIN,EnableAdminAccount);
  180. // L"Accounts: Guest account status", L""
  181. HANDLE_PROFILE_CASE(IDS_ENABLE_GUEST,EnableGuestAccount);
  182. // "Maximum application log size"
  183. HANDLE_PROFILE_CASE(IDS_APP_LOG_MAX, MaximumLogSize[0]);
  184. // "Maximum security log size"
  185. HANDLE_PROFILE_CASE(IDS_SEC_LOG_MAX, MaximumLogSize[1]);
  186. // "Maximum system log size"
  187. HANDLE_PROFILE_CASE(IDS_SYS_LOG_MAX, MaximumLogSize[2]);
  188. // "Prevent local guests group from accessing application log"
  189. HANDLE_PROFILE_CASE(IDS_APP_LOG_GUEST, RestrictGuestAccess[0]);
  190. // "Prevent local guests group from accessing security log"
  191. HANDLE_PROFILE_CASE(IDS_SEC_LOG_GUEST, RestrictGuestAccess[1]);
  192. // "Prevent local guests group from accessing system log"
  193. HANDLE_PROFILE_CASE(IDS_SYS_LOG_GUEST, RestrictGuestAccess[2]);
  194. // "Retain application log"
  195. HANDLE_PROFILE_CASE(IDS_APP_LOG_DAYS, RetentionDays[0]);
  196. // "Retain security log"
  197. HANDLE_PROFILE_CASE(IDS_SEC_LOG_DAYS, RetentionDays[1]);
  198. // "Retain system log"
  199. HANDLE_PROFILE_CASE(IDS_SYS_LOG_DAYS, RetentionDays[2]);
  200. // "Retention method for application log""
  201. HANDLE_PROFILE_CASE(IDS_APP_LOG_RET, AuditLogRetentionPeriod[0]);
  202. // "Retention method for security log"
  203. HANDLE_PROFILE_CASE(IDS_SEC_LOG_RET , AuditLogRetentionPeriod[1]);
  204. // "Retention method for system log"
  205. HANDLE_PROFILE_CASE(IDS_SYS_LOG_RET, AuditLogRetentionPeriod[2]);
  206. // "Accounts: Rename administrator account"
  207. HANDLE_PROFILE_STRING_CASE(IDS_NEW_ADMIN, NewAdministratorName);
  208. // "Accounts: Rename guest account"
  209. HANDLE_PROFILE_STRING_CASE(IDS_NEW_GUEST, NewGuestName);
  210. default:
  211. // _ASSERT (0);
  212. break;
  213. }
  214. }
  215. #undef HANDLE_PROFILE_CASE
  216. #undef HANDLE_PROFILE_STRING_CASE
  217. return pvecDisplay;
  218. }
  219. vector<PPRECEDENCEDISPLAY>* CResult::GetGroupPrecedenceDisplays()
  220. {
  221. //
  222. // Get all of the RSOP info and loop through, collecting
  223. // the display info for the policy we care about.
  224. //
  225. CWMIRsop *pWMI = m_pSnapin->GetWMIRsop();
  226. ASSERT(pWMI);
  227. if (!pWMI)
  228. return NULL;
  229. vector<PPRECEDENCEDISPLAY> *pvecDisplay = new vector<PPRECEDENCEDISPLAY>;
  230. if (!pvecDisplay)
  231. return NULL;
  232. PPRECEDENCEDISPLAY ppd = NULL;
  233. vector<PWMI_SCE_PROFILE_INFO> vecInfo;
  234. if (FAILED(pWMI->GetAllRSOPInfo(&vecInfo)))
  235. {
  236. delete pvecDisplay;
  237. return NULL;
  238. }
  239. for(vector<PWMI_SCE_PROFILE_INFO>::iterator i = vecInfo.begin();
  240. i != vecInfo.end();
  241. ++i )
  242. {
  243. PWMI_SCE_PROFILE_INFO pspi = *i;
  244. //
  245. // Find this group in pspi
  246. //
  247. PSCE_GROUP_MEMBERSHIP pGroup = pspi->pGroupMembership;
  248. list<PRSOP_INFO>::iterator pRIGroup = pspi->listRIGroupMemebership.begin();
  249. while(pGroup)
  250. {
  251. if (0 == lstrcmp(pGroup->GroupName,GetAttr()))
  252. {
  253. //
  254. // found our group
  255. //
  256. LPTSTR szValue1 = NULL;
  257. LPTSTR szValue2 = NULL;
  258. LPTSTR szGPO = NULL;
  259. ConvertNameListToString(pGroup->pMembers,&szValue1);
  260. ConvertNameListToString(pGroup->pMemberOf,&szValue2);
  261. //
  262. // szValue1 & szValue2 may legitimately be NULL
  263. //
  264. if (SUCCEEDED(pWMI->GetGPOFriendlyName((*pRIGroup)->pszGPOID,&szGPO)))
  265. {
  266. ULONG uError = (*pRIGroup)->error;
  267. ULONG uStatus = (*pRIGroup)->status;
  268. ppd = new PrecedenceDisplay(szGPO,
  269. szValue1,
  270. uStatus,
  271. uError,
  272. szValue2);
  273. if (ppd)
  274. pvecDisplay->push_back(ppd);
  275. LocalFree(szGPO);
  276. }
  277. if (szValue1)
  278. delete [] szValue1;
  279. if (szValue2)
  280. delete [] szValue2;
  281. break;
  282. }
  283. pGroup = pGroup->Next;
  284. ++pRIGroup;
  285. }
  286. }
  287. return pvecDisplay;
  288. }
  289. vector<PPRECEDENCEDISPLAY>* CResult::GetPrivilegePrecedenceDisplays()
  290. {
  291. //
  292. // Get all of the RSOP info and loop through, collecting
  293. // the display info for the policy we care about.
  294. //
  295. CWMIRsop *pWMI = m_pSnapin->GetWMIRsop();
  296. ASSERT(pWMI);
  297. if (!pWMI)
  298. return NULL;
  299. vector<PPRECEDENCEDISPLAY> *pvecDisplay = new vector<PPRECEDENCEDISPLAY>;
  300. if (!pvecDisplay)
  301. return NULL;
  302. PPRECEDENCEDISPLAY ppd = NULL;
  303. vector<PWMI_SCE_PROFILE_INFO> vecInfo;
  304. if (FAILED(pWMI->GetAllRSOPInfo(&vecInfo)))
  305. {
  306. delete pvecDisplay;
  307. return NULL;
  308. }
  309. if (GetID() <= 0)
  310. {
  311. return pvecDisplay;
  312. }
  313. PWSTR pName = ((PSCE_PRIVILEGE_ASSIGNMENT)GetID())->Name;
  314. if (NULL == pName)
  315. {
  316. return pvecDisplay;
  317. }
  318. for(vector<PWMI_SCE_PROFILE_INFO>::iterator i = vecInfo.begin();
  319. i != vecInfo.end();
  320. ++i)
  321. {
  322. PWMI_SCE_PROFILE_INFO pspi = *i;
  323. //
  324. // Find this group in pspi
  325. //
  326. PSCE_PRIVILEGE_ASSIGNMENT pPriv = pspi->OtherInfo.smp.pPrivilegeAssignedTo;
  327. list<PRSOP_INFO>::iterator pRIPriv = pspi->listRIInfPrivilegeAssignedTo.begin();
  328. while (pPriv)
  329. {
  330. if (0 == lstrcmp(pPriv->Name, pName))
  331. {
  332. //
  333. // found our privilege
  334. //
  335. LPTSTR szValue = NULL;
  336. LPTSTR szGPO = NULL;
  337. ConvertNameListToString(pPriv->AssignedTo,&szValue);
  338. //
  339. // szValue may legitimately be NULL
  340. //
  341. if (SUCCEEDED(pWMI->GetGPOFriendlyName((*pRIPriv)->pszGPOID,&szGPO)))
  342. {
  343. ULONG uStatus = (*pRIPriv)->status;
  344. ULONG uError = (*pRIPriv)->error;
  345. ppd = new PrecedenceDisplay(szGPO,
  346. szValue,
  347. uStatus,
  348. uError);
  349. if (ppd)
  350. pvecDisplay->push_back(ppd);
  351. LocalFree(szGPO);
  352. }
  353. if (szValue)
  354. delete [] szValue;
  355. break;
  356. }
  357. pPriv = pPriv->Next;
  358. ++pRIPriv;
  359. }
  360. }
  361. return pvecDisplay;
  362. }
  363. vector<PPRECEDENCEDISPLAY>* CResult::GetFilePrecedenceDisplays()
  364. {
  365. //
  366. // Get all of the RSOP info and loop through, collecting
  367. // the display info for the policy we care about.
  368. //
  369. CWMIRsop *pWMI = m_pSnapin->GetWMIRsop();
  370. ASSERT(pWMI);
  371. if (!pWMI)
  372. return NULL;
  373. vector<PPRECEDENCEDISPLAY> *pvecDisplay = new vector<PPRECEDENCEDISPLAY>;
  374. if (!pvecDisplay)
  375. return NULL;
  376. PPRECEDENCEDISPLAY ppd = NULL;
  377. vector<PWMI_SCE_PROFILE_INFO> vecInfo;
  378. if (FAILED(pWMI->GetAllRSOPInfo(&vecInfo)))
  379. {
  380. delete pvecDisplay;
  381. return NULL;
  382. }
  383. for(vector<PWMI_SCE_PROFILE_INFO>::iterator i = vecInfo.begin();
  384. i != vecInfo.end();
  385. ++i )
  386. {
  387. PWMI_SCE_PROFILE_INFO pspi = *i;
  388. //
  389. // Find this group in pspi
  390. //
  391. PSCE_OBJECT_ARRAY pFiles = pspi->pFiles.pAllNodes;
  392. if (pFiles)
  393. {
  394. for(DWORD j=0;j<pFiles->Count;j++)
  395. {
  396. if (0 == lstrcmp(pFiles->pObjectArray[j]->Name,GetAttr()))
  397. {
  398. //
  399. // Found our file
  400. //
  401. //
  402. // Just get the GPO name. Files don't have displayable settings
  403. //
  404. LPTSTR szGPO = NULL;
  405. vector<PRSOP_INFO>::reference pRIFiles = pspi->vecRIFiles[j];
  406. if (SUCCEEDED(pWMI->GetGPOFriendlyName((*pRIFiles).pszGPOID,&szGPO)))
  407. {
  408. ULONG uStatus = (*pRIFiles).status;
  409. ULONG uError = (*pRIFiles).error;
  410. ppd = new PrecedenceDisplay(szGPO,
  411. L"",
  412. uStatus,
  413. uError);
  414. if (ppd)
  415. pvecDisplay->push_back(ppd);
  416. }
  417. break;
  418. }
  419. }
  420. }
  421. }
  422. return pvecDisplay;
  423. }
  424. vector<PPRECEDENCEDISPLAY>* CResult::GetRegistryPrecedenceDisplays()
  425. {
  426. //
  427. // Get all of the RSOP info and loop through, collecting
  428. // the display info for the policy we care about.
  429. //
  430. CWMIRsop *pWMI = m_pSnapin->GetWMIRsop();
  431. ASSERT(pWMI);
  432. if (!pWMI)
  433. return NULL;
  434. vector<PPRECEDENCEDISPLAY> *pvecDisplay = new vector<PPRECEDENCEDISPLAY>;
  435. if (!pvecDisplay)
  436. return NULL;
  437. PPRECEDENCEDISPLAY ppd = NULL;
  438. vector<PWMI_SCE_PROFILE_INFO> vecInfo;
  439. if (FAILED(pWMI->GetAllRSOPInfo(&vecInfo)))
  440. {
  441. delete pvecDisplay;
  442. return NULL;
  443. }
  444. for(vector<PWMI_SCE_PROFILE_INFO>::iterator i = vecInfo.begin();
  445. i != vecInfo.end();
  446. ++i )
  447. {
  448. PWMI_SCE_PROFILE_INFO pspi = *i;
  449. //
  450. // Find this group in pspi
  451. //
  452. PSCE_OBJECT_ARRAY pRegistryKeys = pspi->pRegistryKeys.pAllNodes;
  453. if (pRegistryKeys)
  454. {
  455. for(DWORD j=0;j<pRegistryKeys->Count;j++)
  456. {
  457. if (0 == lstrcmp(pRegistryKeys->pObjectArray[j]->Name,GetAttr()))
  458. {
  459. //
  460. // Found our RegistryKey
  461. //
  462. //
  463. // Just get the GPO name. RegistryKeys don't have displayable settings
  464. //
  465. LPTSTR szGPO = NULL;
  466. vector<PRSOP_INFO>::reference pRIReg = pspi->vecRIReg[j];
  467. if (SUCCEEDED(pWMI->GetGPOFriendlyName((*pRIReg).pszGPOID,&szGPO)))
  468. {
  469. ULONG uStatus = (*pRIReg).status;
  470. ULONG uError = (*pRIReg).error;
  471. ppd = new PrecedenceDisplay(szGPO,
  472. L"",
  473. uStatus,
  474. uError);
  475. if (ppd)
  476. pvecDisplay->push_back(ppd);
  477. LocalFree(szGPO);
  478. }
  479. break;
  480. }
  481. }
  482. }
  483. }
  484. return pvecDisplay;
  485. }
  486. vector<PPRECEDENCEDISPLAY>* CResult::GetServicePrecedenceDisplays()
  487. {
  488. //
  489. // Get all of the RSOP info and loop through, collecting
  490. // the display info for the policy we care about.
  491. //
  492. CWMIRsop *pWMI = m_pSnapin->GetWMIRsop();
  493. ASSERT(pWMI);
  494. if (!pWMI)
  495. return NULL;
  496. vector<PPRECEDENCEDISPLAY> *pvecDisplay = new vector<PPRECEDENCEDISPLAY>;
  497. if (!pvecDisplay)
  498. return NULL;
  499. PPRECEDENCEDISPLAY ppd = NULL;
  500. vector<PWMI_SCE_PROFILE_INFO> vecInfo;
  501. if (FAILED(pWMI->GetAllRSOPInfo(&vecInfo)))
  502. {
  503. delete pvecDisplay;
  504. return NULL;
  505. }
  506. for(vector<PWMI_SCE_PROFILE_INFO>::iterator i = vecInfo.begin();
  507. i != vecInfo.end();
  508. ++i )
  509. {
  510. PWMI_SCE_PROFILE_INFO pspi = *i;
  511. //
  512. // Find this group in pspi
  513. //
  514. PSCE_SERVICES pServices = pspi->pServices;
  515. list<PRSOP_INFO>::iterator pRIServices = pspi->listRIServices.begin();
  516. while(pServices)
  517. {
  518. if (0 == lstrcmp(pServices->ServiceName,GetUnits()))
  519. {
  520. //
  521. // found our Servicesilege
  522. //
  523. LPTSTR szGPO = NULL;
  524. //
  525. // Just get the GPO name. Services don't have displayable settings
  526. //
  527. if (SUCCEEDED(pWMI->GetGPOFriendlyName((*pRIServices)->pszGPOID,&szGPO)))
  528. {
  529. ULONG uStatus = (*pRIServices)->status;
  530. ULONG uError = (*pRIServices)->error;
  531. ppd = new PrecedenceDisplay(szGPO,
  532. L"",
  533. uStatus,
  534. uError);
  535. if (ppd)
  536. pvecDisplay->push_back(ppd);
  537. LocalFree(szGPO);
  538. szGPO = NULL;
  539. }
  540. break;
  541. }
  542. pServices = pServices->Next;
  543. ++pRIServices;
  544. }
  545. }
  546. return pvecDisplay;
  547. }
  548. vector<PPRECEDENCEDISPLAY>* CResult::GetRegValuePrecedenceDisplays()
  549. {
  550. //
  551. // Get all of the RSOP info and loop through, collecting
  552. // the display info for the policy we care about.
  553. //
  554. CWMIRsop *pWMI = m_pSnapin->GetWMIRsop();
  555. ASSERT(pWMI);
  556. if (!pWMI)
  557. return NULL;
  558. vector<PPRECEDENCEDISPLAY> *pvecDisplay = new vector<PPRECEDENCEDISPLAY>;
  559. if (!pvecDisplay)
  560. return NULL;
  561. PPRECEDENCEDISPLAY ppd = NULL;
  562. vector<PWMI_SCE_PROFILE_INFO> vecInfo;
  563. if (FAILED(pWMI->GetAllRSOPInfo(&vecInfo)))
  564. {
  565. delete pvecDisplay;
  566. return NULL;
  567. }
  568. for(vector<PWMI_SCE_PROFILE_INFO>::iterator i = vecInfo.begin();
  569. i != vecInfo.end();
  570. ++i )
  571. {
  572. PWMI_SCE_PROFILE_INFO pspi = *i;
  573. //
  574. // Find this group in pspi
  575. //
  576. for(DWORD j=0;j < pspi->RegValueCount;j++)
  577. {
  578. if (0 == lstrcmp(pspi->aRegValues[j].FullValueName,((PSCE_REGISTRY_VALUE_INFO)GetBase())->FullValueName))
  579. {
  580. //
  581. // Found our Registry Value
  582. //
  583. LPTSTR pDisplayName=NULL;
  584. DWORD displayType = 0;
  585. LPTSTR szUnits=NULL;
  586. PREGCHOICE pChoices=NULL;
  587. PREGFLAGS pFlags=NULL;
  588. LPTSTR szValue = NULL;
  589. PSCE_REGISTRY_VALUE_INFO prv = (PSCE_REGISTRY_VALUE_INFO) GetBase();
  590. if (LookupRegValueProperty(prv->FullValueName,
  591. &pDisplayName,
  592. &displayType,
  593. &szUnits,
  594. &pChoices,
  595. &pFlags) )
  596. {
  597. //
  598. // Determine string by the item value.
  599. //
  600. switch ( GetID() )
  601. {
  602. case SCE_REG_DISPLAY_NUMBER:
  603. if ( prv->Value )
  604. {
  605. TranslateSettingToString(
  606. _wtol(prv->Value),
  607. GetUnits(),
  608. ITEM_DW,
  609. &szValue);
  610. }
  611. break;
  612. case SCE_REG_DISPLAY_CHOICE:
  613. if ( prv->Value )
  614. {
  615. TranslateSettingToString(_wtol(prv->Value),
  616. NULL,
  617. ITEM_REGCHOICE,
  618. &szValue);
  619. }
  620. break;
  621. case SCE_REG_DISPLAY_FLAGS:
  622. if ( prv->Value )
  623. {
  624. TranslateSettingToString(_wtol(prv->Value),
  625. NULL,
  626. ITEM_REGFLAGS,
  627. &szValue);
  628. }
  629. break;
  630. case SCE_REG_DISPLAY_MULTISZ:
  631. case SCE_REG_DISPLAY_STRING:
  632. if (prv && prv->Value)
  633. {
  634. szValue = new TCHAR[lstrlen(prv->Value)+1];
  635. if (szValue)
  636. lstrcpy(szValue,prv->Value);
  637. }
  638. break;
  639. default: // boolean
  640. if ( prv->Value )
  641. {
  642. long val = _wtol(prv->Value);
  643. TranslateSettingToString( val,
  644. NULL,
  645. ITEM_BOOL,
  646. &szValue);
  647. }
  648. break;
  649. }
  650. }
  651. LPTSTR szGPO = NULL;
  652. vector<PRSOP_INFO>::reference pRIReg = pspi->vecRIRegValues[j];
  653. if (SUCCEEDED(pWMI->GetGPOFriendlyName((*pRIReg).pszGPOID,&szGPO)))
  654. {
  655. ULONG uStatus = (*pRIReg).status;
  656. ULONG uError = (*pRIReg).error;
  657. ppd = new PrecedenceDisplay(szGPO,
  658. szValue,
  659. uStatus,
  660. uError);
  661. if (ppd)
  662. {
  663. pvecDisplay->push_back(ppd);
  664. szGPO = NULL;
  665. szValue = NULL;
  666. }
  667. }
  668. if ( szGPO )
  669. LocalFree(szGPO);
  670. if ( szValue )
  671. delete [] szValue;
  672. //
  673. // no need to keep looking once we've found the one we're looking for
  674. //
  675. break;
  676. }
  677. }
  678. }
  679. return pvecDisplay;
  680. }