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.

139 lines
4.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: lnumber.cpp
  7. //
  8. // Contents: implementation of CLocalPolNumber
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "wsecmgr.h"
  13. #include "snapmgr.h"
  14. #include "util.h"
  15. #include "anumber.h"
  16. #include "lnumber.h"
  17. #include "DDWarn.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CLocalPolNumber dialog
  25. CLocalPolNumber::CLocalPolNumber()
  26. : CConfigNumber(IDD)
  27. {
  28. m_pHelpIDs = (DWORD_PTR)a228HelpIDs;
  29. m_uTemplateResID = IDD;
  30. }
  31. BOOL CLocalPolNumber::OnApply()
  32. {
  33. if ( !m_bReadOnly )
  34. {
  35. BOOL bUpdateAll = FALSE;
  36. DWORD dw = 0;
  37. CString strForever,strOff;
  38. int status = 0;
  39. UpdateData(TRUE);
  40. if (m_bConfigure)
  41. {
  42. dw = CurrentEditValue();
  43. bUpdateAll = FALSE;
  44. PEDITTEMPLATE pLocalDeltaTemplate = m_pSnapin->GetTemplate(GT_LOCAL_POLICY_DELTA,AREA_SECURITY_POLICY);
  45. if (pLocalDeltaTemplate)
  46. pLocalDeltaTemplate->LockWriteThrough();
  47. //
  48. // Check dependencies for the item.
  49. //
  50. if (DDWarn.CheckDependencies (dw) == ERROR_MORE_DATA )
  51. {
  52. //
  53. // If the user presses cancel then we will not allow them to set the item and let
  54. // them press cancel.
  55. //
  56. CThemeContextActivator activator;
  57. if ( DDWarn.DoModal() != IDOK)
  58. return FALSE;
  59. //
  60. // The user is giving us the go ahead to set the items to the suggested
  61. // configuration.
  62. //
  63. for (int i = 0; i < DDWarn.GetFailedCount(); i++)
  64. {
  65. PDEPENDENCYFAILED pItem = DDWarn.GetFailedInfo(i);
  66. if (pItem && pItem->pResult )
  67. {
  68. //
  69. // Update local policy for each item that failed the dependency.
  70. // The suggested values are relative to the item we are configuring.
  71. //
  72. status = m_pSnapin->SetLocalPolInfo(
  73. pItem->pResult->GetID(),
  74. pItem->dwSuggested);
  75. if (SCE_ERROR_VALUE != status)
  76. {
  77. pItem->pResult->SetBase( pItem->dwSuggested );
  78. pItem->pResult->SetStatus( status );
  79. pItem->pResult->Update(m_pSnapin, FALSE);
  80. }
  81. }
  82. }
  83. }
  84. //
  85. // Update local policy for this item.
  86. //
  87. status = m_pSnapin->SetLocalPolInfo(m_pData->GetID(),dw);
  88. if (pLocalDeltaTemplate)
  89. pLocalDeltaTemplate->UnLockWriteThrough();
  90. if (SCE_ERROR_VALUE != status)
  91. {
  92. m_pData->SetBase(dw);
  93. m_pData->SetStatus(status);
  94. //
  95. // Update the entire pane, not just this particular item, since
  96. // many of these changes will effect a second item in the pane
  97. //
  98. switch (m_pData->GetID())
  99. {
  100. case IDS_SEC_LOG_DAYS:
  101. case IDS_APP_LOG_DAYS:
  102. case IDS_SYS_LOG_DAYS:
  103. bUpdateAll = TRUE;
  104. break;
  105. default:
  106. break;
  107. }
  108. }
  109. //
  110. // Redraw the result pane.
  111. //
  112. if (SCE_ERROR_VALUE != status || bUpdateAll)
  113. m_pData->Update(m_pSnapin, bUpdateAll);
  114. }
  115. }
  116. // Class hieirarchy is bad - call CAttribute base method directly
  117. return CAttribute::OnApply();
  118. }