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.

3441 lines
121 KiB

  1. /*********************************************************************************************
  2. Copyright (c) Microsoft Corporation
  3. Module Name:
  4. VerboseLoggingData.cpp
  5. Abstract:
  6. The verbose data is displayed in this module.
  7. Author:
  8. Wipro Technologies
  9. Revision History:
  10. 22-Feb-2001 : Created It.
  11. *********************************************************************************************/
  12. #include "pch.h"
  13. #include "GpResult.h"
  14. #include "WMI.h"
  15. #include "VerboseLoggingData.h"
  16. /*********************************************************************************************
  17. Routine Description:
  18. This function displays the verbose data for the scope - computer
  19. Arguments:
  20. [in] IWbemServices *pRsopNameSpace : interface pointer
  21. Return Value:
  22. TRUE on SUCCESS
  23. FALSE on FAILURE
  24. *********************************************************************************************/
  25. BOOL CGpResult::DisplayVerboseComputerData( IWbemServices *pNameSpace )
  26. {
  27. DWORD dwLength = 0;
  28. //
  29. // Display the verbose information for the scope - computer
  30. // Display the header
  31. ShowMessage( stdout, GetResString( IDS_COMPUTER_RESULT ) );
  32. ShowMessage( stdout, GetResString( IDS_NEWLINE_TAB ) );
  33. for( dwLength = lstrlen( GetResString( IDS_COMPUTER_RESULT ) ); dwLength > 4; dwLength-- )
  34. {
  35. ShowMessage( stdout, GetResString( IDS_DASH ) );
  36. }
  37. ShowMessage( stdout, NEW_LINE );
  38. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  39. // Display the software installations
  40. ShowMessage( stdout, GetResString( IDS_SW_SETTINGS ) );
  41. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  42. for( dwLength = lstrlen( GetResString( IDS_SW_SETTINGS ) ); dwLength > 0; dwLength-- )
  43. {
  44. ShowMessage( stdout, GetResString( IDS_DASH ) );
  45. }
  46. DisplaySoftwareInstallations( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  47. // Display the start-up data
  48. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  49. ShowMessage( stdout, GetResString( IDS_WS_SSU ) );
  50. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  51. for( dwLength = lstrlen( GetResString( IDS_WS_SSU ) ); dwLength > 0; dwLength-- )
  52. {
  53. ShowMessage( stdout, GetResString( IDS_DASH ) );
  54. }
  55. DisplayScripts( pNameSpace, TRUE, m_pAuthIdentity, m_bSuperVerbose );
  56. // Display the shut-down data
  57. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  58. ShowMessage( stdout, GetResString( IDS_WS_SSD ) );
  59. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  60. for( dwLength = lstrlen( GetResString( IDS_WS_SSD ) ); dwLength > 0; dwLength-- )
  61. {
  62. ShowMessage( stdout, GetResString( IDS_DASH ) );
  63. }
  64. DisplayScripts( pNameSpace, FALSE, m_pAuthIdentity, m_bSuperVerbose );
  65. // Display the password policy
  66. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  67. ShowMessage( stdout, GetResString( IDS_WS_SS_AP_PP ) );
  68. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  69. for( dwLength = lstrlen( GetResString( IDS_WS_SS_AP_PP ) ); dwLength > 0; dwLength-- )
  70. {
  71. ShowMessage( stdout, GetResString( IDS_DASH ) );
  72. }
  73. DisplayPasswordPolicy( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  74. // Display the Audit Policy
  75. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  76. ShowMessage( stdout, GetResString( IDS_WS_SS_LP_AP ) );
  77. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  78. for( dwLength = lstrlen( GetResString( IDS_WS_SS_LP_AP ) ); dwLength > 0; dwLength-- )
  79. {
  80. ShowMessage( stdout, GetResString( IDS_DASH ) );
  81. }
  82. DisplayAuditPolicy( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  83. // Display the user rights
  84. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  85. ShowMessage( stdout, GetResString( IDS_WS_SS_LP_URA ) );
  86. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  87. for( dwLength = lstrlen( GetResString( IDS_WS_SS_LP_URA ) ); dwLength > 0; dwLength-- )
  88. {
  89. ShowMessage( stdout, GetResString( IDS_DASH ) );
  90. }
  91. DisplayUserRights( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  92. // Display the security options
  93. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  94. ShowMessage( stdout, GetResString( IDS_WS_SS_LP_SO ) );
  95. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  96. for( dwLength = lstrlen( GetResString( IDS_WS_SS_LP_SO ) ); dwLength > 0; dwLength-- )
  97. {
  98. ShowMessage( stdout, GetResString( IDS_DASH ) );
  99. }
  100. DisplaySecurityandEvents( pNameSpace, CLS_SECURITY_BOOLEAN, m_pAuthIdentity, m_bSuperVerbose );
  101. DisplaySecurityandEvents( pNameSpace, CLS_SECURITY_STRING, m_pAuthIdentity, m_bSuperVerbose );
  102. // Display the event log information
  103. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  104. ShowMessage( stdout, GetResString( IDS_WS_SS_EL ) );
  105. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  106. for( dwLength = lstrlen( GetResString( IDS_WS_SS_EL ) ); dwLength > 0; dwLength-- )
  107. {
  108. ShowMessage( stdout, GetResString( IDS_DASH ) );
  109. }
  110. DisplaySecurityandEvents( pNameSpace, CLS_EVENTLOG_NUMERIC, m_pAuthIdentity, m_bSuperVerbose );
  111. DisplaySecurityandEvents( pNameSpace, CLS_EVENTLOG_BOOLEAN, m_pAuthIdentity, m_bSuperVerbose );
  112. // Display the restricted groups information
  113. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  114. ShowMessage( stdout, GetResString( IDS_WS_SS_RG ) );
  115. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  116. for( dwLength = lstrlen( GetResString( IDS_WS_SS_RG ) ); dwLength > 0; dwLength-- )
  117. {
  118. ShowMessage( stdout, GetResString( IDS_DASH ) );
  119. }
  120. DisplayRestrictedGroups( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  121. // Display the system services information
  122. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  123. ShowMessage( stdout, GetResString( IDS_WS_SS_SS ) );
  124. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  125. for( dwLength = lstrlen( GetResString( IDS_WS_SS_SS ) ); dwLength > 0; dwLength-- )
  126. {
  127. ShowMessage( stdout, GetResString( IDS_DASH ) );
  128. }
  129. DisplaySystemServices( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  130. // Display the registry information
  131. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  132. ShowMessage( stdout, GetResString( IDS_WS_SS_REG ) );
  133. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  134. for( dwLength = lstrlen( GetResString( IDS_WS_SS_REG ) ); dwLength > 0; dwLength-- )
  135. {
  136. ShowMessage( stdout, GetResString( IDS_DASH ) );
  137. }
  138. DisplayRegistryandFileInfo( pNameSpace, CLS_REGISTRY, m_pAuthIdentity, m_bSuperVerbose );
  139. // Display the file information
  140. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  141. ShowMessage( stdout, GetResString( IDS_WS_SS_FS ) );
  142. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  143. for( dwLength = lstrlen( GetResString( IDS_WS_SS_FS ) ); dwLength > 0; dwLength-- )
  144. {
  145. ShowMessage( stdout, GetResString( IDS_DASH ) );
  146. }
  147. DisplayRegistryandFileInfo( pNameSpace, CLS_FILE, m_pAuthIdentity, m_bSuperVerbose );
  148. // Display the public key policies
  149. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  150. ShowMessage( stdout, GetResString( IDS_WS_SS_PKP ) );
  151. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  152. for( dwLength = lstrlen( GetResString( IDS_WS_SS_PKP ) ); dwLength > 0; dwLength-- )
  153. {
  154. ShowMessage( stdout, GetResString( IDS_DASH ) );
  155. }
  156. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  157. ShowMessage( stdout, V_NOT_AVAILABLE );
  158. ShowMessage( stdout, NEW_LINE );
  159. // Display the administrative templates
  160. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  161. ShowMessage( stdout, GetResString( IDS_ADTS_ERS ) );
  162. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  163. for( dwLength = lstrlen( GetResString( IDS_ADTS_ERS ) ); dwLength > 0; dwLength-- )
  164. {
  165. ShowMessage( stdout, GetResString( IDS_DASH ) );
  166. }
  167. DisplayTemplates( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  168. return TRUE;
  169. }
  170. /*********************************************************************************************
  171. Routine Description
  172. This function displays the software installations for the system or user
  173. Arguments:
  174. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  175. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure.
  176. [in] BOOL bSuperVerbose : is set to TRUE if the super verbose
  177. information is to be displayed.
  178. Return Value:
  179. None
  180. *********************************************************************************************/
  181. VOID DisplaySoftwareInstallations( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  182. BOOL bSuperVerbose )
  183. {
  184. HRESULT hResult = S_OK;
  185. BOOL bResult = FALSE;
  186. BOOL bFlag = FALSE;
  187. BOOL bGotClass = FALSE;
  188. IWbemClassObject *pClass = NULL;
  189. IEnumWbemClassObject *pEnumClass = NULL;
  190. CHString strTemp;
  191. TCHAR szTemp[ MAX_STRING_LENGTH ];
  192. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  193. ULONG ulReturned = 0;
  194. DWORD dwTemp = 0;
  195. try
  196. {
  197. if( pNameSpace == NULL )
  198. {
  199. _com_issue_error( STG_E_UNKNOWN );
  200. }
  201. ZeroMemory( szTemp, sizeof( szTemp ) );
  202. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  203. // Form the query string
  204. if( bSuperVerbose == TRUE )
  205. {
  206. // ennumerate all the classes
  207. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  208. FORMAT_STRING( szQueryString, szTemp, CLS_SOFTWARE );
  209. }
  210. else
  211. {
  212. // ennumerate all the classes with precedance = 1
  213. lstrcpy( szTemp, QUERY_VERBOSE );
  214. FORMAT_STRING( szQueryString, szTemp, CLS_SOFTWARE );
  215. }
  216. // Get the pointer to ennumerate with
  217. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  218. _bstr_t( szQueryString ),
  219. WBEM_FLAG_FORWARD_ONLY |
  220. WBEM_FLAG_RETURN_IMMEDIATELY,
  221. NULL, &pEnumClass );
  222. CHECK_HRESULT( hResult );
  223. // Set the interface security
  224. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  225. CHECK_HRESULT( hResult );
  226. // Enumerate the classes one by one and get the data
  227. hResult = WBEM_S_NO_ERROR;
  228. while( WBEM_S_NO_ERROR == hResult )
  229. {
  230. // Get the next class
  231. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  232. CHECK_HRESULT( hResult );
  233. if( ulReturned == 0 )
  234. {
  235. // No more classes to enumerate
  236. // Display N/A if there were no classes
  237. if( bGotClass == FALSE )
  238. {
  239. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  240. ShowMessage( stdout, V_NOT_AVAILABLE );
  241. ShowMessage( stdout, NEW_LINE );
  242. }
  243. break;
  244. }
  245. bGotClass = TRUE;
  246. // Get the GPO id
  247. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  248. CHECK_BRESULT( bResult );
  249. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  250. // Display the GPO name
  251. ShowMessage( stdout, GetResString( IDS_GPO ) );
  252. GpoName( pNameSpace, szTemp, pAuthIdentity );
  253. // Got the class.....get the name of the installable
  254. bResult = PropertyGet( pClass, CPV_APP_NAME, strTemp, V_NOT_AVAILABLE );
  255. CHECK_BRESULT( bResult );
  256. ShowMessage( stdout, GetResString( IDS_APP_NAME ) );
  257. ShowMessage( stdout, strTemp );
  258. // Get the version number
  259. bResult = PropertyGet( pClass, CPV_VER_HI, dwTemp, 0 );
  260. CHECK_BRESULT( bResult );
  261. wsprintf( szTemp, _T( "%u" ), dwTemp );
  262. lstrcat( szTemp, _T( "." ) );
  263. ShowMessage( stdout, GetResString( IDS_APP_VERSION ) );
  264. ShowMessage( stdout, szTemp );
  265. bResult = PropertyGet( pClass, CPV_VER_LO, dwTemp, 0 );
  266. CHECK_BRESULT( bResult );
  267. wsprintf( szTemp, _T( "%u" ), dwTemp );
  268. ShowMessage( stdout, szTemp );
  269. // Get the Deployment state
  270. bResult = PropertyGet( pClass, CPV_DEPLOY_STATE, dwTemp, 0 );
  271. CHECK_BRESULT( bResult );
  272. ShowMessage( stdout, GetResString( IDS_DEPLOY_STATE ) );
  273. switch( dwTemp )
  274. {
  275. case 1: ShowMessage( stdout, GetResString( IDS_ASSIGNED ) );
  276. break;
  277. case 2: ShowMessage( stdout, GetResString( IDS_PUBLISHED ) );
  278. break;
  279. default: ShowMessage( stdout, V_NOT_AVAILABLE );
  280. break;
  281. }
  282. // Get the Deployment state
  283. bResult = PropertyGet( pClass, CPV_APP_SRC, strTemp, 0 );
  284. CHECK_BRESULT( bResult );
  285. ShowMessage( stdout, GetResString( IDS_APP_SRC ) );
  286. ShowMessage( stdout, strTemp );
  287. // Get the auto-install information
  288. bResult = PropertyGet( pClass, CPV_AUTO_INSTALL, dwTemp, 2 );
  289. CHECK_BRESULT( bResult );
  290. ShowMessage( stdout, GetResString( IDS_AUTOINSTALL ) );
  291. if( dwTemp == VAR_TRUE )
  292. {
  293. ShowMessage( stdout, GetResString( IDS_TRUE ) );
  294. }
  295. else
  296. {
  297. ShowMessage( stdout, GetResString( IDS_FALSE ) );
  298. }
  299. // Get the origin information
  300. ShowMessage( stdout, GetResString( IDS_ORIGIN ) );
  301. bResult = PropertyGet( pClass, CPV_ORIGIN, dwTemp, 0 );
  302. CHECK_BRESULT( bResult );
  303. switch( dwTemp )
  304. {
  305. case 1: ShowMessage( stdout, GetResString( IDS_APPLICATION ) );
  306. break;
  307. case 2: ShowMessage( stdout, GetResString( IDS_REMOVED ) );
  308. break;
  309. case 3: ShowMessage( stdout, GetResString( IDS_ARP ) );
  310. break;
  311. default: ShowMessage( stdout, V_NOT_AVAILABLE );
  312. break;
  313. }
  314. ShowMessage( stdout, NEW_LINE );
  315. }// while
  316. }
  317. catch( _com_error & error )
  318. {
  319. WMISaveError( error.Error() );
  320. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  321. ShowMessage( stderr, GetReason() );
  322. }
  323. // release the interface pointers
  324. SAFEIRELEASE( pEnumClass );
  325. SAFEIRELEASE( pClass );
  326. return;
  327. }
  328. /*********************************************************************************************
  329. Routine Description
  330. This function displays the scripts policy setting for both start-up and
  331. shut-down.
  332. Arguments:
  333. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  334. [in] BOOL bScriptFlag : script type.
  335. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  336. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  337. info is to be displayed..
  338. Return Value:
  339. None
  340. *********************************************************************************************/
  341. VOID DisplayScripts( IWbemServices *pNameSpace, BOOL bStartUp,
  342. COAUTHIDENTITY *pAuthIdentity, BOOL bSuperVerbose )
  343. {
  344. HRESULT hResult = S_OK;
  345. BOOL bResult = FALSE;
  346. BOOL bGotClass = FALSE;
  347. BOOL bLocaleChanged = FALSE;
  348. IWbemClassObject *pClass = NULL;
  349. IEnumWbemClassObject *pEnumClass = NULL;
  350. IWbemClassObject *pScriptObject = NULL;
  351. VARIANT vVarScript;
  352. VARTYPE vartype;
  353. SAFEARRAY *safeArray = NULL;
  354. CHString strTemp;
  355. TCHAR szTemp[ MAX_STRING_LENGTH ];
  356. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  357. ULONG ulReturned = 0;
  358. LONG lLBound = 0;
  359. LONG lUBound = 0;
  360. SYSTEMTIME SysTime;
  361. LCID lcid;
  362. try
  363. {
  364. if( pNameSpace == NULL )
  365. {
  366. _com_issue_error( STG_E_UNKNOWN );
  367. }
  368. ZeroMemory( szTemp, sizeof( szTemp ) );
  369. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  370. if( bStartUp == TRUE )
  371. {
  372. lstrcpy( szTemp, QUERY_START_UP );
  373. }
  374. else
  375. {
  376. lstrcpy( szTemp, QUERY_SHUT_DOWN );
  377. }
  378. // Form the query string
  379. if( bSuperVerbose == TRUE )
  380. {
  381. // ennumerate all the classes
  382. FORMAT_STRING( szQueryString, szTemp, CLS_SCRIPTS );
  383. }
  384. else
  385. {
  386. // ennumerate all the classes with precedance = 1
  387. FORMAT_STRING( szQueryString, szTemp, CLS_SCRIPTS );
  388. lstrcat( szQueryString, QUERY_ADD_VERBOSE );
  389. }
  390. // Get the pointer to ennumerate with
  391. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  392. _bstr_t( szQueryString ),
  393. WBEM_FLAG_FORWARD_ONLY |
  394. WBEM_FLAG_RETURN_IMMEDIATELY,
  395. NULL, &pEnumClass );
  396. CHECK_HRESULT( hResult );
  397. // Set the interface security
  398. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  399. CHECK_HRESULT( hResult );
  400. // Enumerate the classes one by one and get the data
  401. hResult = WBEM_S_NO_ERROR;
  402. while( WBEM_S_NO_ERROR == hResult )
  403. {
  404. // Get the next class
  405. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  406. CHECK_HRESULT( hResult );
  407. if( ulReturned == 0 )
  408. {
  409. // No more classes to enumerate
  410. // Display N/A if there were no classes
  411. if( bGotClass == FALSE )
  412. {
  413. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  414. ShowMessage( stdout, V_NOT_AVAILABLE );
  415. ShowMessage( stdout, NEW_LINE );
  416. }
  417. break;
  418. }
  419. bGotClass = TRUE;
  420. // Get the GPO id...
  421. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  422. CHECK_BRESULT( bResult );
  423. // Display the GPO name
  424. lstrcpy( szTemp, strTemp );
  425. ShowMessage( stdout, GetResString( IDS_GPO ) );
  426. GpoName( pNameSpace, szTemp, pAuthIdentity );
  427. // Get the script list
  428. VariantInit( &vVarScript );
  429. hResult = pClass->Get( _bstr_t( CPV_SCRIPTLIST ), 0, &vVarScript, 0, 0 );
  430. CHECK_HRESULT_VAR( hResult, vVarScript );
  431. if( vVarScript.vt != VT_NULL && vVarScript.vt != VT_EMPTY )
  432. {
  433. // get the type of the elements in the safe array
  434. vartype = V_VT( &vVarScript ) & ~VT_ARRAY;
  435. // Get the array of script objects into a safe array
  436. safeArray = ( SAFEARRAY * )vVarScript.parray;
  437. //get the number of subkeys
  438. if( safeArray != NULL )
  439. {
  440. hResult = SafeArrayGetLBound( safeArray, 1, &lLBound );
  441. CHECK_HRESULT( hResult );
  442. hResult = SafeArrayGetUBound( safeArray, 1, &lUBound );
  443. CHECK_HRESULT( hResult );
  444. }
  445. // Get the identifier values for each sub-key
  446. for( ; lLBound <= lUBound; lLBound++ )
  447. {
  448. // Get the script object interface pointer...
  449. bResult = GetPropertyFromSafeArray( safeArray, lLBound, &pScriptObject, vartype );
  450. CHECK_BRESULT( bResult );
  451. // Get the script...
  452. bResult = PropertyGet( pScriptObject, CPV_SCRIPT, strTemp, V_NOT_AVAILABLE );
  453. CHECK_BRESULT( bResult );
  454. ShowMessage( stdout, GetResString( IDS_NAME ) );
  455. ShowMessage( stdout, strTemp );
  456. // Get the arguments...
  457. bResult = PropertyGet( pScriptObject, CPV_ARGUMENTS, strTemp,
  458. V_NOT_AVAILABLE );
  459. CHECK_BRESULT( bResult );
  460. ShowMessage( stdout, GetResString( IDS_PARAMETERS ) );
  461. ShowMessage( stdout, strTemp );
  462. // Get the execution time...
  463. bResult = PropertyGet( pScriptObject, CPV_EXECTIME, strTemp,
  464. V_NOT_AVAILABLE );
  465. CHECK_BRESULT( bResult );
  466. ShowMessage( stdout, GetResString( IDS_LASTEXECUTED ) );
  467. // Check if the str is zero
  468. if( strTemp.Compare( ZERO ) == 0 )
  469. {
  470. ShowMessage( stdout, GetResString( IDS_NOT_EXECUTED ) );
  471. }
  472. else
  473. {
  474. bResult = PropertyGet( pScriptObject, CPV_EXECTIME, SysTime );
  475. CHECK_BRESULT( bResult );
  476. // verify whether console supports the current locale 100% or not
  477. lcid = GetSupportedUserLocale( bLocaleChanged );
  478. // now format the date
  479. GetTimeFormat( LOCALE_USER_DEFAULT, 0,
  480. &SysTime, ((bLocaleChanged == TRUE) ? L"HH:mm:ss" : NULL),
  481. szTemp, SIZE_OF_ARRAY( szTemp ) );
  482. ShowMessage( stdout, szTemp );
  483. }
  484. ShowMessage( stdout, NEW_LINE );
  485. }//end for safearray
  486. }
  487. else
  488. {
  489. ShowMessage( stdout, V_NOT_AVAILABLE );
  490. ShowMessage( stdout, NEW_LINE );
  491. V_VT( &vVarScript ) = VT_EMPTY;
  492. }
  493. VariantClear(&vVarScript);
  494. }// while
  495. }
  496. catch(_com_error & error)
  497. {
  498. WMISaveError( error.Error() );
  499. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  500. ShowMessage( stderr, GetReason() );
  501. VariantClear( &vVarScript );
  502. }
  503. // release the interface pointers
  504. SAFEIRELEASE(pEnumClass);
  505. SAFEIRELEASE(pClass);
  506. SAFEIRELEASE(pScriptObject);
  507. return;
  508. }
  509. /*********************************************************************************************
  510. Routine Description
  511. This function displays the password policy for the computer configuration
  512. Arguments:
  513. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  514. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  515. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  516. info is to be displayed..
  517. Return Value:
  518. None
  519. *********************************************************************************************/
  520. VOID DisplayPasswordPolicy( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  521. BOOL bSuperVerbose )
  522. {
  523. HRESULT hResult = S_OK;
  524. BOOL bResult = FALSE;
  525. BOOL bGotClass = FALSE;
  526. ULONG ulReturned = 0;
  527. CHString strTemp;
  528. TCHAR szTemp[ MAX_STRING_LENGTH ];
  529. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  530. IWbemClassObject *pClass = NULL;
  531. IEnumWbemClassObject *pEnumClass = NULL;
  532. try
  533. {
  534. if( pNameSpace == NULL )
  535. {
  536. _com_issue_error( STG_E_UNKNOWN );
  537. }
  538. ZeroMemory( szTemp, sizeof( szTemp ) );
  539. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  540. // Form the query string
  541. if( bSuperVerbose == TRUE )
  542. {
  543. // ennumerate all the classes
  544. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  545. FORMAT_STRING( szQueryString, szTemp, CLS_PASSWD_POLICY );
  546. }
  547. else
  548. {
  549. // ennumerate all the classes with precedance = 1
  550. lstrcpy( szTemp, QUERY_VERBOSE );
  551. FORMAT_STRING( szQueryString, szTemp, CLS_PASSWD_POLICY );
  552. }
  553. // Get the pointer to ennumerate with
  554. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  555. _bstr_t( szQueryString ),
  556. WBEM_FLAG_FORWARD_ONLY |
  557. WBEM_FLAG_RETURN_IMMEDIATELY,
  558. NULL, &pEnumClass );
  559. CHECK_HRESULT( hResult );
  560. // Set the interface security
  561. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  562. if(FAILED( hResult ) )
  563. {
  564. _com_issue_error( hResult );
  565. }
  566. hResult = WBEM_S_NO_ERROR;
  567. while( WBEM_S_NO_ERROR == hResult )
  568. {
  569. // Get the next class
  570. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  571. CHECK_HRESULT( hResult );
  572. if( ulReturned == 0 )
  573. {
  574. // No more classes to enumerate
  575. // Display N/A if there were no classes
  576. if( bGotClass == FALSE )
  577. {
  578. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  579. ShowMessage( stdout, V_NOT_AVAILABLE );
  580. ShowMessage( stdout, NEW_LINE );
  581. }
  582. break;
  583. }
  584. bGotClass = TRUE;
  585. // Get the GPO id
  586. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  587. CHECK_BRESULT( bResult );
  588. // Display the GPO name
  589. lstrcpy( szTemp, strTemp );
  590. ShowMessage( stdout, GetResString( IDS_GPO ) );
  591. GpoName( pNameSpace, szTemp, pAuthIdentity );
  592. // get the key name
  593. bResult = PropertyGet( pClass, CPV_KEYNAME1, strTemp, V_NOT_AVAILABLE );
  594. CHECK_BRESULT( bResult );
  595. ShowMessage(stdout, GetResString( IDS_POLICY ) );
  596. ShowMessage(stdout, strTemp);
  597. // get the setting
  598. bResult = PropertyGet( pClass, CPV_SETTING1, ulReturned, 0 );
  599. CHECK_BRESULT( bResult );
  600. ShowMessage(stdout, GetResString( IDS_COMPUTER_SETTING ) );
  601. if( ulReturned == 0)
  602. {
  603. ShowMessage( stdout, V_NOT_AVAILABLE );
  604. }
  605. else
  606. {
  607. DISPLAY_MESSAGE1( stdout, szTemp, _T( "%u" ), ulReturned );
  608. }
  609. ShowMessage( stdout, NEW_LINE );
  610. }// while
  611. }
  612. catch( _com_error & error )
  613. {
  614. WMISaveError( error.Error() );
  615. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  616. ShowMessage( stderr, GetReason() );
  617. }
  618. // release the interface pointers
  619. SAFEIRELEASE( pEnumClass );
  620. SAFEIRELEASE( pClass );
  621. return;
  622. }
  623. /*********************************************************************************************
  624. Routine Description
  625. This function displays the Audit policy for the computer configuration.
  626. Arguments:
  627. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  628. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  629. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  630. info is to be displayed..
  631. Return Value:
  632. None
  633. *********************************************************************************************/
  634. VOID DisplayAuditPolicy( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  635. BOOL bSuperVerbose )
  636. {
  637. HRESULT hResult = S_OK;
  638. BOOL bResult = FALSE;
  639. BOOL bGotClass = FALSE;
  640. BOOL bTemp = FALSE;
  641. DWORD dwNoAuditing = 0;
  642. DWORD dwTemp = 0;
  643. ULONG ulReturned = 0;
  644. IWbemClassObject *pClass = NULL;
  645. IEnumWbemClassObject *pEnumClass = NULL;
  646. TCHAR szTemp[ MAX_STRING_LENGTH ];
  647. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  648. CHString strTemp;
  649. try
  650. {
  651. if( pNameSpace == NULL )
  652. {
  653. _com_issue_error( STG_E_UNKNOWN );
  654. }
  655. ZeroMemory( szTemp, sizeof( szTemp ) );
  656. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  657. // Form the query string
  658. if( bSuperVerbose == TRUE )
  659. {
  660. // ennumerate all the classes
  661. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  662. FORMAT_STRING( szQueryString, szTemp, CLS_AUDIT_POLICY );
  663. }
  664. else
  665. {
  666. // ennumerate all the classes with precedance = 1
  667. lstrcpy( szTemp, QUERY_VERBOSE );
  668. FORMAT_STRING( szQueryString, szTemp, CLS_AUDIT_POLICY );
  669. }
  670. // Get the pointer to ennumerate with
  671. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  672. _bstr_t( szQueryString ),
  673. WBEM_FLAG_FORWARD_ONLY |
  674. WBEM_FLAG_RETURN_IMMEDIATELY,
  675. NULL, &pEnumClass );
  676. CHECK_HRESULT( hResult );
  677. // Set the interface security
  678. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  679. CHECK_HRESULT( hResult );
  680. hResult = WBEM_S_NO_ERROR;
  681. while( WBEM_S_NO_ERROR == hResult )
  682. {
  683. // Get the next class
  684. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  685. CHECK_HRESULT( hResult );
  686. if( ulReturned == 0 )
  687. {
  688. // No more classes to enumerate
  689. // Display N/A if there were no classes
  690. if( bGotClass == FALSE )
  691. {
  692. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  693. ShowMessage( stdout, V_NOT_AVAILABLE );
  694. ShowMessage( stdout, NEW_LINE );
  695. }
  696. break;
  697. }
  698. bGotClass = TRUE;
  699. // Get the GPO id
  700. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  701. CHECK_BRESULT( bResult );
  702. // Get the GPO output
  703. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  704. ShowMessage( stdout, GetResString( IDS_GPO ) );
  705. GpoName( pNameSpace, szTemp, pAuthIdentity );
  706. // Get the category...
  707. bResult = PropertyGet( pClass, CPV_CATEGORY, strTemp, V_NOT_AVAILABLE );
  708. CHECK_BRESULT( bResult );
  709. ShowMessage( stdout, GetResString( IDS_POLICY ) );
  710. ShowMessage( stdout, strTemp );
  711. ShowMessage( stdout, GetResString( IDS_COMPUTER_SETTING ) );
  712. // Get the success property
  713. bResult = PropertyGet( pClass, CPV_SUCCESS, bTemp, FALSE );
  714. CHECK_BRESULT( bResult );
  715. if( bTemp == VAR_TRUE )
  716. {
  717. ShowMessage( stdout, CPV_SUCCESS );
  718. }
  719. else
  720. {
  721. dwNoAuditing++;
  722. }
  723. // Get the failure property
  724. bResult = PropertyGet( pClass, CPV_FAILURE, bTemp, FALSE );
  725. CHECK_BRESULT( bResult );
  726. if( bTemp == VAR_TRUE )
  727. {
  728. // Check if the success property is also set
  729. if ( dwNoAuditing == 0 )
  730. {
  731. ShowMessage( stdout, _T( ", " ) );
  732. }
  733. ShowMessage( stdout, CPV_FAILURE );
  734. }
  735. else
  736. {
  737. dwNoAuditing++;
  738. }
  739. if( dwNoAuditing == 2 )
  740. {
  741. ShowMessage( stdout, GetResString( IDS_NO_AUDITING ) );
  742. }
  743. dwNoAuditing = 0;
  744. ShowMessage( stdout, NEW_LINE );
  745. }// while
  746. }
  747. catch( _com_error & error )
  748. {
  749. WMISaveError( error.Error() );
  750. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  751. ShowMessage( stderr, GetReason() );
  752. }
  753. catch( CHeap_Exception )
  754. {
  755. SetLastError( E_OUTOFMEMORY );
  756. SaveLastError();
  757. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  758. ShowMessage( stderr, GetReason() );
  759. }
  760. // release the interface pointers
  761. SAFEIRELEASE(pEnumClass);
  762. SAFEIRELEASE(pClass);
  763. return;
  764. }
  765. /*********************************************************************************************
  766. Routine Description
  767. To get the User Rights Assignment policy for the output display-
  768. [Computer Configuration\Security Setting\Local Policies\User Rights Assignment]
  769. Arguments:
  770. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  771. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  772. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  773. info is to be displayed..
  774. Return Value:
  775. None
  776. *********************************************************************************************/
  777. VOID DisplayUserRights( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  778. BOOL bSuperVerbose )
  779. {
  780. HRESULT hResult = S_OK;
  781. BOOL bResult = FALSE;
  782. BOOL bGotClass = FALSE;
  783. ULONG ulReturned = 0;
  784. LONG lLBound = 0;
  785. LONG lUBound = 0;
  786. IWbemClassObject *pClass = NULL;
  787. IEnumWbemClassObject *pEnumClass = NULL;
  788. VARIANT vVarVerbose;
  789. VARTYPE vartype;
  790. TCHAR szTemp[ MAX_STRING_LENGTH ];
  791. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  792. CHString strTemp;
  793. SAFEARRAY *safeArray = NULL;
  794. try
  795. {
  796. if( pNameSpace == NULL )
  797. {
  798. _com_issue_error( STG_E_UNKNOWN );
  799. }
  800. ZeroMemory( szTemp, sizeof( szTemp ) );
  801. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  802. // Form the query string
  803. if( bSuperVerbose == TRUE )
  804. {
  805. // ennumerate all the classes
  806. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  807. FORMAT_STRING( szQueryString, szTemp, CLS_USER_RIGHTS );
  808. }
  809. else
  810. {
  811. // ennumerate all the classes with precedance = 1
  812. lstrcpy( szTemp, QUERY_VERBOSE );
  813. FORMAT_STRING( szQueryString, szTemp, CLS_USER_RIGHTS );
  814. }
  815. // Get the pointer to ennumerate with
  816. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  817. _bstr_t( szQueryString ),
  818. WBEM_FLAG_FORWARD_ONLY |
  819. WBEM_FLAG_RETURN_IMMEDIATELY,
  820. NULL, &pEnumClass );
  821. CHECK_HRESULT( hResult );
  822. // Set the interface security
  823. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  824. CHECK_HRESULT( hResult );
  825. hResult = WBEM_S_NO_ERROR;
  826. while( WBEM_S_NO_ERROR == hResult )
  827. {
  828. // Get the next class
  829. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  830. CHECK_HRESULT( hResult );
  831. if( ulReturned == 0 )
  832. {
  833. // No more classes to enumerate
  834. // Display N/A if there were no classes
  835. if( bGotClass == FALSE )
  836. {
  837. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  838. ShowMessage( stdout, V_NOT_AVAILABLE );
  839. ShowMessage( stdout, NEW_LINE );
  840. }
  841. break;
  842. }
  843. bGotClass = TRUE;
  844. // Get the GPO id
  845. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  846. CHECK_BRESULT( bResult );
  847. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  848. // Display the GPO name
  849. ShowMessage( stdout, GetResString( IDS_GPO ) );
  850. GpoName( pNameSpace, szTemp, pAuthIdentity );
  851. // Get the user rights
  852. VariantInit( &vVarVerbose );
  853. bResult = PropertyGet( pClass, CPV_USERRIGHT, strTemp, V_NOT_AVAILABLE );
  854. CHECK_BRESULT( bResult );
  855. strTemp = strTemp.Mid( ( strTemp.Find( EXTRA ) + 1 ), strTemp.GetLength() );
  856. ShowMessage( stdout, GetResString( IDS_POLICY ) );
  857. ShowMessage( stdout, strTemp );
  858. // Get the computer setting
  859. ShowMessage( stdout, GetResString( IDS_COMPUTER_SETTING ) );
  860. hResult = pClass->Get( _bstr_t( CPV_ACCOUNTLIST ), 0, &vVarVerbose, 0, 0 );
  861. CHECK_HRESULT_VAR( hResult, vVarVerbose );
  862. if( vVarVerbose.vt != VT_NULL && vVarVerbose.vt != VT_EMPTY )
  863. {
  864. // get the type of the elements in the safe array
  865. vartype = V_VT( &vVarVerbose ) & ~VT_ARRAY;
  866. //get the array of strings in to the safe array from the variant
  867. safeArray = (SAFEARRAY *)vVarVerbose.parray;
  868. //get the number of elements (subkeys)
  869. if( safeArray != NULL )
  870. {
  871. hResult = SafeArrayGetLBound( safeArray, 1, &lLBound );
  872. CHECK_HRESULT( hResult );
  873. hResult = SafeArrayGetUBound( safeArray, 1, &lUBound );
  874. CHECK_HRESULT( hResult );
  875. }
  876. for( ; lLBound <= lUBound; lLBound++ )
  877. {
  878. // Get the element from the safe array
  879. bResult = GetPropertyFromSafeArray( safeArray, lLBound, strTemp, vartype );
  880. CHECK_BRESULT( bResult );
  881. if( strTemp.GetLength() == 0 )
  882. {
  883. ShowMessage( stdout, V_NOT_AVAILABLE );
  884. }
  885. else
  886. {
  887. ShowMessage( stdout, strTemp );
  888. }
  889. ShowMessage( stdout, GetResString( IDS_NEWLINE1 ) );
  890. }
  891. }
  892. else
  893. {
  894. ShowMessage( stdout, V_NOT_AVAILABLE );
  895. ShowMessage( stdout, NEW_LINE );
  896. }
  897. VariantClear(&vVarVerbose);
  898. }
  899. }
  900. catch( _com_error & error )
  901. {
  902. WMISaveError( error.Error() );
  903. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  904. ShowMessage( stderr, GetReason() );
  905. VariantClear(&vVarVerbose);
  906. }
  907. catch( CHeap_Exception )
  908. {
  909. SetLastError( E_OUTOFMEMORY );
  910. SaveLastError();
  911. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  912. ShowMessage( stderr, GetReason() );
  913. VariantClear(&vVarVerbose);
  914. }
  915. // release the interface pointers
  916. SAFEIRELEASE(pEnumClass);
  917. SAFEIRELEASE(pClass);
  918. return;
  919. }
  920. /*********************************************************************************************
  921. Routine Description
  922. To get the GPO name from the GPOID in the instance of any RSOP class
  923. Arguments:
  924. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  925. [in] LPTSTR lpszGpoid : GPO id.
  926. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  927. Return Value:
  928. None
  929. *********************************************************************************************/
  930. VOID GpoName(IWbemServices *pNameSpace, LPTSTR lpszGpoId,
  931. COAUTHIDENTITY *pAuthIdentity)
  932. {
  933. HRESULT hResult = S_OK;
  934. BOOL bResult = FALSE;
  935. IWbemClassObject *pClass = NULL;
  936. IEnumWbemClassObject *pEnumClass = NULL;
  937. ULONG ulReturned = 0;
  938. TCHAR szQuery[ MAX_STRING_LENGTH ];
  939. CHString strTemp;
  940. try
  941. {
  942. ZeroMemory( szQuery, sizeof( szQuery ) );
  943. // Form the query string
  944. wsprintf( szQuery, QUERY_GPO_NAME, lpszGpoId );
  945. // Eexecute the query to get the corressponding Gpo Name.
  946. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  947. _bstr_t( szQuery ),
  948. WBEM_FLAG_FORWARD_ONLY |
  949. WBEM_FLAG_RETURN_IMMEDIATELY,
  950. NULL, &pEnumClass);
  951. CHECK_HRESULT( hResult );
  952. // Set the interface security
  953. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  954. CHECK_HRESULT( hResult );
  955. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  956. CHECK_HRESULT( hResult );
  957. if( ulReturned == 0 )
  958. {
  959. // Did not get the data we were looking for...
  960. // Display N/A if there were no classes
  961. ShowMessage( stdout, V_NOT_AVAILABLE );
  962. // Release the interface pointers
  963. SAFEIRELEASE(pEnumClass);
  964. SAFEIRELEASE(pClass);
  965. return;
  966. }
  967. // Found the GPO.....get the name
  968. bResult = PropertyGet( pClass, CPV_GPO_NAME, strTemp, V_NOT_AVAILABLE );
  969. CHECK_BRESULT( bResult );
  970. ShowMessage( stdout, strTemp );
  971. }
  972. catch( _com_error & error )
  973. {
  974. WMISaveError( error.Error() );
  975. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  976. ShowMessage( stderr, GetReason() );
  977. }
  978. // Release the interface pointers
  979. SAFEIRELEASE(pEnumClass);
  980. SAFEIRELEASE(pClass);
  981. return;
  982. }
  983. /*********************************************************************************************
  984. Routine Description
  985. This function displays the Security Options or Eventlog instances for the
  986. computer configuration.
  987. Arguments:
  988. [in] pNamespace : pointer to IWbemServices.
  989. [in] pszClassName : classname to retrieve data from.
  990. [in] pAuthIdentity : pointer to the Authorization structure
  991. [in] BOOL : set to TRUE if the super verbose info is to be displayed
  992. Return Value:
  993. None
  994. *********************************************************************************************/
  995. VOID DisplaySecurityandEvents( IWbemServices *pNameSpace, BSTR pszClassName,
  996. COAUTHIDENTITY *pAuthIdentity, BOOL bSuperVerbose )
  997. {
  998. HRESULT hResult = S_OK;
  999. BOOL bResult = FALSE;
  1000. BOOL bGotClass = FALSE;
  1001. ULONG ulReturned = 0;
  1002. DWORD dwTemp = 0;
  1003. IWbemClassObject *pClass = NULL;
  1004. IEnumWbemClassObject *pEnumClass = NULL;
  1005. TCHAR szTemp[ MAX_STRING_LENGTH ];
  1006. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  1007. CHString strTemp;
  1008. try
  1009. {
  1010. if( pNameSpace == NULL )
  1011. {
  1012. _com_issue_error( STG_E_UNKNOWN );
  1013. }
  1014. ZeroMemory( szTemp, sizeof( szTemp ) );
  1015. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  1016. // Form the query string
  1017. if( bSuperVerbose == TRUE )
  1018. {
  1019. // ennumerate all the classes
  1020. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  1021. FORMAT_STRING( szQueryString, szTemp, pszClassName );
  1022. }
  1023. else
  1024. {
  1025. // ennumerate all the classes with precedance = 1
  1026. lstrcpy( szTemp, QUERY_VERBOSE );
  1027. FORMAT_STRING( szQueryString, szTemp, pszClassName );
  1028. }
  1029. // Get the pointer to ennumerate with
  1030. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  1031. _bstr_t( szQueryString ),
  1032. WBEM_FLAG_FORWARD_ONLY |
  1033. WBEM_FLAG_RETURN_IMMEDIATELY,
  1034. NULL, &pEnumClass );
  1035. CHECK_HRESULT( hResult );
  1036. // Set the interface security
  1037. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  1038. CHECK_HRESULT( hResult );
  1039. hResult = WBEM_S_NO_ERROR;
  1040. while( WBEM_S_NO_ERROR == hResult )
  1041. {
  1042. // Get the next class
  1043. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  1044. CHECK_HRESULT( hResult );
  1045. if( ulReturned == 0 )
  1046. {
  1047. // No more classes to enumerate
  1048. // Display N/A if there were no classes
  1049. if( bGotClass == FALSE )
  1050. {
  1051. // Check if this is the Security string class or the eventlog boolean class
  1052. // so that we can avoid multiple N/A's.
  1053. if( ( lstrcmp( pszClassName, CLS_EVENTLOG_BOOLEAN ) != 0 )
  1054. && ( lstrcmp( pszClassName, CLS_SECURITY_STRING ) != 0 ) )
  1055. {
  1056. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  1057. ShowMessage( stdout, V_NOT_AVAILABLE );
  1058. ShowMessage( stdout, NEW_LINE );
  1059. }
  1060. }
  1061. break;
  1062. }
  1063. bGotClass = TRUE;
  1064. // Get the GPO id
  1065. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  1066. CHECK_BRESULT( bResult );
  1067. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  1068. ShowMessage( stdout, GetResString( IDS_GPO ) );
  1069. GpoName( pNameSpace, szTemp, pAuthIdentity );
  1070. // Get the key name
  1071. bResult = PropertyGet( pClass, CPV_KEYNAME1, strTemp, V_NOT_AVAILABLE );
  1072. CHECK_BRESULT( bResult );
  1073. ShowMessage(stdout, GetResString( IDS_POLICY ) );
  1074. ShowMessage( stdout, strTemp );
  1075. // Get the setting
  1076. if( lstrcmp( pszClassName, CLS_SECURITY_STRING ) == 0 )
  1077. {
  1078. bResult = PropertyGet( pClass, CPV_SETTING1, strTemp, V_NOT_AVAILABLE );
  1079. }
  1080. else
  1081. {
  1082. bResult = PropertyGet( pClass, CPV_SETTING1, dwTemp, 0 );
  1083. }
  1084. CHECK_BRESULT( bResult );
  1085. ShowMessage( stdout, GetResString( IDS_COMPUTER_SETTING ) );
  1086. if( lstrcmp( pszClassName, CLS_EVENTLOG_NUMERIC ) == 0 )
  1087. {
  1088. wsprintf( szTemp, _T( "%u" ), dwTemp );
  1089. ShowMessage( stdout, szTemp );
  1090. }
  1091. else if( lstrcmp( pszClassName, CLS_SECURITY_STRING ) == 0 )
  1092. {
  1093. if( strTemp.Compare( V_NOT_AVAILABLE ) != 0 )
  1094. {
  1095. ShowMessage( stdout, GetResString( IDS_ENABLED ) );
  1096. }
  1097. else
  1098. {
  1099. ShowMessage( stdout, GetResString( IDS_NOT_ENABLED ) );
  1100. }
  1101. }
  1102. else
  1103. {
  1104. if( dwTemp == VAR_TRUE )
  1105. {
  1106. ShowMessage( stdout, GetResString( IDS_ENABLED ) );
  1107. }
  1108. else
  1109. {
  1110. ShowMessage( stdout, GetResString( IDS_NOT_ENABLED ) );
  1111. }
  1112. }
  1113. // Get the log name
  1114. if( ( lstrcmp( pszClassName, CLS_SECURITY_BOOLEAN ) != 0 )
  1115. && ( lstrcmp( pszClassName, CLS_SECURITY_STRING ) != 0 ) )
  1116. {
  1117. bResult = PropertyGet( pClass, CPV_TYPE, dwTemp, 5 );
  1118. CHECK_BRESULT( bResult );
  1119. ShowMessage( stdout, GetResString( IDS_LOG_NAME ) );
  1120. switch( dwTemp )
  1121. {
  1122. case 0: ShowMessage( stdout, GetResString( IDS_SYSTEM ) );
  1123. break;
  1124. case 1: ShowMessage( stdout, GetResString( IDS_SECURITY ) );
  1125. break;
  1126. case 2: ShowMessage( stdout, GetResString( IDS_APP_LOG ) );
  1127. break;
  1128. default: ShowMessage( stdout, V_NOT_AVAILABLE );
  1129. break;
  1130. }
  1131. }
  1132. ShowMessage( stdout, NEW_LINE );
  1133. }// while
  1134. }
  1135. catch( _com_error & error )
  1136. {
  1137. WMISaveError( error.Error() );
  1138. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  1139. ShowMessage( stderr, GetReason() );
  1140. }
  1141. // Release the interface pointers
  1142. SAFEIRELEASE( pEnumClass );
  1143. SAFEIRELEASE( pClass );
  1144. return;
  1145. }
  1146. /*********************************************************************************************
  1147. Routine Description
  1148. Function to display the Restricted Groups policy for computer configuration
  1149. Arguments:
  1150. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  1151. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure.
  1152. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  1153. info is to be displayed.
  1154. Return Value:
  1155. None
  1156. *********************************************************************************************/
  1157. VOID DisplayRestrictedGroups( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  1158. BOOL bSuperVerbose )
  1159. {
  1160. HRESULT hResult = S_OK;
  1161. BOOL bResult = FALSE;
  1162. BOOL bGotClass = FALSE;
  1163. ULONG ulTemp = 0;
  1164. DWORD dwTemp = 0;
  1165. ULONG ulReturned = 0;
  1166. LONG lLBound = 0;
  1167. LONG lUBound = 0;
  1168. IWbemClassObject *pClass = NULL;
  1169. IEnumWbemClassObject *pEnumClass = NULL;
  1170. VARIANT vVarVerbose;
  1171. VARTYPE vartype;
  1172. TCHAR szTemp[ MAX_STRING_LENGTH ];
  1173. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  1174. CHString strTemp;
  1175. SAFEARRAY *safeArray = NULL;
  1176. try
  1177. {
  1178. if( pNameSpace == NULL )
  1179. {
  1180. _com_issue_error( STG_E_UNKNOWN );
  1181. }
  1182. ZeroMemory( szTemp, sizeof( szTemp ) );
  1183. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  1184. // Form the query string
  1185. if( bSuperVerbose == TRUE )
  1186. {
  1187. // ennumerate all the classes
  1188. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  1189. FORMAT_STRING( szQueryString, szTemp, CLS_RESTRICTED_GROUPS );
  1190. }
  1191. else
  1192. {
  1193. // ennumerate all the classes with precedance = 1
  1194. lstrcpy( szTemp, QUERY_VERBOSE );
  1195. FORMAT_STRING( szQueryString, szTemp, CLS_RESTRICTED_GROUPS );
  1196. }
  1197. // Get the pointer to ennumerate with
  1198. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  1199. _bstr_t( szQueryString ),
  1200. WBEM_FLAG_FORWARD_ONLY |
  1201. WBEM_FLAG_RETURN_IMMEDIATELY,
  1202. NULL, &pEnumClass );
  1203. CHECK_HRESULT( hResult );
  1204. // set the interface security
  1205. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  1206. CHECK_HRESULT( hResult );
  1207. hResult = WBEM_S_NO_ERROR;
  1208. while( WBEM_S_NO_ERROR == hResult )
  1209. {
  1210. // Get the next instance
  1211. hResult = pEnumClass->Next( WBEM_INFINITE, 1, &pClass, &ulReturned );
  1212. CHECK_HRESULT( hResult );
  1213. if( ulReturned == 0 )
  1214. {
  1215. // No more instances to enumerate
  1216. // Display N/A if there were no classes
  1217. if( bGotClass == FALSE )
  1218. {
  1219. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  1220. ShowMessage( stdout, V_NOT_AVAILABLE );
  1221. ShowMessage( stdout, NEW_LINE );
  1222. }
  1223. break;
  1224. }
  1225. bGotClass = TRUE;
  1226. // Get the GPO id
  1227. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  1228. CHECK_BRESULT( bResult );
  1229. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  1230. ShowMessage( stdout, GetResString( IDS_GPO ) );
  1231. GpoName( pNameSpace, szTemp, pAuthIdentity );
  1232. // Get the group name
  1233. bResult = PropertyGet( pClass, CPV_GROUP, strTemp, V_NOT_AVAILABLE );
  1234. CHECK_BRESULT( bResult );
  1235. ShowMessage( stdout, GetResString( IDS_GROUPNAME ) );
  1236. ShowMessage( stdout, strTemp );
  1237. // Get the members of the group
  1238. VariantInit( &vVarVerbose );
  1239. ShowMessage( stdout, GetResString( IDS_MEMBERS ) );
  1240. hResult = pClass->Get( _bstr_t( CPV_MEMBERS ), 0, &vVarVerbose, 0, 0 );
  1241. CHECK_HRESULT_VAR( hResult, vVarVerbose );
  1242. if( vVarVerbose.vt != VT_NULL && vVarVerbose.vt != VT_EMPTY )
  1243. {
  1244. // get the type of the elements in the safe array
  1245. vartype = V_VT( &vVarVerbose ) & ~VT_ARRAY;
  1246. //get the array of strings in to the safe array from the variant
  1247. safeArray = ( SAFEARRAY * )vVarVerbose.parray;
  1248. //get the number of elements (subkeys)
  1249. if( safeArray != NULL )
  1250. {
  1251. hResult = SafeArrayGetLBound( safeArray, 1, &lLBound );
  1252. CHECK_HRESULT( hResult );
  1253. hResult = SafeArrayGetUBound( safeArray, 1, &lUBound );
  1254. CHECK_HRESULT( hResult );
  1255. }
  1256. for( ; lLBound <= lUBound; lLBound++ )
  1257. {
  1258. // Get the element from the safe array
  1259. bResult = GetPropertyFromSafeArray( safeArray, lLBound, strTemp, vartype );
  1260. CHECK_BRESULT( bResult );
  1261. if( strTemp.GetLength() == 0 )
  1262. {
  1263. ShowMessage( stdout, V_NOT_AVAILABLE );
  1264. }
  1265. else
  1266. {
  1267. ShowMessage( stdout, strTemp );
  1268. }
  1269. ShowMessage( stdout, GetResString( IDS_NEWLINE2 ) );
  1270. }
  1271. }
  1272. else
  1273. {
  1274. ShowMessage( stdout, V_NOT_AVAILABLE );
  1275. }
  1276. VariantClear( &vVarVerbose );
  1277. }// while
  1278. }
  1279. catch( _com_error & error )
  1280. {
  1281. WMISaveError( error.Error() );
  1282. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  1283. ShowMessage( stderr, GetReason() );
  1284. VariantClear( &vVarVerbose );
  1285. }
  1286. // Release the interface pointers
  1287. SAFEIRELEASE( pEnumClass );
  1288. SAFEIRELEASE( pClass );
  1289. return;
  1290. }
  1291. /*********************************************************************************************
  1292. Routine Description
  1293. This function displays the System Services policy for the computer configuration
  1294. Arguments:
  1295. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  1296. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure.
  1297. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  1298. info is to be displayed.
  1299. Return Value:
  1300. None
  1301. *********************************************************************************************/
  1302. VOID DisplaySystemServices( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  1303. BOOL bSuperVerbose )
  1304. {
  1305. HRESULT hResult = S_OK;
  1306. BOOL bResult = FALSE;
  1307. BOOL bGotClass = FALSE;
  1308. DWORD dwTemp = 0;
  1309. ULONG ulReturned = 0;
  1310. IWbemClassObject *pClass = NULL;
  1311. IEnumWbemClassObject *pEnumClass = NULL;
  1312. TCHAR szTemp[ MAX_STRING_LENGTH ];
  1313. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  1314. CHString strTemp;
  1315. try
  1316. {
  1317. if( pNameSpace == NULL )
  1318. {
  1319. _com_issue_error( STG_E_UNKNOWN );
  1320. }
  1321. ZeroMemory( szTemp, sizeof( szTemp ) );
  1322. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  1323. // Form the query string
  1324. if( bSuperVerbose == TRUE )
  1325. {
  1326. // ennumerate all the classes
  1327. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  1328. FORMAT_STRING( szQueryString, szTemp, CLS_SYSTEM_SERVICES );
  1329. }
  1330. else
  1331. {
  1332. // ennumerate all the classes with precedance = 1
  1333. lstrcpy( szTemp, QUERY_VERBOSE );
  1334. FORMAT_STRING( szQueryString, szTemp, CLS_SYSTEM_SERVICES );
  1335. }
  1336. // Get the pointer to ennumerate with
  1337. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  1338. _bstr_t( szQueryString ),
  1339. WBEM_FLAG_FORWARD_ONLY |
  1340. WBEM_FLAG_RETURN_IMMEDIATELY,
  1341. NULL, &pEnumClass );
  1342. CHECK_HRESULT( hResult );
  1343. // Set the interface security
  1344. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  1345. CHECK_HRESULT( hResult );
  1346. hResult = WBEM_S_NO_ERROR;
  1347. while( WBEM_S_NO_ERROR == hResult )
  1348. {
  1349. // Get the next instance
  1350. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  1351. CHECK_HRESULT( hResult );
  1352. if( ulReturned == 0 )
  1353. {
  1354. // No more classes to enumerate
  1355. // Display N/A if there were no classes
  1356. if( bGotClass == FALSE )
  1357. {
  1358. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  1359. ShowMessage( stdout, V_NOT_AVAILABLE );
  1360. ShowMessage( stdout, NEW_LINE );
  1361. }
  1362. break;
  1363. }
  1364. bGotClass = TRUE;
  1365. // Get the GPO id
  1366. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  1367. CHECK_BRESULT( bResult );
  1368. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  1369. ShowMessage( stdout, GetResString( IDS_GPO ) );
  1370. GpoName( pNameSpace, szTemp, pAuthIdentity );
  1371. // Get the service information
  1372. bResult = PropertyGet( pClass, CPV_SERVICE, strTemp, V_NOT_AVAILABLE );
  1373. CHECK_BRESULT( bResult );
  1374. ShowMessage(stdout, GetResString( IDS_SERVICENAME ) );
  1375. ShowMessage( stdout, strTemp );
  1376. ShowMessage(stdout, GetResString( IDS_STARTUP ) );
  1377. bResult = PropertyGet( pClass, CPV_STARTUP, dwTemp, 0 );
  1378. CHECK_BRESULT( bResult );
  1379. switch( dwTemp )
  1380. {
  1381. case 2: ShowMessage( stdout, GetResString( IDS_AUTOMATIC ) );
  1382. break;
  1383. case 3: ShowMessage( stdout, GetResString( IDS_MANUAL ) );
  1384. break;
  1385. case 4: ShowMessage( stdout, GetResString( IDS_DISABLED ) );
  1386. break;
  1387. default: ShowMessage( stdout, V_NOT_AVAILABLE );
  1388. break;
  1389. }
  1390. ShowMessage( stdout, NEW_LINE );
  1391. }// while
  1392. }
  1393. catch( _com_error & error )
  1394. {
  1395. WMISaveError( error.Error() );
  1396. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  1397. ShowMessage( stderr, GetReason() );
  1398. }
  1399. // Release the interface pointers
  1400. SAFEIRELEASE( pEnumClass );
  1401. SAFEIRELEASE( pClass );
  1402. return;
  1403. }
  1404. /*********************************************************************************************
  1405. Routine Description
  1406. This function displays the Registry policy or File System policy for the
  1407. computer configuration.
  1408. Arguments:
  1409. [in] pNamespace : pointer to IWbemServices.
  1410. [in] pszClassName : classname to retrieve data from.
  1411. [in] pAuthIdentity : pointer to the Authorization structure
  1412. [in] BOOL : set to TRUE if the super verbose info is to be displayed
  1413. Return Value:
  1414. None
  1415. *********************************************************************************************/
  1416. VOID DisplayRegistryandFileInfo( IWbemServices *pNameSpace, BSTR pszClassName,
  1417. COAUTHIDENTITY *pAuthIdentity, BOOL bSuperVerbose )
  1418. {
  1419. HRESULT hResult = S_OK;
  1420. BOOL bResult = FALSE;
  1421. BOOL bGotClass = FALSE;
  1422. DWORD dwTemp = 0;
  1423. ULONG ulReturned = 0;
  1424. IWbemClassObject *pClass = NULL;
  1425. IEnumWbemClassObject *pEnumClass = NULL;
  1426. TCHAR szTemp[ MAX_STRING_LENGTH ];
  1427. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  1428. CHString strTemp;
  1429. try
  1430. {
  1431. if( pNameSpace == NULL )
  1432. {
  1433. _com_issue_error( STG_E_UNKNOWN );
  1434. }
  1435. ZeroMemory( szTemp, sizeof( szTemp ) );
  1436. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  1437. // Form the query string
  1438. if( bSuperVerbose == TRUE )
  1439. {
  1440. // ennumerate all the classes
  1441. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  1442. FORMAT_STRING( szQueryString, szTemp, pszClassName );
  1443. }
  1444. else
  1445. {
  1446. // ennumerate all the classes with precedance = 1
  1447. lstrcpy( szTemp, QUERY_VERBOSE );
  1448. FORMAT_STRING( szQueryString, szTemp, pszClassName );
  1449. }
  1450. // Get the pointer to ennumerate with
  1451. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  1452. _bstr_t( szQueryString ),
  1453. WBEM_FLAG_FORWARD_ONLY |
  1454. WBEM_FLAG_RETURN_IMMEDIATELY,
  1455. NULL, &pEnumClass );
  1456. CHECK_HRESULT( hResult );
  1457. // Set the interface security
  1458. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  1459. CHECK_HRESULT( hResult );
  1460. hResult = WBEM_S_NO_ERROR;
  1461. while( WBEM_S_NO_ERROR == hResult )
  1462. {
  1463. // Get the next instance
  1464. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  1465. CHECK_HRESULT( hResult );
  1466. if(ulReturned == 0)
  1467. {
  1468. // No more classes to enumerate
  1469. // Display N/A if there were no classes
  1470. if( bGotClass == FALSE )
  1471. {
  1472. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  1473. ShowMessage( stdout, V_NOT_AVAILABLE );
  1474. ShowMessage( stdout, NEW_LINE );
  1475. }
  1476. break;
  1477. }
  1478. bGotClass = TRUE;
  1479. // Get the GPO id
  1480. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  1481. CHECK_BRESULT( bResult );
  1482. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  1483. ShowMessage( stdout, GetResString( IDS_GPO ) );
  1484. GpoName( pNameSpace, szTemp, pAuthIdentity );
  1485. // Get the name
  1486. bResult = PropertyGet( pClass, CPV_REG_FS, strTemp, V_NOT_AVAILABLE );
  1487. CHECK_BRESULT( bResult );
  1488. ShowMessage( stdout, GetResString( IDS_OBJECTNAME ) );
  1489. ShowMessage( stdout, strTemp );
  1490. ShowMessage( stdout, NEW_LINE );
  1491. }// while
  1492. }
  1493. catch( _com_error & error )
  1494. {
  1495. WMISaveError( error.Error() );
  1496. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  1497. ShowMessage( stderr, GetReason() );
  1498. }
  1499. catch( CHeap_Exception )
  1500. {
  1501. SetLastError( E_OUTOFMEMORY );
  1502. SaveLastError();
  1503. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  1504. ShowMessage( stderr, GetReason() );
  1505. }
  1506. // Release the interface pointers
  1507. SAFEIRELEASE( pEnumClass );
  1508. SAFEIRELEASE( pClass );
  1509. return;
  1510. }
  1511. /*********************************************************************************************
  1512. Routine Description
  1513. This function displays the Administrative Templates policy for the user and
  1514. computer configurations.
  1515. Arguments:
  1516. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  1517. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure.
  1518. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  1519. info is to be displayed.
  1520. Return Value:
  1521. None
  1522. *********************************************************************************************/
  1523. VOID DisplayTemplates( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  1524. BOOL bSuperVerbose )
  1525. {
  1526. HRESULT hResult = S_OK;
  1527. BOOL bResult = FALSE;
  1528. BOOL bGotClass = FALSE;
  1529. BOOL bTemp = FALSE;
  1530. ULONG ulReturned = 0;
  1531. DWORD dwTemp = 0;
  1532. IWbemClassObject *pClass = NULL;
  1533. IEnumWbemClassObject *pEnumClass = NULL;
  1534. TCHAR szTemp[ MAX_STRING_LENGTH ];
  1535. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  1536. CHString strTemp;
  1537. try
  1538. {
  1539. if( pNameSpace == NULL )
  1540. {
  1541. _com_issue_error( STG_E_UNKNOWN );
  1542. }
  1543. ZeroMemory( szTemp, sizeof( szTemp ) );
  1544. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  1545. // Form the query string
  1546. if( bSuperVerbose == TRUE )
  1547. {
  1548. // ennumerate all the classes
  1549. lstrcpy( szTemp, QUERY_ADMIN_TEMP );
  1550. FORMAT_STRING( szQueryString, szTemp, CLS_ADMIN );
  1551. }
  1552. else
  1553. {
  1554. // ennumerate all the classes with precedance = 1
  1555. lstrcpy( szTemp, QUERY_ADMIN_TEMP );
  1556. FORMAT_STRING( szQueryString, szTemp, CLS_ADMIN );
  1557. lstrcat( szQueryString, QUERY_ADD_VERBOSE );
  1558. }
  1559. // Get the pointer to ennumerate with
  1560. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  1561. _bstr_t( szQueryString ),
  1562. WBEM_FLAG_FORWARD_ONLY |
  1563. WBEM_FLAG_RETURN_IMMEDIATELY,
  1564. NULL, &pEnumClass );
  1565. CHECK_HRESULT( hResult );
  1566. // Set the interface security
  1567. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  1568. CHECK_HRESULT( hResult );
  1569. hResult = WBEM_S_NO_ERROR;
  1570. while(WBEM_S_NO_ERROR == hResult)
  1571. {
  1572. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  1573. CHECK_HRESULT( hResult );
  1574. if(ulReturned == 0)
  1575. {
  1576. // No more classes to enumerate
  1577. // Display N/A if there were no classes
  1578. if( bGotClass == FALSE )
  1579. {
  1580. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  1581. ShowMessage( stdout, V_NOT_AVAILABLE );
  1582. ShowMessage( stdout, NEW_LINE );
  1583. }
  1584. break;
  1585. }
  1586. bGotClass = TRUE;
  1587. // Get the GPO id
  1588. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  1589. CHECK_BRESULT( bResult );
  1590. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  1591. ShowMessage( stdout, GetResString( IDS_GPO ) );
  1592. GpoName( pNameSpace, szTemp, pAuthIdentity );
  1593. // Get the registry value (string)
  1594. bResult = PropertyGet( pClass, CPV_REGISTRY, strTemp, V_NOT_AVAILABLE );
  1595. CHECK_BRESULT( bResult );
  1596. ShowMessage( stdout, GetResString( IDS_FR_SETTING ) );
  1597. ShowMessage( stdout, strTemp );
  1598. // Get the state (Enabled/Disabled)
  1599. ShowMessage( stdout, GetResString( IDS_STATE ) );
  1600. bResult = PropertyGet( pClass, CPV_DELETED, bTemp, FALSE );
  1601. CHECK_BRESULT( bResult );
  1602. if( bTemp == VAR_TRUE )
  1603. {
  1604. // The deleted flag is set to TRUE for all the disabled templates
  1605. ShowMessage( stdout, GetResString( IDS_DISABLED ) );
  1606. ShowMessage( stdout, GetResString( IDS_NEWLINE ) );
  1607. }
  1608. else
  1609. {
  1610. ShowMessage( stdout, GetResString( IDS_ENABLED ) );
  1611. ShowMessage( stdout, GetResString( IDS_NEWLINE ) );
  1612. }
  1613. }// while
  1614. }
  1615. catch( _com_error & error )
  1616. {
  1617. WMISaveError( error.Error() );
  1618. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  1619. ShowMessage( stderr, GetReason() );
  1620. }
  1621. // Release the interface pointers
  1622. SAFEIRELEASE( pEnumClass );
  1623. SAFEIRELEASE( pClass );
  1624. return;
  1625. }
  1626. /*********************************************************************************************
  1627. Routine Description
  1628. This function displays the Folder Redirection settings for the user configuration.
  1629. Arguments:
  1630. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  1631. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  1632. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  1633. info is to be displayed.
  1634. Return Value:
  1635. None
  1636. *********************************************************************************************/
  1637. VOID DisplayFolderRedirection( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  1638. BOOL bSuperVerbose )
  1639. {
  1640. HRESULT hResult = S_OK;
  1641. BOOL bResult = FALSE;
  1642. BOOL bGotClass = FALSE;
  1643. BOOL bTemp = FALSE;
  1644. DWORD dwTemp = 0;
  1645. ULONG ulReturned = 0;
  1646. LONG lLBound = 0;
  1647. LONG lUBound = 0;
  1648. IWbemClassObject *pClass = NULL;
  1649. IEnumWbemClassObject *pEnumClass = NULL;
  1650. VARIANT vVarVerbose;
  1651. VARTYPE vartype;
  1652. TCHAR szTemp[ MAX_STRING_LENGTH ];
  1653. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  1654. CHString strTemp;
  1655. SAFEARRAY *safeArray = NULL;
  1656. try
  1657. {
  1658. if( pNameSpace == NULL )
  1659. {
  1660. _com_issue_error( STG_E_UNKNOWN );
  1661. }
  1662. ZeroMemory( szTemp, sizeof( szTemp ) );
  1663. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  1664. // Form the query string
  1665. if( bSuperVerbose == TRUE )
  1666. {
  1667. // ennumerate all the classes
  1668. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  1669. FORMAT_STRING( szQueryString, szTemp, CLS_FOLDER_REDIRECTION );
  1670. }
  1671. else
  1672. {
  1673. // ennumerate all the classes with precedance = 1
  1674. lstrcpy( szTemp, QUERY_VERBOSE );
  1675. FORMAT_STRING( szQueryString, szTemp, CLS_FOLDER_REDIRECTION );
  1676. }
  1677. // Get the pointer to ennumerate with
  1678. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  1679. _bstr_t( szQueryString ),
  1680. WBEM_FLAG_FORWARD_ONLY |
  1681. WBEM_FLAG_RETURN_IMMEDIATELY,
  1682. NULL, &pEnumClass );
  1683. CHECK_HRESULT( hResult );
  1684. // Set the interface security
  1685. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  1686. CHECK_HRESULT( hResult );
  1687. hResult = WBEM_S_NO_ERROR;
  1688. while( WBEM_S_NO_ERROR == hResult )
  1689. {
  1690. // Get the next class
  1691. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  1692. CHECK_HRESULT( hResult );
  1693. if(ulReturned == 0)
  1694. {
  1695. // No more classes to enumerate
  1696. // Display N/A if there were no classes
  1697. if( bGotClass == FALSE )
  1698. {
  1699. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  1700. ShowMessage( stdout, V_NOT_AVAILABLE );
  1701. ShowMessage( stdout, NEW_LINE );
  1702. }
  1703. break;
  1704. }
  1705. bGotClass = TRUE;
  1706. // Get the GPO id
  1707. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  1708. CHECK_BRESULT( bResult );
  1709. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  1710. ShowMessage( stdout, GetResString( IDS_GPO ) );
  1711. GpoName( pNameSpace, szTemp, pAuthIdentity );
  1712. // Get the folder re-direction information
  1713. ShowMessage( stdout, GetResString( IDS_FR_SETTING ) );
  1714. // Get the installation type
  1715. ShowMessage( stdout, GetResString( IDS_INSTALLATIONTYPE ) );
  1716. bResult = PropertyGet( pClass, CPV_FRINSTYPE, dwTemp, 0 );
  1717. CHECK_BRESULT( bResult );
  1718. switch( dwTemp )
  1719. {
  1720. case 1: ShowMessage( stdout, GetResString( IDS_BASIC ) );
  1721. break;
  1722. case 2: ShowMessage( stdout, GetResString( IDS_MAXIMUM ) );
  1723. break;
  1724. default: ShowMessage( stdout, V_NOT_AVAILABLE );
  1725. break;
  1726. }
  1727. // Get the Grant Type
  1728. ShowMessage( stdout, GetResString( IDS_GRANTTYPE ) );
  1729. bResult = PropertyGet( pClass, CPV_FRGRANT, bTemp, FALSE );
  1730. CHECK_BRESULT( bResult );
  1731. if( bTemp == VAR_TRUE )
  1732. {
  1733. ShowMessage( stdout, GetResString( IDS_EXCLUSIVE ) );
  1734. }
  1735. else
  1736. {
  1737. ShowMessage( stdout, GetResString( IDS_NOTEXCLUSIVE ) );
  1738. }
  1739. // Get the Move type
  1740. ShowMessage( stdout, GetResString( IDS_MOVETYPE ) );
  1741. bResult = PropertyGet( pClass, CPV_FRMOVE, bTemp, FALSE );
  1742. CHECK_BRESULT( bResult );
  1743. if( bTemp == VAR_TRUE )
  1744. {
  1745. ShowMessage( stdout, GetResString( IDS_MOVED ) );
  1746. }
  1747. else
  1748. {
  1749. ShowMessage( stdout, GetResString( IDS_NOTMOVED ) );
  1750. }
  1751. // Get the removal policy
  1752. ShowMessage( stdout, GetResString( IDS_POLICYREMOVAL ) );
  1753. bResult = PropertyGet( pClass, CPV_FRREMOVAL, dwTemp, 0 );
  1754. CHECK_BRESULT( bResult );
  1755. switch( dwTemp )
  1756. {
  1757. case 1: ShowMessage( stdout, GetResString( IDS_LEAVEFOLDER ) );
  1758. break;
  1759. case 2: ShowMessage( stdout, GetResString( IDS_REDIRECT ) );
  1760. break;
  1761. default: ShowMessage( stdout, V_NOT_AVAILABLE );
  1762. break;
  1763. }
  1764. // Get the Redirecting group
  1765. bResult = PropertyGet( pClass, CPV_FRSECGROUP, strTemp, V_NOT_AVAILABLE );
  1766. CHECK_BRESULT( bResult );
  1767. ShowMessage( stdout, GetResString( IDS_REDIRECTINGGROUP ) );
  1768. // Compare the value got with the set of values and display the appropriate output
  1769. if( strTemp.Compare( SID_EVERYONE ) == 0 )
  1770. {
  1771. ShowMessage( stdout, GetResString( IDS_EVERYONE ) );
  1772. }
  1773. else if( strTemp.Compare( SID_NULL_SID ) == 0 )
  1774. {
  1775. ShowMessage( stdout, GetResString( IDS_NULL_SID ) );
  1776. }
  1777. else if( strTemp.Compare( SID_LOCAL ) == 0 )
  1778. {
  1779. ShowMessage( stdout, GetResString( IDS_LOCAL ) );
  1780. }
  1781. else if( strTemp.Compare( SID_CREATOR_OWNER ) == 0 )
  1782. {
  1783. ShowMessage( stdout, GetResString( IDS_CREATOR_OWNER ) );
  1784. }
  1785. else if( strTemp.Compare( SID_CREATOR_GROUP ) == 0 )
  1786. {
  1787. ShowMessage( stdout, GetResString( IDS_CREATOR_GROUP ) );
  1788. }
  1789. else
  1790. {
  1791. ShowMessage( stdout, V_NOT_AVAILABLE );
  1792. }
  1793. // Get the re-directed path
  1794. VariantInit( &vVarVerbose );
  1795. hResult = pClass->Get( _bstr_t( CPV_FRPATH ), 0, &vVarVerbose, 0, 0 );
  1796. CHECK_HRESULT_VAR( hResult, vVarVerbose );
  1797. ShowMessage( stdout, GetResString( IDS_REDIRECTEDPATH ) );
  1798. if( vVarVerbose.vt != VT_NULL && vVarVerbose.vt != VT_EMPTY )
  1799. {
  1800. // get the type of the elements in the safe array
  1801. vartype = V_VT( &vVarVerbose ) & ~VT_ARRAY;
  1802. //get the array of strings in to the safe array from the variant
  1803. safeArray = ( SAFEARRAY * )vVarVerbose.parray;
  1804. //get the number of elements (subkeys)
  1805. if( safeArray != NULL )
  1806. {
  1807. hResult = SafeArrayGetLBound( safeArray, 1, &lLBound );
  1808. CHECK_HRESULT( hResult );
  1809. hResult = SafeArrayGetUBound( safeArray, 1, &lUBound );
  1810. CHECK_HRESULT( hResult );
  1811. }
  1812. for( ; lLBound <= lUBound; lLBound++ )
  1813. {
  1814. // Get the element from the Safe Array
  1815. bResult = GetPropertyFromSafeArray( safeArray, lLBound, strTemp, vartype );
  1816. CHECK_BRESULT( bResult );
  1817. if( strTemp.GetLength() == 0)
  1818. {
  1819. ShowMessage( stdout, V_NOT_AVAILABLE );
  1820. }
  1821. else
  1822. {
  1823. ShowMessage( stdout, strTemp );
  1824. }
  1825. ShowMessage( stdout, GetResString( IDS_NEWLINE1 ) );
  1826. }
  1827. }
  1828. else
  1829. {
  1830. ShowMessage( stdout, V_NOT_AVAILABLE );
  1831. }
  1832. VariantClear( &vVarVerbose );
  1833. }// while
  1834. }
  1835. catch( _com_error & error )
  1836. {
  1837. WMISaveError( error.Error() );
  1838. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  1839. ShowMessage( stderr, GetReason() );
  1840. VariantClear( &vVarVerbose );
  1841. }
  1842. // Release the interface pointers
  1843. SAFEIRELEASE( pEnumClass );
  1844. SAFEIRELEASE( pClass );
  1845. return;
  1846. }
  1847. /*********************************************************************************************
  1848. Routine Description:
  1849. This function displays the verbose data for the scope - user
  1850. Arguments:
  1851. [in] IWbemServices *pRsopNameSpace : interface pointer
  1852. Return Value:
  1853. TRUE on SUCCESS
  1854. FALSE on FAILURE
  1855. *********************************************************************************************/
  1856. BOOL CGpResult::DisplayVerboseUserData( IWbemServices *pNameSpace )
  1857. {
  1858. DWORD dwLength = 0;
  1859. //
  1860. // Display the verbose information for the scope - user
  1861. // Display the header
  1862. ShowMessage( stdout, GetResString( IDS_USER_RESULT ) );
  1863. ShowMessage( stdout, GetResString( IDS_NEWLINE_TAB ) );
  1864. for( dwLength = lstrlen( GetResString( IDS_USER_RESULT ) ); dwLength > 4; dwLength-- )
  1865. {
  1866. ShowMessage( stdout, GetResString( IDS_DASH ) );
  1867. }
  1868. ShowMessage( stdout, NEW_LINE );
  1869. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1870. // Display the software installation data
  1871. ShowMessage( stdout, GetResString( IDS_SW_SETTINGS ) );
  1872. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1873. for( dwLength = lstrlen( GetResString( IDS_SW_SETTINGS ) ); dwLength > 0; dwLength-- )
  1874. {
  1875. ShowMessage( stdout, GetResString( IDS_DASH ) );
  1876. }
  1877. DisplaySoftwareInstallations( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  1878. // Display the public key policies
  1879. // Displaying N/A for time being
  1880. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1881. ShowMessage( stdout, GetResString( IDS_WS_SS_PKP ) );
  1882. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1883. for( dwLength = lstrlen( GetResString( IDS_WS_SS_PKP ) ); dwLength > 0; dwLength-- )
  1884. {
  1885. ShowMessage( stdout, GetResString( IDS_DASH ) );
  1886. }
  1887. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  1888. ShowMessage( stdout, V_NOT_AVAILABLE );
  1889. ShowMessage( stdout, NEW_LINE );
  1890. // Display the administrative template information
  1891. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1892. ShowMessage( stdout, GetResString( IDS_ADTS_ERS ) );
  1893. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1894. for( dwLength = lstrlen( GetResString( IDS_ADTS_ERS ) ); dwLength > 0; dwLength-- )
  1895. {
  1896. ShowMessage( stdout, GetResString( IDS_DASH ) );
  1897. }
  1898. DisplayTemplates( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  1899. // Display the File Re-direction information
  1900. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1901. ShowMessage( stdout, GetResString( IDS_USERFR ) );
  1902. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1903. for( dwLength = lstrlen( GetResString( IDS_USERFR ) ); dwLength > 0; dwLength-- )
  1904. {
  1905. ShowMessage( stdout, GetResString( IDS_DASH ) );
  1906. }
  1907. DisplayFolderRedirection( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  1908. // Display the group policy for IE
  1909. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1910. ShowMessage( stdout, GetResString( IDS_IEPOLICY ) );
  1911. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1912. for( dwLength = lstrlen( GetResString( IDS_IEPOLICY ) ); dwLength > 0; dwLength-- )
  1913. {
  1914. ShowMessage( stdout, GetResString( IDS_DASH ) );
  1915. }
  1916. DisplayIEPolicy( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  1917. // Display the connection information
  1918. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1919. ShowMessage( stdout, GetResString( IDS_PROXY ) );
  1920. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1921. for( dwLength = lstrlen( GetResString( IDS_PROXY ) ); dwLength > 0; dwLength-- )
  1922. {
  1923. ShowMessage( stdout, GetResString( IDS_DASH ) );
  1924. }
  1925. DisplayIEProxySetting( pNameSpace, m_pAuthIdentity );
  1926. // Display the IE Favorite Links or Items
  1927. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1928. ShowMessage( stdout, GetResString( IDS_FAVLINKORITEM ) );
  1929. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1930. for( dwLength = lstrlen( GetResString( IDS_FAVLINKORITEM ) ); dwLength > 0; dwLength-- )
  1931. {
  1932. ShowMessage( stdout, GetResString( IDS_DASH ) );
  1933. }
  1934. DisplayIEImpURLS( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  1935. DisplayIEFavorites( pNameSpace, m_pAuthIdentity );
  1936. // Display the security content ratings
  1937. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1938. ShowMessage( stdout, GetResString( IDS_IE_SECURITY ) );
  1939. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1940. for( dwLength = lstrlen( GetResString( IDS_IE_SECURITY ) ); dwLength > 0; dwLength-- )
  1941. {
  1942. ShowMessage( stdout, GetResString( IDS_DASH ) );
  1943. }
  1944. DisplayIESecurityContent( pNameSpace, m_pAuthIdentity );
  1945. DisplayIESecurity( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  1946. // Display the secutrity zone settings
  1947. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1948. ShowMessage( stdout, GetResString( IDS_IE_PROGRAMS ) );
  1949. ShowMessage( stdout, GetResString( IDS_NEWLINETAB ) );
  1950. for( dwLength = lstrlen( GetResString( IDS_IE_PROGRAMS ) ); dwLength > 0; dwLength-- )
  1951. {
  1952. ShowMessage( stdout, GetResString( IDS_DASH ) );
  1953. }
  1954. DisplayIEPrograms( pNameSpace, m_pAuthIdentity, m_bSuperVerbose );
  1955. return TRUE;
  1956. }
  1957. /*********************************************************************************************
  1958. Routine Description
  1959. This function displays the IE policy settings for the user configuration.
  1960. Arguments:
  1961. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  1962. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  1963. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  1964. info is to be displayed.
  1965. Return Value:
  1966. None
  1967. *********************************************************************************************/
  1968. VOID DisplayIEPolicy( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  1969. BOOL bSuperVerbose )
  1970. {
  1971. HRESULT hResult = S_OK;
  1972. BOOL bResult = FALSE;
  1973. BOOL bGotClass = FALSE;
  1974. BOOL bTemp = FALSE;
  1975. ULONG ulReturned = 0;
  1976. IWbemClassObject *pClass = NULL;
  1977. IEnumWbemClassObject *pEnumClass = NULL;
  1978. TCHAR szTemp[ MAX_STRING_LENGTH ];
  1979. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  1980. CHString strTemp;
  1981. try
  1982. {
  1983. if( pNameSpace == NULL )
  1984. {
  1985. _com_issue_error( STG_E_UNKNOWN );
  1986. }
  1987. ZeroMemory( szTemp, sizeof( szTemp ) );
  1988. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  1989. // Form the query string
  1990. if( bSuperVerbose == TRUE )
  1991. {
  1992. // ennumerate all the classes
  1993. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  1994. FORMAT_STRING( szQueryString, szTemp, CLS_IE_POLICY );
  1995. }
  1996. else
  1997. {
  1998. // ennumerate all the classes with precedance = 1
  1999. lstrcpy( szTemp, QUERY_VERBOSE );
  2000. FORMAT_STRING( szQueryString, szTemp, CLS_IE_POLICY );
  2001. }
  2002. // Get the pointer to ennumerate with
  2003. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  2004. _bstr_t( szQueryString ),
  2005. WBEM_FLAG_FORWARD_ONLY |
  2006. WBEM_FLAG_RETURN_IMMEDIATELY,
  2007. NULL, &pEnumClass );
  2008. CHECK_HRESULT( hResult );
  2009. // Set the interface security
  2010. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  2011. CHECK_HRESULT( hResult );
  2012. hResult = WBEM_S_NO_ERROR;
  2013. while( WBEM_S_NO_ERROR == hResult )
  2014. {
  2015. // get the next class
  2016. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  2017. CHECK_HRESULT( hResult );
  2018. if( ulReturned == 0 )
  2019. {
  2020. // No more classes to enumerate
  2021. // Display N/A if there were no classes
  2022. if( bGotClass == FALSE )
  2023. {
  2024. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  2025. ShowMessage( stdout, V_NOT_AVAILABLE );
  2026. ShowMessage( stdout, NEW_LINE );
  2027. }
  2028. break;
  2029. }
  2030. bGotClass = TRUE;
  2031. // Get the GPO id
  2032. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  2033. CHECK_BRESULT( bResult );
  2034. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  2035. ShowMessage( stdout, GetResString( IDS_GPO ) );
  2036. GpoName( pNameSpace, szTemp, pAuthIdentity );
  2037. // Get the bit-map name
  2038. bResult = PropertyGet( pClass, CPV_BITMAPNAME, strTemp, V_NOT_AVAILABLE );
  2039. CHECK_BRESULT( bResult );
  2040. ShowMessage( stdout, GetResString( IDS_BITMAPNAME ) );
  2041. ShowMessage( stdout, strTemp );
  2042. // Get the Logo bitmap name
  2043. bResult = PropertyGet( pClass, CPV_LOGOBITMAPNAME, strTemp, V_NOT_AVAILABLE );
  2044. CHECK_BRESULT( bResult );
  2045. ShowMessage( stdout, GetResString( IDS_LOGOBITMAPNAME ) );
  2046. ShowMessage( stdout, strTemp );
  2047. // Get the title bar text
  2048. bResult = PropertyGet( pClass, CPV_TITLEBARTEXT, strTemp, V_NOT_AVAILABLE );
  2049. CHECK_BRESULT( bResult );
  2050. ShowMessage( stdout, GetResString( IDS_TITLEBARTEXT ) );
  2051. ShowMessage( stdout, strTemp );
  2052. // Get the user agent text
  2053. bResult = PropertyGet( pClass, CPV_USERAGENTTEXT, strTemp, V_NOT_AVAILABLE );
  2054. CHECK_BRESULT( bResult );
  2055. ShowMessage( stdout, GetResString( IDS_USERAGENTTEXT ) );
  2056. ShowMessage( stdout, strTemp );
  2057. // Get the info., wether to delete the existing toolbar buttons
  2058. bResult = PropertyGet( pClass, CPV_TOOL_BUTTONS, bTemp, FALSE );
  2059. CHECK_BRESULT( bResult );
  2060. ShowMessage( stdout, GetResString( IDS_TOOL_BUTTONS ) );
  2061. if( bTemp == VAR_TRUE )
  2062. {
  2063. ShowMessage( stdout, GetResString( IDS_YES ) );
  2064. }
  2065. else
  2066. {
  2067. ShowMessage( stdout, GetResString( IDS_NO ) );
  2068. }
  2069. ShowMessage( stdout, NEW_LINE );
  2070. }// while
  2071. }
  2072. catch( _com_error & error )
  2073. {
  2074. WMISaveError( error.Error() );
  2075. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  2076. ShowMessage( stderr, GetReason() );
  2077. }
  2078. catch( CHeap_Exception )
  2079. {
  2080. SetLastError( E_OUTOFMEMORY );
  2081. SaveLastError();
  2082. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  2083. ShowMessage( stderr, GetReason() );
  2084. }
  2085. // Release the interface pointers
  2086. SAFEIRELEASE( pEnumClass );
  2087. SAFEIRELEASE( pClass );
  2088. return;
  2089. }
  2090. /*********************************************************************************************
  2091. Routine Description
  2092. This function displays the IE favorites information.
  2093. Arguments:
  2094. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  2095. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  2096. Return Value:
  2097. None
  2098. *********************************************************************************************/
  2099. VOID DisplayIEFavorites( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity )
  2100. {
  2101. HRESULT hResult = S_OK;
  2102. BOOL bResult = FALSE;
  2103. ULONG ulReturned = 0;
  2104. DWORD dwTemp = 0;
  2105. IWbemClassObject *pClass = NULL;
  2106. IEnumWbemClassObject *pEnumClass = NULL;
  2107. TCHAR szTemp[ MAX_STRING_LENGTH ];
  2108. CHString strTemp;
  2109. try
  2110. {
  2111. if( pNameSpace == NULL )
  2112. {
  2113. _com_issue_error( STG_E_UNKNOWN );
  2114. }
  2115. ZeroMemory( szTemp, sizeof( szTemp ) );
  2116. // Enumerate the classes
  2117. hResult = pNameSpace->CreateInstanceEnum( _bstr_t( CLS_IE_FAVLINKORITEM ),
  2118. WBEM_FLAG_FORWARD_ONLY |
  2119. WBEM_FLAG_RETURN_IMMEDIATELY,
  2120. NULL, &pEnumClass);
  2121. CHECK_HRESULT( hResult );
  2122. // Set the interface security
  2123. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  2124. CHECK_HRESULT( hResult );
  2125. hResult = WBEM_S_NO_ERROR;
  2126. while( WBEM_S_NO_ERROR == hResult )
  2127. {
  2128. // Get the next class
  2129. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  2130. CHECK_HRESULT( hResult );
  2131. if( ulReturned == 0 )
  2132. {
  2133. // No more classes to enumerate
  2134. break;
  2135. }
  2136. // Get the URL information
  2137. bResult = PropertyGet( pClass, CPV_URL, strTemp, V_NOT_AVAILABLE );
  2138. CHECK_BRESULT( bResult );
  2139. ShowMessage( stdout, GetResString( IDS_URL ) );
  2140. ShowMessage( stdout, strTemp );
  2141. // Get the information on wether the site is available off line
  2142. bResult = PropertyGet( pClass, CPV_AVAILOFFLINE, dwTemp, 2 );
  2143. CHECK_BRESULT( bResult );
  2144. ShowMessage( stdout, GetResString( IDS_AVAILABLE ) );
  2145. if( dwTemp == VAR_TRUE )
  2146. {
  2147. ShowMessage( stdout, GetResString( IDS_YES ) );
  2148. }
  2149. else
  2150. {
  2151. ShowMessage( stdout, GetResString( IDS_NO ) );
  2152. }
  2153. ShowMessage( stdout, GetResString( IDS_NEWLINE ) );
  2154. }// while
  2155. }
  2156. catch( _com_error & error )
  2157. {
  2158. WMISaveError( error.Error() );
  2159. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  2160. ShowMessage( stderr, GetReason() );
  2161. }
  2162. // Release the interface pointers
  2163. SAFEIRELEASE( pEnumClass );
  2164. SAFEIRELEASE( pClass );
  2165. return;
  2166. }
  2167. /*********************************************************************************************
  2168. Routine Description
  2169. This function displays the IE security contents information.
  2170. Arguments:
  2171. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  2172. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  2173. Return Value:
  2174. None
  2175. *********************************************************************************************/
  2176. VOID DisplayIESecurityContent( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity )
  2177. {
  2178. HRESULT hResult = S_OK;
  2179. BOOL bResult = FALSE;
  2180. BOOL bGotClass = FALSE;
  2181. BOOL bTemp = FALSE;
  2182. DWORD dwTemp = 0;
  2183. ULONG ulReturned = 0;
  2184. LONG lLBound = 0;
  2185. LONG lUBound = 0;
  2186. IWbemClassObject *pClass = NULL;
  2187. IEnumWbemClassObject *pEnumClass = NULL;
  2188. VARIANT vVarVerbose;
  2189. VARTYPE vartype;
  2190. TCHAR szTemp[ MAX_STRING_LENGTH ];
  2191. CHString strTemp;
  2192. SAFEARRAY *safeArray = NULL;
  2193. try
  2194. {
  2195. if( pNameSpace == NULL )
  2196. {
  2197. _com_issue_error( STG_E_UNKNOWN );
  2198. }
  2199. ZeroMemory( szTemp, sizeof( szTemp ) );
  2200. // enumerate the classes
  2201. hResult = pNameSpace->CreateInstanceEnum( _bstr_t( CLS_IE_SECURITY_CONTENT ),
  2202. WBEM_FLAG_FORWARD_ONLY |
  2203. WBEM_FLAG_RETURN_IMMEDIATELY,
  2204. NULL, &pEnumClass);
  2205. CHECK_HRESULT( hResult );
  2206. // set the interface security
  2207. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  2208. CHECK_HRESULT( hResult );
  2209. hResult = WBEM_S_NO_ERROR;
  2210. while( WBEM_S_NO_ERROR == hResult )
  2211. {
  2212. // Get the next class
  2213. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  2214. CHECK_HRESULT( hResult );
  2215. if( ulReturned == 0 )
  2216. {
  2217. // No more classes to enumerate
  2218. // Display N/A if there were no instances in both the security classes
  2219. if( bGotClass == FALSE )
  2220. {
  2221. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  2222. ShowMessage( stdout, V_NOT_AVAILABLE );
  2223. ShowMessage( stdout, NEW_LINE );
  2224. }
  2225. break;
  2226. }
  2227. // Got a class...set the flag
  2228. bGotClass = TRUE;
  2229. // Get the viewable sites information
  2230. VariantInit( &vVarVerbose );
  2231. ShowMessage( stdout, GetResString( IDS_VIEWABLESITES ) );
  2232. hResult = pClass->Get( _bstr_t( CPV_ALWAYSVIEW ), 0, &vVarVerbose, 0, 0 );
  2233. CHECK_HRESULT_VAR( hResult, vVarVerbose );
  2234. if( vVarVerbose.vt != VT_NULL && vVarVerbose.vt != VT_EMPTY )
  2235. {
  2236. // get the type of the elements in the safe array
  2237. vartype = V_VT( &vVarVerbose ) & ~VT_ARRAY;
  2238. //get the array of strings in to the safe array from the variant
  2239. safeArray = ( SAFEARRAY * )vVarVerbose.parray;
  2240. //get the number of elements (subkeys)
  2241. if( safeArray != NULL )
  2242. {
  2243. hResult = SafeArrayGetLBound( safeArray, 1, &lLBound );
  2244. CHECK_HRESULT( hResult );
  2245. hResult = SafeArrayGetUBound( safeArray, 1, &lUBound );
  2246. CHECK_HRESULT( hResult );
  2247. }
  2248. for( ; lLBound <= lUBound; lLBound++ )
  2249. {
  2250. // Get the element from the safe array
  2251. bResult = GetPropertyFromSafeArray( safeArray, lLBound, strTemp, vartype );
  2252. CHECK_BRESULT( bResult );
  2253. if( strTemp.GetLength() == 0 )
  2254. {
  2255. ShowMessage( stdout, V_NOT_AVAILABLE );
  2256. }
  2257. else
  2258. {
  2259. ShowMessage( stdout, strTemp );
  2260. }
  2261. ShowMessage( stdout, GetResString( IDS_NEWLINE1 ) );
  2262. }
  2263. }
  2264. else
  2265. {
  2266. ShowMessage( stdout, V_NOT_AVAILABLE );
  2267. }
  2268. // Get the password over-ride information
  2269. ShowMessage( stdout, GetResString( IDS_PASSWORDOVERRIDE ) );
  2270. bResult = PropertyGet( pClass, CPV_ENABLEPASSWORD, bTemp, FALSE );
  2271. CHECK_BRESULT( bResult );
  2272. if( bTemp == VAR_TRUE )
  2273. {
  2274. ShowMessage( stdout, GetResString( IDS_TRUE ) );
  2275. }
  2276. else
  2277. {
  2278. ShowMessage( stdout, GetResString( IDS_FALSE ) );
  2279. }
  2280. ShowMessage( stdout, GetResString( IDS_NEWLINE ) );
  2281. VariantClear(&vVarVerbose);
  2282. }// while
  2283. }
  2284. catch( _com_error & error )
  2285. {
  2286. WMISaveError( error.Error() );
  2287. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  2288. ShowMessage( stderr, GetReason() );
  2289. VariantClear(&vVarVerbose);
  2290. }
  2291. // Release the interface pointers
  2292. SAFEIRELEASE( pEnumClass );
  2293. SAFEIRELEASE( pClass );
  2294. return;
  2295. }
  2296. /*********************************************************************************************
  2297. Routine Description
  2298. This function displays the IE security information.
  2299. Arguments:
  2300. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  2301. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  2302. Return Value:
  2303. None
  2304. *********************************************************************************************/
  2305. VOID DisplayIESecurity( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  2306. BOOL bSuperVerbose )
  2307. {
  2308. HRESULT hResult = S_OK;
  2309. BOOL bResult = FALSE;
  2310. BOOL bGotClass = FALSE;
  2311. BOOL bTemp = FALSE;
  2312. ULONG ulReturned = 0;
  2313. IWbemClassObject *pClass = NULL;
  2314. IEnumWbemClassObject *pEnumClass = NULL;
  2315. TCHAR szTemp[ MAX_STRING_LENGTH ];
  2316. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  2317. CHString strTemp;
  2318. try
  2319. {
  2320. if( pNameSpace == NULL )
  2321. {
  2322. _com_issue_error( STG_E_UNKNOWN );
  2323. }
  2324. ZeroMemory( szTemp, sizeof( szTemp ) );
  2325. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  2326. // Form the query string
  2327. if( bSuperVerbose == TRUE )
  2328. {
  2329. // ennumerate all the classes
  2330. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  2331. FORMAT_STRING( szQueryString, szTemp, CLS_IE_POLICY );
  2332. }
  2333. else
  2334. {
  2335. // ennumerate all the classes with precedance = 1
  2336. lstrcpy( szTemp, QUERY_VERBOSE );
  2337. FORMAT_STRING( szQueryString, szTemp, CLS_IE_POLICY );
  2338. }
  2339. // Get the pointer to ennumerate with
  2340. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  2341. _bstr_t( szQueryString ),
  2342. WBEM_FLAG_FORWARD_ONLY |
  2343. WBEM_FLAG_RETURN_IMMEDIATELY,
  2344. NULL, &pEnumClass );
  2345. CHECK_HRESULT( hResult );
  2346. // Set the interface security
  2347. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  2348. CHECK_HRESULT( hResult );
  2349. hResult = WBEM_S_NO_ERROR;
  2350. while( WBEM_S_NO_ERROR == hResult )
  2351. {
  2352. // get the next class
  2353. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  2354. CHECK_HRESULT( hResult );
  2355. if( ulReturned == 0 )
  2356. {
  2357. // No more classes to enumerate
  2358. break;
  2359. }
  2360. // Got a class...set the flag
  2361. bGotClass = TRUE;
  2362. // Get the GPO id
  2363. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  2364. CHECK_BRESULT( bResult );
  2365. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  2366. ShowMessage( stdout, GetResString( IDS_GPO ) );
  2367. GpoName( pNameSpace, szTemp, pAuthIdentity );
  2368. // Get the Security content information
  2369. bResult = PropertyGet( pClass, CPV_SEC_CONTENT, bTemp, FALSE );
  2370. CHECK_BRESULT( bResult );
  2371. ShowMessage( stdout, GetResString( IDS_CONTENT_SETTING ) );
  2372. if( bTemp == VAR_TRUE )
  2373. {
  2374. ShowMessage( stdout, GetResString( IDS_YES ) );
  2375. }
  2376. else
  2377. {
  2378. ShowMessage( stdout, GetResString( IDS_NO ) );
  2379. }
  2380. // Get the Security zone information
  2381. bResult = PropertyGet( pClass, CPV_SEC_ZONE, bTemp, FALSE );
  2382. CHECK_BRESULT( bResult );
  2383. ShowMessage( stdout, GetResString( IDS_ZONE_SETTING ) );
  2384. if( bTemp == VAR_TRUE )
  2385. {
  2386. ShowMessage( stdout, GetResString( IDS_YES ) );
  2387. }
  2388. else
  2389. {
  2390. ShowMessage( stdout, GetResString( IDS_NO ) );
  2391. }
  2392. // Get the Authenticode information
  2393. bResult = PropertyGet( pClass, CPV_AUTH_CODE, bTemp, FALSE );
  2394. CHECK_BRESULT( bResult );
  2395. ShowMessage( stdout, GetResString( IDS_AUTH_SETTING ) );
  2396. if( bTemp == VAR_TRUE )
  2397. {
  2398. ShowMessage( stdout, GetResString( IDS_YES ) );
  2399. }
  2400. else
  2401. {
  2402. ShowMessage( stdout, GetResString( IDS_NO ) );
  2403. }
  2404. // Get the trusted publisher lock down information
  2405. bResult = PropertyGet( pClass, CPV_TRUST_PUB, bTemp, FALSE );
  2406. CHECK_BRESULT( bResult );
  2407. ShowMessage( stdout, GetResString( IDS_TRUST_PUB ) );
  2408. if( bTemp == VAR_TRUE )
  2409. {
  2410. ShowMessage( stdout, GetResString( IDS_YES ) );
  2411. }
  2412. else
  2413. {
  2414. ShowMessage( stdout, GetResString( IDS_NO ) );
  2415. }
  2416. ShowMessage( stdout, NEW_LINE );
  2417. }// while
  2418. }
  2419. catch( _com_error & error )
  2420. {
  2421. WMISaveError( error.Error() );
  2422. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  2423. ShowMessage( stderr, GetReason() );
  2424. }
  2425. catch( CHeap_Exception )
  2426. {
  2427. SetLastError( E_OUTOFMEMORY );
  2428. SaveLastError();
  2429. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  2430. ShowMessage( stderr, GetReason() );
  2431. }
  2432. // Release the interface pointers
  2433. SAFEIRELEASE( pEnumClass );
  2434. SAFEIRELEASE( pClass );
  2435. return;
  2436. }
  2437. /*********************************************************************************************
  2438. Routine Description
  2439. This function displays the IE proxy information.
  2440. Arguments:
  2441. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  2442. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  2443. Return Value:
  2444. None
  2445. *********************************************************************************************/
  2446. VOID DisplayIEProxySetting( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity )
  2447. {
  2448. HRESULT hResult = S_OK;
  2449. BOOL bResult = FALSE;
  2450. BOOL bGotClass = FALSE;
  2451. ULONG ulReturned = 0;
  2452. DWORD dwTemp = 0;
  2453. IWbemClassObject *pClass = NULL;
  2454. IEnumWbemClassObject *pEnumClass = NULL;
  2455. TCHAR szTemp[ MAX_STRING_LENGTH ];
  2456. CHString strTemp;
  2457. try
  2458. {
  2459. if( pNameSpace == NULL )
  2460. {
  2461. _com_issue_error( STG_E_UNKNOWN );
  2462. }
  2463. ZeroMemory( szTemp, sizeof( szTemp ) );
  2464. // Enumerate the classes
  2465. hResult = pNameSpace->CreateInstanceEnum( _bstr_t( CLS_IE_CONNECTION ),
  2466. WBEM_FLAG_FORWARD_ONLY |
  2467. WBEM_FLAG_RETURN_IMMEDIATELY,
  2468. NULL, &pEnumClass);
  2469. CHECK_HRESULT( hResult );
  2470. // set the security interface
  2471. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  2472. CHECK_HRESULT( hResult );
  2473. hResult = WBEM_S_NO_ERROR;
  2474. while( WBEM_S_NO_ERROR == hResult )
  2475. {
  2476. // Get the next class
  2477. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  2478. CHECK_HRESULT( hResult );
  2479. if( ulReturned == 0 )
  2480. {
  2481. // No more classes to enumerate
  2482. // Display N/A if there were no classes
  2483. if( bGotClass == FALSE )
  2484. {
  2485. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  2486. ShowMessage( stdout, V_NOT_AVAILABLE );
  2487. ShowMessage( stdout, NEW_LINE );
  2488. }
  2489. break;
  2490. }
  2491. bGotClass = TRUE;
  2492. // Get the http proxy information
  2493. bResult = PropertyGet( pClass, CPV_HTTP_PROXY, strTemp, V_NOT_AVAILABLE );
  2494. CHECK_BRESULT( bResult );
  2495. ShowMessage( stdout, GetResString( IDS_HTTP_PROXY ) );
  2496. ShowMessage( stdout, strTemp );
  2497. // Get the Secure proxy information
  2498. bResult = PropertyGet( pClass, CPV_SECURE_PROXY, strTemp, V_NOT_AVAILABLE );
  2499. CHECK_BRESULT( bResult );
  2500. ShowMessage( stdout, GetResString( IDS_SECURE_PROXY ) );
  2501. ShowMessage( stdout, strTemp );
  2502. // Get the ftp proxy information
  2503. bResult = PropertyGet( pClass, CPV_FTP_PROXY, strTemp, V_NOT_AVAILABLE );
  2504. CHECK_BRESULT( bResult );
  2505. ShowMessage( stdout, GetResString( IDS_FTP_PROXY ) );
  2506. ShowMessage( stdout, strTemp );
  2507. // Get the Gopher proxy information
  2508. bResult = PropertyGet( pClass, CPV_GOPHER_PROXY, strTemp, V_NOT_AVAILABLE );
  2509. CHECK_BRESULT( bResult );
  2510. ShowMessage( stdout, GetResString( IDS_GOPHER_PROXY ) );
  2511. ShowMessage( stdout, strTemp );
  2512. // Get the socks proxy information
  2513. bResult = PropertyGet( pClass, CPV_SOCKS_PROXY, strTemp, V_NOT_AVAILABLE );
  2514. CHECK_BRESULT( bResult );
  2515. ShowMessage( stdout, GetResString( IDS_SOCKS_PROXY ) );
  2516. ShowMessage( stdout, strTemp );
  2517. // Get the Auto config enable information
  2518. ShowMessage( stdout, GetResString( IDS_AUTO_CONFIG_ENABLE ) );
  2519. bResult = PropertyGet( pClass, CPV_AUTO_CONFIG_ENABLE, dwTemp, 2 );
  2520. CHECK_BRESULT( bResult );
  2521. if( dwTemp == -1 )
  2522. {
  2523. ShowMessage( stdout, GetResString( IDS_YES ) );
  2524. }
  2525. else
  2526. {
  2527. ShowMessage( stdout, GetResString( IDS_NO ) );
  2528. }
  2529. // Get the info on wether or not the proxy is enabled
  2530. ShowMessage( stdout, GetResString( IDS_ENABLE_PROXY ) );
  2531. bResult = PropertyGet( pClass, CPV_ENABLE_PROXY, dwTemp, 2 );
  2532. CHECK_BRESULT( bResult );
  2533. if( dwTemp == VAR_TRUE )
  2534. {
  2535. ShowMessage( stdout, GetResString( IDS_YES ) );
  2536. }
  2537. else
  2538. {
  2539. ShowMessage( stdout, GetResString( IDS_NO ) );
  2540. }
  2541. // Get the info on wether or not to use the same proxy
  2542. ShowMessage( stdout, GetResString( IDS_USE_SAME_PROXY ) );
  2543. bResult = PropertyGet( pClass, CPV_USE_SAME_PROXY, dwTemp, 2 );
  2544. CHECK_BRESULT( bResult );
  2545. if( dwTemp == -1 )
  2546. {
  2547. ShowMessage( stdout, GetResString( IDS_YES ) );
  2548. }
  2549. else
  2550. {
  2551. ShowMessage( stdout, GetResString( IDS_NO ) );
  2552. }
  2553. ShowMessage( stdout, GetResString( IDS_NEWLINE ) );
  2554. }// while
  2555. }
  2556. catch( _com_error & error )
  2557. {
  2558. WMISaveError( error.Error() );
  2559. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  2560. ShowMessage( stderr, GetReason() );
  2561. }
  2562. // Release the interface pointers
  2563. SAFEIRELEASE( pEnumClass );
  2564. SAFEIRELEASE( pClass );
  2565. return;
  2566. }
  2567. /*********************************************************************************************
  2568. Routine Description
  2569. This function displays the IE program settings for the user configuration.
  2570. Arguments:
  2571. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  2572. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  2573. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  2574. info is to be displayed.
  2575. Return Value:
  2576. None
  2577. *********************************************************************************************/
  2578. VOID DisplayIEPrograms( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  2579. BOOL bSuperVerbose )
  2580. {
  2581. HRESULT hResult = S_OK;
  2582. BOOL bResult = FALSE;
  2583. BOOL bGotClass = FALSE;
  2584. BOOL bTemp = FALSE;
  2585. ULONG ulReturned = 0;
  2586. IWbemClassObject *pClass = NULL;
  2587. IEnumWbemClassObject *pEnumClass = NULL;
  2588. TCHAR szTemp[ MAX_STRING_LENGTH ];
  2589. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  2590. CHString strTemp;
  2591. try
  2592. {
  2593. if( pNameSpace == NULL )
  2594. {
  2595. _com_issue_error( STG_E_UNKNOWN );
  2596. }
  2597. ZeroMemory( szTemp, sizeof( szTemp ) );
  2598. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  2599. // Form the query string
  2600. if( bSuperVerbose == TRUE )
  2601. {
  2602. // ennumerate all the classes
  2603. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  2604. FORMAT_STRING( szQueryString, szTemp, CLS_IE_POLICY );
  2605. }
  2606. else
  2607. {
  2608. // ennumerate all the classes with precedance = 1
  2609. lstrcpy( szTemp, QUERY_VERBOSE );
  2610. FORMAT_STRING( szQueryString, szTemp, CLS_IE_POLICY );
  2611. }
  2612. // Get the pointer to ennumerate with
  2613. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  2614. _bstr_t( szQueryString ),
  2615. WBEM_FLAG_FORWARD_ONLY |
  2616. WBEM_FLAG_RETURN_IMMEDIATELY,
  2617. NULL, &pEnumClass );
  2618. CHECK_HRESULT( hResult );
  2619. // Set the interface security
  2620. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  2621. CHECK_HRESULT( hResult );
  2622. hResult = WBEM_S_NO_ERROR;
  2623. while( WBEM_S_NO_ERROR == hResult )
  2624. {
  2625. // get the next class
  2626. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  2627. CHECK_HRESULT( hResult );
  2628. if( ulReturned == 0 )
  2629. {
  2630. // No more classes to enumerate
  2631. // Display N/A if there were no classes
  2632. if( bGotClass == FALSE )
  2633. {
  2634. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  2635. ShowMessage( stdout, V_NOT_AVAILABLE );
  2636. ShowMessage( stdout, NEW_LINE );
  2637. }
  2638. break;
  2639. }
  2640. bGotClass = TRUE;
  2641. // Get the GPO id
  2642. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  2643. CHECK_BRESULT( bResult );
  2644. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  2645. ShowMessage( stdout, GetResString( IDS_GPO ) );
  2646. GpoName( pNameSpace, szTemp, pAuthIdentity );
  2647. // Get the program information
  2648. bResult = PropertyGet( pClass, CPV_PROGRAM, bTemp, FALSE );
  2649. CHECK_BRESULT( bResult );
  2650. ShowMessage( stdout, GetResString( IDS_PROGRAM_SETTING ) );
  2651. if( bTemp == VAR_TRUE )
  2652. {
  2653. ShowMessage( stdout, GetResString( IDS_YES ) );
  2654. }
  2655. else
  2656. {
  2657. ShowMessage( stdout, GetResString( IDS_NO ) );
  2658. }
  2659. ShowMessage( stdout, NEW_LINE );
  2660. }// while
  2661. }
  2662. catch( _com_error & error )
  2663. {
  2664. WMISaveError( error.Error() );
  2665. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  2666. ShowMessage( stderr, GetReason() );
  2667. }
  2668. // Release the interface pointers
  2669. SAFEIRELEASE( pEnumClass );
  2670. SAFEIRELEASE( pClass );
  2671. return;
  2672. }
  2673. /*********************************************************************************************
  2674. Routine Description
  2675. This function displays the information on the important URLs.
  2676. Arguments:
  2677. [in] IWbemServices *pNamespace : pointer to IWbemServices.
  2678. [in] COAUTHIDENTITY *pAuthIdentity : pointer to the authorization structure
  2679. [in] BOOL bSuperVerbose : set to TRUE if the super verbose
  2680. info is to be displayed.
  2681. Return Value:
  2682. None
  2683. *********************************************************************************************/
  2684. VOID DisplayIEImpURLS( IWbemServices *pNameSpace, COAUTHIDENTITY *pAuthIdentity,
  2685. BOOL bSuperVerbose )
  2686. {
  2687. HRESULT hResult = S_OK;
  2688. BOOL bResult = FALSE;
  2689. BOOL bGotClass = FALSE;
  2690. BOOL bTemp = FALSE;
  2691. ULONG ulReturned = 0;
  2692. IWbemClassObject *pClass = NULL;
  2693. IEnumWbemClassObject *pEnumClass = NULL;
  2694. TCHAR szTemp[ MAX_STRING_LENGTH ];
  2695. TCHAR szQueryString [ MAX_STRING_LENGTH ];
  2696. CHString strTemp;
  2697. try
  2698. {
  2699. if( pNameSpace == NULL )
  2700. {
  2701. _com_issue_error( STG_E_UNKNOWN );
  2702. }
  2703. ZeroMemory( szTemp, sizeof( szTemp ) );
  2704. ZeroMemory( szQueryString, sizeof( szQueryString ) );
  2705. // Form the query string
  2706. if( bSuperVerbose == TRUE )
  2707. {
  2708. // ennumerate all the classes
  2709. lstrcpy( szTemp, QUERY_SUPER_VERBOSE );
  2710. FORMAT_STRING( szQueryString, szTemp, CLS_IE_POLICY );
  2711. }
  2712. else
  2713. {
  2714. // ennumerate all the classes with precedance = 1
  2715. lstrcpy( szTemp, QUERY_VERBOSE );
  2716. FORMAT_STRING( szQueryString, szTemp, CLS_IE_POLICY );
  2717. }
  2718. // Get the pointer to ennumerate with
  2719. hResult = pNameSpace->ExecQuery( _bstr_t( QUERY_LANGUAGE ),
  2720. _bstr_t( szQueryString ),
  2721. WBEM_FLAG_FORWARD_ONLY |
  2722. WBEM_FLAG_RETURN_IMMEDIATELY,
  2723. NULL, &pEnumClass );
  2724. CHECK_HRESULT( hResult );
  2725. // Set the interface security
  2726. hResult = SetInterfaceSecurity( pEnumClass, pAuthIdentity );
  2727. CHECK_HRESULT( hResult );
  2728. hResult = WBEM_S_NO_ERROR;
  2729. while( WBEM_S_NO_ERROR == hResult )
  2730. {
  2731. // get the next class
  2732. hResult = pEnumClass->Next( WBEM_INFINITE , 1, &pClass, &ulReturned );
  2733. CHECK_HRESULT( hResult );
  2734. if( ulReturned == 0 )
  2735. {
  2736. // No more classes to enumerate
  2737. // Display N/A if there were no classes
  2738. if( bGotClass == FALSE )
  2739. {
  2740. ShowMessage( stdout, GetResString( IDS_NEWLINE_TABTHREE ) );
  2741. ShowMessage( stdout, V_NOT_AVAILABLE );
  2742. ShowMessage( stdout, NEW_LINE );
  2743. }
  2744. break;
  2745. }
  2746. bGotClass = TRUE;
  2747. // Get the GPO id
  2748. bResult = PropertyGet( pClass, CPV_GPOID, strTemp, V_NOT_AVAILABLE );
  2749. CHECK_BRESULT( bResult );
  2750. lstrcpy( szTemp, strTemp.GetBuffer( strTemp.GetLength() ) );
  2751. ShowMessage( stdout, GetResString( IDS_GPO ) );
  2752. GpoName( pNameSpace, szTemp, pAuthIdentity );
  2753. // Get the home page URL
  2754. bResult = PropertyGet( pClass, CPV_HOMEPAGEURL, strTemp, V_NOT_AVAILABLE );
  2755. CHECK_BRESULT( bResult );
  2756. ShowMessage( stdout, GetResString( IDS_HOMEPAGEURL ) );
  2757. ShowMessage( stdout, strTemp );
  2758. // Get the search bar URL
  2759. bResult = PropertyGet( pClass, CPV_SEARCHBARURL, strTemp, V_NOT_AVAILABLE );
  2760. CHECK_BRESULT( bResult );
  2761. ShowMessage( stdout, GetResString( IDS_SEARCHBARURL ) );
  2762. ShowMessage( stdout, strTemp );
  2763. // Get the Online Help Page URL
  2764. bResult = PropertyGet( pClass, CPV_HELPPAGEURL, strTemp, V_NOT_AVAILABLE );
  2765. CHECK_BRESULT( bResult );
  2766. ShowMessage( stdout, GetResString( IDS_HELPPAGEURL ) );
  2767. ShowMessage( stdout, strTemp );
  2768. ShowMessage( stdout, NEW_LINE );
  2769. }// while
  2770. }
  2771. catch( _com_error & error )
  2772. {
  2773. WMISaveError( error.Error() );
  2774. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  2775. ShowMessage( stderr, GetReason() );
  2776. }
  2777. catch( CHeap_Exception )
  2778. {
  2779. SetLastError( E_OUTOFMEMORY );
  2780. SaveLastError();
  2781. ShowMessage( stderr, GetResString( IDS_ERROR ) );
  2782. ShowMessage( stderr, GetReason() );
  2783. }
  2784. // Release the interface pointers
  2785. SAFEIRELEASE( pEnumClass );
  2786. SAFEIRELEASE( pClass );
  2787. return;
  2788. }