Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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