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.

940 lines
26 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #include"stdafx.h"
  3. #include"snodes.h"
  4. #include"resource.h"
  5. #define ERROR_USERDEFINED_LICENSE_VIOLATION ( ( DWORD )0xC000026AL )
  6. extern void xxxErrMessage( HWND hwnd , INT_PTR nResMessageId , INT_PTR nResTitleId , UINT nFlags );
  7. extern void TscAccessDeniedMsg( HWND hwnd );
  8. extern void TscGeneralErrMsg( HWND hwnd );
  9. extern void ReportStatusError( HWND hwnd , DWORD dwStatus );
  10. void SnodeErrorHandler( HWND hParent , INT nObjectId , DWORD dwStatus );
  11. //----------------------------------------------------------
  12. CSettingNode::CSettingNode( )
  13. {
  14. m_szAttributeName = NULL;
  15. m_szAttributeValue = NULL;
  16. SetNodeType( RSETTINGS_NODE );
  17. m_objectid = -1;
  18. m_pSettings = NULL;
  19. m_hrStatus = S_OK;
  20. }
  21. //----------------------------------------------------------
  22. void CSettingNode::SetObjectId( INT id )
  23. {
  24. m_objectid = id;
  25. }
  26. //----------------------------------------------------------
  27. HRESULT CSettingNode::SetAttributeValue( DWORD nVal , PDWORD pdwStatus )
  28. {
  29. HRESULT hr = S_OK;
  30. ISettingsComp *pSettings = NULL;
  31. INT nObjectId = GetObjectId( );
  32. if( nObjectId < CUSTOM_EXTENSION )
  33. {
  34. pSettings = reinterpret_cast< ISettingsComp *>( m_pSettings );
  35. if( pSettings == NULL )
  36. {
  37. ODS( L"CSettingNode::SetAttributeValue downcasting failure\n" );
  38. return E_FAIL;
  39. }
  40. }
  41. if( nObjectId == LICENSING )
  42. {
  43. DWORD dwNewStatus;
  44. hr = pSettings->SetLicensingMode( nVal , pdwStatus, &dwNewStatus );
  45. if( SUCCEEDED( hr ) )
  46. {
  47. xx_SetValue( nVal );
  48. }
  49. else
  50. {
  51. if ((NULL != pdwStatus) && (ERROR_SUCCESS == *pdwStatus))
  52. {
  53. // make sure any failure gets returned to caller
  54. *pdwStatus = dwNewStatus;
  55. }
  56. }
  57. }
  58. else
  59. {
  60. if( nObjectId == DELETED_DIRS_ONEXIT ) // Delete temp dirs on exit
  61. {
  62. hr = pSettings->SetDelDirsOnExit( ( BOOL )nVal );
  63. }
  64. else if( nObjectId == PERSESSION_TEMPDIR )// User temp dirs per session
  65. {
  66. hr = pSettings->SetUseTempDirPerSession( ( BOOL )nVal );
  67. }
  68. /* else if( nObjectId == DEF_CONSECURITY ) // default security descriptor
  69. {
  70. hr = m_pSettings->SetDefaultSecurity( nVal );
  71. }*/
  72. else if( nObjectId == ACTIVE_DESK )
  73. {
  74. hr = pSettings->SetActiveDesktopState( nVal , pdwStatus );
  75. }
  76. else if( nObjectId == USERSECURITY )
  77. {
  78. hr = pSettings->SetUserPerm( nVal , pdwStatus );
  79. if( FAILED( hr ) )
  80. {
  81. return hr;
  82. }
  83. }
  84. else if( nObjectId == SINGLE_SESSION )
  85. {
  86. hr = pSettings->SetSingleSessionState( nVal , pdwStatus );
  87. }
  88. if( FAILED( hr ) )
  89. {
  90. if( hr == E_ACCESSDENIED )
  91. {
  92. *pdwStatus = ERROR_ACCESS_DENIED;
  93. }
  94. else
  95. {
  96. *pdwStatus = ( DWORD )hr; // general failure
  97. }
  98. }
  99. else
  100. {
  101. xx_SetValue( nVal );
  102. }
  103. }
  104. return hr;
  105. }
  106. //----------------------------------------------------------
  107. BOOL CSettingNode::SetAttributeName( LPTSTR psz )
  108. {
  109. if( psz != NULL )
  110. {
  111. int cchText = lstrlen( psz ) + 1;
  112. if( m_szAttributeName != NULL )
  113. {
  114. delete[] m_szAttributeName;
  115. }
  116. m_szAttributeName = ( LPTSTR )new TCHAR[ cchText ];
  117. if( m_szAttributeName != NULL )
  118. {
  119. lstrcpy( m_szAttributeName , psz );
  120. }
  121. return TRUE;
  122. }
  123. return FALSE;
  124. }
  125. //----------------------------------------------------------
  126. LPTSTR CSettingNode::GetAttributeValue( )
  127. {
  128. DWORD nVal = 0;
  129. DWORD dwStatus;
  130. ISettingsComp *pSettings = NULL;
  131. HRESULT hr = S_OK;
  132. INT nObjectId = GetObjectId( );
  133. if( nObjectId < CUSTOM_EXTENSION )
  134. {
  135. pSettings = reinterpret_cast< ISettingsComp *>( m_pSettings );
  136. if( pSettings == NULL )
  137. {
  138. hr = E_FAIL;
  139. }
  140. ODS( L"Getting attribute value\n" );
  141. }
  142. if( SUCCEEDED( hr ) )
  143. {
  144. POLICY_TS_MACHINE p;
  145. RegGetMachinePolicy(&p);
  146. switch( nObjectId )
  147. {
  148. case DELETED_DIRS_ONEXIT: // Delete temp dirs on exit
  149. hr = pSettings->GetDelDirsOnExit( ( PBOOL )&nVal );
  150. if (p.fPolicyDeleteTempFoldersOnExit)
  151. nVal = p.fDeleteTempFoldersOnExit;
  152. break;
  153. case PERSESSION_TEMPDIR:// User temp dirs per session
  154. hr = pSettings->GetUseTempDirPerSession( ( PBOOL )&nVal );
  155. if (p.fPolicyTempFoldersPerSession)
  156. nVal = p.fTempFoldersPerSession;
  157. break;
  158. /* case DEF_CONSECURITY: // default security descriptor
  159. hr = m_pSettings->GetDefaultSecurity( &nVal );
  160. break;
  161. */
  162. case LICENSING: // licensing mode
  163. hr = pSettings->GetLicensingMode( &nVal , &dwStatus );
  164. break;
  165. case ACTIVE_DESK:
  166. hr = pSettings->GetActiveDesktopState( ( PBOOL )&nVal , &dwStatus );
  167. break;
  168. case USERSECURITY:
  169. hr = pSettings->GetUserPerm( ( PBOOL )&nVal , &dwStatus );
  170. break;
  171. case SINGLE_SESSION:
  172. hr = pSettings->GetSingleSessionState( ( PBOOL )&nVal , &dwStatus );
  173. if (p.fPolicySingleSessionPerUser)
  174. nVal = p.fSingleSessionPerUser;
  175. break;
  176. default:
  177. if( nObjectId >= CUSTOM_EXTENSION )
  178. {
  179. ODS( L"Getting attribute value\n" );
  180. nVal = 0; // we don't care we leave it up to the provider
  181. hr = S_OK;
  182. }
  183. }
  184. }
  185. if( FAILED( hr ) )
  186. {
  187. TCHAR szBuffer[ 80 ];
  188. szBuffer[0] = 0;
  189. if( m_szAttributeValue != NULL )
  190. {
  191. delete[] m_szAttributeValue;
  192. }
  193. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_SSERROR , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  194. m_szAttributeValue = ( LPTSTR )new TCHAR[ lstrlen( szBuffer ) + 1 ];
  195. if( m_szAttributeValue != NULL )
  196. {
  197. lstrcpy( m_szAttributeValue , szBuffer );
  198. }
  199. if( nObjectId != LICENSING )
  200. {
  201. xx_SetValue( 0 );
  202. }
  203. }
  204. else
  205. {
  206. xx_SetValue( nVal );
  207. }
  208. m_hrStatus = hr;
  209. return m_szAttributeValue;
  210. }
  211. //----------------------------------------------------------
  212. DWORD CSettingNode::GetImageIdx( )
  213. {
  214. return ( DWORD )3;
  215. }
  216. //----------------------------------------------------------
  217. BOOL CSettingNode::AddMenuItems( LPCONTEXTMENUCALLBACK pcmc , PLONG pl )
  218. {
  219. HRESULT hr = E_FAIL;
  220. TCHAR tchName[ 80 ];
  221. TCHAR tchStatus[ 256 ];
  222. CONTEXTMENUITEM cmi;
  223. BOOL bVal = FALSE;
  224. INT nObjectId = GetObjectId( );
  225. POLICY_TS_MACHINE p;
  226. RegGetMachinePolicy(&p);
  227. switch( nObjectId )
  228. {
  229. case DELETED_DIRS_ONEXIT:
  230. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  231. cmi.strName = tchName;
  232. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  233. cmi.strStatusBarText = tchStatus;
  234. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  235. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  236. cmi.fFlags = cmi.fSpecialFlags = 0;
  237. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  238. hr = pcmc->AddItem( &cmi );
  239. if( SUCCEEDED( hr ) )
  240. {
  241. bVal = ( BOOL )xx_GetValue( );
  242. if( bVal )
  243. {
  244. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NOMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  245. cmi.strName = tchName;
  246. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NOTDELTEMP_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  247. cmi.strStatusBarText = tchStatus;
  248. }
  249. else
  250. {
  251. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YESMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  252. cmi.strName = tchName;
  253. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DELTEMP_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  254. cmi.strStatusBarText = tchStatus;
  255. }
  256. if (p.fPolicyDeleteTempFoldersOnExit)
  257. {
  258. //Clear the last 2 bits since MF_GRAYED is
  259. //incompatible with MF_DISABLED
  260. cmi.fFlags &= 0xFFFFFFFCL;
  261. cmi.fFlags |= MF_GRAYED;
  262. }
  263. cmi.lCommandID = IDM_SETTINGS_DELTEMPDIRSONEXIT;
  264. hr = pcmc->AddItem( &cmi );
  265. }
  266. break;
  267. case PERSESSION_TEMPDIR:
  268. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  269. cmi.strName = tchName;
  270. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  271. cmi.strStatusBarText = tchStatus;
  272. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  273. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  274. cmi.fFlags = cmi.fSpecialFlags = 0;
  275. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  276. hr = pcmc->AddItem( &cmi );
  277. if( SUCCEEDED( hr ) )
  278. {
  279. bVal = ( BOOL )xx_GetValue( );
  280. if( bVal )
  281. {
  282. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NOMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  283. cmi.strName = tchName;
  284. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NOTUSEPERSESSION_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  285. cmi.strStatusBarText = tchStatus;
  286. }
  287. else
  288. {
  289. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YESMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  290. cmi.strName = tchName;
  291. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_USEPERSESSION_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  292. cmi.strStatusBarText = tchStatus;
  293. }
  294. if (p.fPolicyTempFoldersPerSession)
  295. {
  296. //Clear the last 2 bits since MF_GRAYED is
  297. //incompatible with MF_DISABLED
  298. cmi.fFlags &= 0xFFFFFFFCL;
  299. cmi.fFlags |= MF_GRAYED;
  300. }
  301. cmi.lCommandID = IDM_SETTINGS_USETMPDIR;
  302. hr = pcmc->AddItem( &cmi );
  303. }
  304. break;
  305. /* case DEF_CONSECURITY:
  306. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  307. cmi.strName = tchName;
  308. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  309. cmi.strStatusBarText = tchStatus;
  310. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  311. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  312. cmi.fFlags = cmi.fSpecialFlags = 0;
  313. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  314. hr = pcmc->AddItem( &cmi );
  315. break;
  316. */
  317. case LICENSING:
  318. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  319. cmi.strName = tchName;
  320. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  321. cmi.strStatusBarText = tchStatus;
  322. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  323. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  324. cmi.fFlags = cmi.fSpecialFlags = 0;
  325. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  326. hr = pcmc->AddItem( &cmi );
  327. break;
  328. case ACTIVE_DESK:
  329. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  330. cmi.strName = tchName;
  331. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ACTIVEDESK_PROP_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  332. cmi.strStatusBarText = tchStatus;
  333. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  334. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  335. cmi.fFlags = cmi.fSpecialFlags = 0;
  336. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  337. hr = pcmc->AddItem( &cmi );
  338. if( SUCCEEDED( hr ) )
  339. {
  340. bVal = ( BOOL )xx_GetValue( );
  341. if( bVal )
  342. {
  343. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABLEMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  344. cmi.strName = tchName;
  345. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABLE_ADP_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  346. cmi.strStatusBarText = tchStatus;
  347. }
  348. else
  349. {
  350. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ENABLEMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  351. cmi.strName = tchName;
  352. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ENABLE_ADP_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  353. cmi.strStatusBarText = tchStatus;
  354. }
  355. cmi.lCommandID = IDM_SETTINGS_ADP;
  356. hr = pcmc->AddItem( &cmi );
  357. }
  358. break;
  359. case SINGLE_SESSION:
  360. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  361. cmi.strName = tchName;
  362. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  363. cmi.strStatusBarText = tchStatus;
  364. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  365. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  366. cmi.fFlags = cmi.fSpecialFlags = 0;
  367. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  368. hr = pcmc->AddItem( &cmi );
  369. if( SUCCEEDED( hr ) )
  370. {
  371. bVal = ( BOOL )xx_GetValue( );
  372. if( bVal )
  373. {
  374. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NOMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  375. cmi.strName = tchName;
  376. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABLE_SINGLESESSION_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  377. cmi.strStatusBarText = tchStatus;
  378. }
  379. else
  380. {
  381. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YESMENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  382. cmi.strName = tchName;
  383. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ENABLE_SINGLESESSION_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  384. cmi.strStatusBarText = tchStatus;
  385. }
  386. if (p.fPolicySingleSessionPerUser)
  387. {
  388. //Clear the last 2 bits since MF_GRAYED is
  389. //incompatible with MF_DISABLED
  390. cmi.fFlags &= 0xFFFFFFFCL;
  391. cmi.fFlags |= MF_GRAYED;
  392. }
  393. cmi.lCommandID = IDM_SETTINGS_SS;
  394. hr = pcmc->AddItem( &cmi );
  395. }
  396. break;
  397. case USERSECURITY:
  398. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_PROPERTIES_MENU , tchName , SIZE_OF_BUFFER( tchName ) ) );
  399. cmi.strName = tchName;
  400. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_STANDARAD_PROPERTIES_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  401. cmi.strStatusBarText = tchStatus;
  402. cmi.lCommandID = IDM_SETTINGS_PROPERTIES;
  403. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;//CCM_INSERTIONPOINTID_PRIMARY_TASK;
  404. cmi.fFlags = cmi.fSpecialFlags = 0;
  405. *pl |= CCM_INSERTIONALLOWED_TOP; //CCM_INSERTIONALLOWED_TASK;
  406. hr = pcmc->AddItem( &cmi );
  407. break;
  408. default:
  409. if( nObjectId >= CUSTOM_EXTENSION )
  410. {
  411. IExtendServerSettings *pSetting = reinterpret_cast< IExtendServerSettings * >( m_pSettings );
  412. if( pSetting != NULL )
  413. {
  414. PMENUEXTENSION pMex = NULL;
  415. INT cbItems = 0;
  416. if( SUCCEEDED( pSetting->GetMenuItems( &cbItems , &pMex ) ) )
  417. {
  418. for( INT i = 0 ; i < cbItems; i++ )
  419. {
  420. cmi.strName = pMex[ i ].MenuItemName;
  421. cmi.strStatusBarText = pMex[ i ].StatusBarText;
  422. cmi.lCommandID = pMex[ i ].cmd;
  423. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
  424. cmi.fFlags = pMex[ i ].fFlags;
  425. cmi.fSpecialFlags = 0;
  426. *pl |= CCM_INSERTIONALLOWED_TOP;
  427. if (p.fPolicySessionDirectoryActive)
  428. {
  429. //Gray out everything but properties
  430. if (cmi.lCommandID != IDM_MENU_PROPS)
  431. {
  432. //Clear the last 2 bits since MF_GRAYED is
  433. //incompatible with MF_DISABLED
  434. cmi.fFlags &= 0xFFFFFFFCL;
  435. cmi.fFlags |= MF_GRAYED;
  436. }
  437. }
  438. if (p.fPolicySessionDirectoryLocation)
  439. {
  440. //Enable the "enable" menu item
  441. if (cmi.lCommandID != IDM_MENU_PROPS)
  442. {
  443. cmi.fFlags = 0;
  444. }
  445. }
  446. pcmc->AddItem( &cmi );
  447. }
  448. hr = S_OK;
  449. LocalFree( pMex );
  450. }
  451. }
  452. }
  453. }
  454. return ( SUCCEEDED( hr ) ? TRUE : FALSE );
  455. }
  456. //----------------------------------------------------------
  457. BOOL CSettingNode::SetInterface( LPUNKNOWN pInf )
  458. {
  459. pInf->AddRef( );
  460. m_pSettings = pInf;
  461. return TRUE;
  462. }
  463. //----------------------------------------------------------
  464. CSettingNode::~CSettingNode( )
  465. {
  466. DBGMSG( L"CSettingNode dtor called for objectid %d\n" , m_objectid );
  467. if( m_szAttributeName != NULL )
  468. {
  469. delete[] m_szAttributeName;
  470. }
  471. if( m_szAttributeValue != NULL )
  472. {
  473. delete[] m_szAttributeValue;
  474. }
  475. if( m_pSettings != NULL )
  476. {
  477. m_pSettings->Release( );
  478. }
  479. }
  480. //---------------------------------------------------------
  481. // Helper functions
  482. //---------------------------------------------------------
  483. BOOL CSettingNode::xx_SetValue( INT nVal )
  484. {
  485. TCHAR szBuffer[ 1024 ];
  486. szBuffer[0] = 0;
  487. INT nObjectId = GetObjectId( );
  488. if( m_szAttributeValue != NULL )
  489. {
  490. delete[] m_szAttributeValue;
  491. }
  492. switch( nObjectId )
  493. {
  494. case SINGLE_SESSION:
  495. if( ( BOOL )nVal )
  496. {
  497. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YES , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  498. }
  499. else
  500. {
  501. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NO , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  502. }
  503. break;
  504. case DELETED_DIRS_ONEXIT: // Delete temp dirs on exit
  505. if( ( BOOL )nVal )
  506. {
  507. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YES , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  508. }
  509. else
  510. {
  511. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NO , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  512. }
  513. break;
  514. case PERSESSION_TEMPDIR:// User temp dirs per session
  515. if( ( BOOL )nVal )
  516. {
  517. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_YES , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  518. }
  519. else
  520. {
  521. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_NO , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  522. }
  523. break;
  524. /*
  525. case DEF_CONSECURITY: // default security descriptor
  526. switch( nVal )
  527. {
  528. case 0: // this shoudl never happen
  529. case 1:
  530. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_RAA , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  531. break;
  532. case 2:
  533. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_AS , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  534. break;
  535. case 3:
  536. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_AA , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  537. break;
  538. }
  539. break;
  540. */
  541. case LICENSING: // licensing mode
  542. {
  543. ISettingsComp *pSettings = reinterpret_cast< ISettingsComp * > (m_pSettings);
  544. if (NULL != pSettings)
  545. {
  546. WCHAR *wszName, *wszDescription;
  547. DWORD dwStatus;
  548. HRESULT hr;
  549. hr = pSettings->GetLicensingModeInfo(
  550. nVal,
  551. &wszName,
  552. &wszDescription,
  553. &dwStatus);
  554. if (SUCCEEDED(hr))
  555. {
  556. _ASSERTE( ERROR_SUCCESS == dwStatus );
  557. lstrcpyn(szBuffer,wszName,sizeof(szBuffer)/sizeof(TCHAR));
  558. CoTaskMemFree(wszName);
  559. CoTaskMemFree(wszDescription);
  560. }
  561. }
  562. }
  563. break;
  564. case ACTIVE_DESK:
  565. if( ( BOOL )nVal )
  566. {
  567. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ENABLED , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  568. }
  569. else
  570. {
  571. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABLED , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  572. }
  573. break;
  574. case USERSECURITY:
  575. if( ( BOOL )nVal )
  576. {
  577. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_USERPERM_NT4 , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  578. }
  579. else
  580. {
  581. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_USERPERM_W2K , szBuffer , SIZE_OF_BUFFER( szBuffer ) ) );
  582. }
  583. break;
  584. default:
  585. if( nObjectId >= CUSTOM_EXTENSION )
  586. {
  587. IExtendServerSettings *pSettings = reinterpret_cast< IExtendServerSettings *>( m_pSettings );
  588. if( pSettings != NULL )
  589. {
  590. pSettings->GetDisplayableValueName( szBuffer );
  591. DBGMSG( L"xx_SetValue for Extension returned %s\n" , szBuffer );
  592. }
  593. }
  594. } // switch
  595. m_szAttributeValue = ( LPTSTR )new TCHAR[ lstrlen( szBuffer ) + 1 ];
  596. if( m_szAttributeValue != NULL )
  597. {
  598. lstrcpy( m_szAttributeValue , szBuffer );
  599. }
  600. m_nGenericValue = nVal;
  601. return TRUE;
  602. }
  603. //----------------------------------------------------------------------
  604. // And all out central server setting error handler
  605. // this is setup in this manner to allow MMC to own the Msgbx as well
  606. // as the custom dialog pages
  607. //
  608. void SnodeErrorHandler( HWND hParent , INT nObjectId , DWORD dwStatus )
  609. {
  610. switch( nObjectId )
  611. {
  612. case DELETED_DIRS_ONEXIT: // Delete temp dirs on exit
  613. case PERSESSION_TEMPDIR:// User temp dirs per session
  614. case SINGLE_SESSION: // Restrict to single session per user
  615. // case DEF_CONSECURITY: // default security descriptor
  616. case LICENSING: // licensing mode
  617. case ACTIVE_DESK:
  618. if( dwStatus == ERROR_ACCESS_DENIED )
  619. {
  620. TscAccessDeniedMsg( hParent );
  621. }
  622. else
  623. {
  624. TscGeneralErrMsg( hParent );
  625. }
  626. break;
  627. case USERSECURITY:
  628. if( dwStatus != 0 )
  629. {
  630. ReportStatusError( hParent , dwStatus );
  631. }
  632. } // switch
  633. }