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.

832 lines
22 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: AObject.cpp
  7. //
  8. // Contents: Implementation of CAttrObject
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "wsecmgr.h"
  13. #include "attr.h"
  14. #include "resource.h"
  15. #include "snapmgr.h"
  16. #include "util.h"
  17. #include <accctrl.h>
  18. #include "servperm.h"
  19. #include "AObject.h"
  20. #include <aclapi.h>
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CAttrObject dialog
  28. CAttrObject::CAttrObject()
  29. : CAttribute(IDD),
  30. m_pSceInspect(NULL),
  31. m_pSceTemplate(NULL),
  32. posInspect(NULL),
  33. posTemplate(NULL),
  34. m_bNotAnalyzed(FALSE), m_pfnCreateDsPage(NULL), m_pSI(NULL), m_pNewSD(NULL), m_pAnalSD(NULL),
  35. m_pCDI(NULL), m_AnalInfo(0), m_NewSeInfo(0), m_hwndTemplate(NULL), m_hwndInspect(NULL), m_pFolder(NULL)
  36. {
  37. //{{AFX_DATA_INIT(CAttrObject)
  38. m_strLastInspect = _T("");
  39. m_radConfigPrevent = 0;
  40. m_radInheritOverwrite = 0;
  41. //}}AFX_DATA_INIT
  42. m_pHelpIDs = (DWORD_PTR)a198HelpIDs;
  43. m_uTemplateResID = IDD;
  44. }
  45. CAttrObject::~CAttrObject()
  46. {
  47. if (::IsWindow(m_hwndInspect))
  48. {
  49. m_pSceInspect->Destroy(m_hwndInspect);
  50. m_hwndInspect = NULL;
  51. }
  52. delete m_pSceInspect;
  53. m_pSceInspect = NULL;
  54. if (::IsWindow(m_hwndTemplate))
  55. {
  56. m_pSceTemplate->Destroy(m_hwndTemplate);
  57. m_hwndTemplate = NULL;
  58. }
  59. delete m_pSceTemplate;
  60. m_pSceTemplate = NULL;
  61. }
  62. void CAttrObject::DoDataExchange(CDataExchange* pDX)
  63. {
  64. CAttribute::DoDataExchange(pDX);
  65. //{{AFX_DATA_MAP(CAttrObject)
  66. DDX_Text(pDX, IDC_INSPECTED, m_strLastInspect);
  67. DDX_Radio(pDX, IDC_CONFIG, m_radConfigPrevent);
  68. DDX_Radio(pDX, IDC_INHERIT, m_radInheritOverwrite);
  69. //}}AFX_DATA_MAP
  70. }
  71. BEGIN_MESSAGE_MAP(CAttrObject, CAttribute)
  72. //{{AFX_MSG_MAP(CAttrObject)
  73. ON_BN_CLICKED(IDC_TEMPLATE_SECURITY, OnTemplateSecurity)
  74. ON_BN_CLICKED(IDC_INSPECTED_SECURITY, OnInspectedSecurity)
  75. ON_BN_CLICKED(IDC_CONFIGURE, OnConfigure)
  76. ON_BN_CLICKED(IDC_CONFIG, OnConfig)
  77. ON_BN_CLICKED(IDC_PREVENT, OnPrevent)
  78. ON_BN_CLICKED(IDC_OVERWRITE, OnOverwrite)
  79. ON_BN_CLICKED(IDC_INHERIT, OnInherit)
  80. //}}AFX_MSG_MAP
  81. END_MESSAGE_MAP()
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CAttrObject message handlers
  84. void CAttrObject::OnConfigure()
  85. {
  86. CAttribute::OnConfigure();
  87. if ( m_bConfigure ) {
  88. //
  89. // Ensure that the security descriptor is set.
  90. //
  91. if( !m_pNewSD ){
  92. OnTemplateSecurity();
  93. }
  94. UpdateData(FALSE);
  95. }
  96. BOOL bEnable = TRUE;
  97. if(m_pFolder){
  98. DWORD dwStatus = 0;
  99. m_pFolder->GetObjectInfo( &dwStatus, NULL );
  100. switch( dwStatus ){
  101. case SCE_STATUS_NOT_ANALYZED:
  102. case SCE_STATUS_ERROR_NOT_AVAILABLE:
  103. case SCE_STATUS_NOT_CONFIGURED:
  104. bEnable = FALSE;
  105. break;
  106. default:
  107. bEnable = m_pAnalSD || m_AnalInfo;
  108. }
  109. } else {
  110. bEnable = m_pAnalSD || m_AnalInfo;
  111. }
  112. if (m_bConfigure) {
  113. if (0 == m_radConfigPrevent) {
  114. OnConfig();
  115. } else {
  116. OnPrevent();
  117. }
  118. }
  119. }
  120. void CAttrObject::Initialize(CFolder *pFolder,
  121. CComponentDataImpl *pCDI) {
  122. CAttribute::Initialize(NULL);
  123. m_strName = pFolder->GetName();
  124. m_strPath = pFolder->GetName();
  125. m_dwType = pFolder->GetType();
  126. switch (pFolder->GetType()) {
  127. case REG_OBJECTS:
  128. m_dwType = ITEM_REGSD;
  129. break;
  130. case FILE_OBJECTS:
  131. m_dwType = ITEM_FILESD;
  132. break;
  133. default:
  134. m_dwType = 0;
  135. break;
  136. }
  137. m_pObject = (PSCE_OBJECT_LIST)pFolder->GetData();
  138. m_pHandle = pCDI->GetSadHandle();
  139. m_pCDI = pCDI;
  140. m_pFolder = pFolder;
  141. Initialize2();
  142. }
  143. void CAttrObject::Initialize(CResult *pResult) {
  144. CAttribute::Initialize(pResult);
  145. m_strName = pResult->GetAttr();
  146. m_strPath = pResult->GetUnits();
  147. m_pHandle = (HANDLE)pResult->GetID();
  148. m_dwType = pResult->GetType();
  149. m_pObject = (PSCE_OBJECT_LIST)pResult->GetBaseProfile();
  150. m_pCDI = NULL;
  151. Initialize2();
  152. }
  153. void CAttrObject::Initialize2()
  154. {
  155. LPTSTR szPath;
  156. SCESTATUS status;
  157. AREA_INFORMATION Area;
  158. switch (m_dwType) {
  159. case ITEM_REGSD:
  160. Area = AREA_REGISTRY_SECURITY;
  161. break;
  162. case ITEM_FILESD:
  163. Area = AREA_FILE_SECURITY;
  164. break;
  165. default:
  166. ASSERT(FALSE);
  167. return;
  168. }
  169. m_pNewSD = NULL;
  170. m_NewSeInfo = 0;
  171. if ( m_pSI ) {
  172. m_pSI->Release();
  173. m_pSI = NULL;
  174. }
  175. m_pfnCreateDsPage=NULL;
  176. szPath = m_strPath.GetBuffer(1);
  177. status = SceGetObjectSecurity(m_pHandle,
  178. SCE_ENGINE_SMP,
  179. Area,
  180. szPath,
  181. &posTemplate);
  182. m_strPath.ReleaseBuffer();
  183. if (SCESTATUS_SUCCESS == status && posTemplate ) {
  184. switch (posTemplate-> Status) {
  185. case SCE_STATUS_IGNORE:
  186. m_radConfigPrevent = 1;
  187. m_radInheritOverwrite = 0;
  188. break;
  189. case SCE_STATUS_OVERWRITE:
  190. m_radConfigPrevent = 0;
  191. m_radInheritOverwrite = 1;
  192. break;
  193. case SCE_STATUS_CHECK:
  194. m_radConfigPrevent = 0;
  195. m_radInheritOverwrite = 0;
  196. break;
  197. default:
  198. case SCE_STATUS_NO_AUTO_INHERIT:
  199. m_radConfigPrevent = 1;
  200. m_radInheritOverwrite = 0;
  201. break;
  202. }
  203. if ( posTemplate->pSecurityDescriptor ) {
  204. MyMakeSelfRelativeSD(posTemplate->pSecurityDescriptor,
  205. &m_pNewSD);
  206. }
  207. m_NewSeInfo = posTemplate->SeInfo;
  208. } else {
  209. m_bConfigure = FALSE;
  210. }
  211. szPath = m_strPath.GetBuffer(1);
  212. status = SceGetObjectSecurity(m_pHandle,
  213. SCE_ENGINE_SAP,
  214. Area,
  215. szPath,
  216. &posInspect);
  217. m_strPath.ReleaseBuffer();
  218. //
  219. // Display the same thing we displayed on the result pane
  220. //
  221. if (m_pFolder) {
  222. m_pFolder->GetDisplayName( m_strLastInspect, 1 );
  223. } else if (m_pData) {
  224. m_pData->GetDisplayName(0, m_strLastInspect, 1);
  225. } else {
  226. ASSERT(0);
  227. m_strLastInspect.LoadString(IDS_ERROR_VALUE);
  228. }
  229. //
  230. // if the item is good, there will be no SAP record, but a template record exists.
  231. //
  232. if ( posInspect ) {
  233. m_pAnalSD = posInspect->pSecurityDescriptor;
  234. m_AnalInfo = posInspect->SeInfo;
  235. //
  236. // We don't need to display children not configured in the dialog box.
  237. // Instead display the actual status of the item.
  238. //
  239. if( posInspect->Status == SCE_STATUS_CHILDREN_CONFIGURED) {
  240. m_strLastInspect.LoadString(IDS_NOT_CONFIGURED);
  241. }
  242. switch(posInspect->Status &
  243. ~(SCE_STATUS_PERMISSION_MISMATCH | SCE_STATUS_AUDIT_MISMATCH)) {
  244. case SCE_STATUS_CHILDREN_CONFIGURED:
  245. case SCE_STATUS_NOT_CONFIGURED:
  246. case SCE_STATUS_ERROR_NOT_AVAILABLE:
  247. case SCE_STATUS_NEW_SERVICE:
  248. case SCE_STATUS_NOT_ANALYZED:
  249. m_bNotAnalyzed = TRUE;
  250. break;
  251. }
  252. } else if ( posTemplate ) {
  253. m_pAnalSD = posTemplate->pSecurityDescriptor;
  254. m_AnalInfo = posTemplate->SeInfo;
  255. } else {
  256. m_bNotAnalyzed = TRUE;
  257. }
  258. }
  259. void CAttrObject::OnInspectedSecurity()
  260. {
  261. SE_OBJECT_TYPE SeType;
  262. //
  263. // If we already have the inspected security window up then
  264. // don't bring up a second.
  265. //
  266. if (IsWindow(m_hwndInspect)) {
  267. ::BringWindowToTop(m_hwndInspect);
  268. return;
  269. }
  270. switch (m_dwType) {
  271. case ITEM_REGSD:
  272. SeType = SE_REGISTRY_KEY;
  273. break;
  274. case ITEM_FILESD:
  275. SeType = SE_FILE_OBJECT;
  276. break;
  277. default:
  278. ASSERT(FALSE);
  279. return;
  280. }
  281. if ( m_pAnalSD || m_AnalInfo ) {
  282. INT_PTR nRet;
  283. if ( SE_DS_OBJECT == SeType ) {
  284. if ( !m_pfnCreateDsPage ) {
  285. if (!g_hDsSecDll)
  286. g_hDsSecDll = LoadLibrary(TEXT("dssec.dll"));
  287. if ( g_hDsSecDll) {
  288. m_pfnCreateDsPage = (PFNDSCREATEISECINFO)GetProcAddress(g_hDsSecDll,
  289. "DSCreateISecurityInfoObject");
  290. }
  291. }
  292. if ( m_pfnCreateDsPage ) {
  293. nRet= MyCreateDsSecurityPage(&m_pSI,
  294. m_pfnCreateDsPage,
  295. &m_pAnalSD,
  296. &m_AnalInfo,
  297. (LPCTSTR)(m_strName),
  298. ANALYSIS_SECURITY_PAGE_READ_ONLY,
  299. GetSafeHwnd());
  300. } else
  301. nRet = -1;
  302. } else {
  303. BOOL bContainer = TRUE; //Raid #585312, yanggao
  304. if ( SE_FILE_OBJECT == SeType )
  305. {
  306. if ( m_pObject )
  307. {
  308. bContainer = m_pObject->IsContainer;
  309. }
  310. else
  311. {
  312. if( NULL == m_pFolder )
  313. {
  314. bContainer = FALSE;
  315. }
  316. }
  317. }
  318. if (NULL == m_pSceInspect)
  319. {
  320. m_pSceInspect = new CModelessSceEditor(bContainer ? true : false,
  321. ANALYSIS_SECURITY_PAGE_READ_ONLY,
  322. GetSafeHwnd(),
  323. SeType,
  324. m_strName);
  325. }
  326. if (NULL != m_pSceInspect)
  327. m_pSceInspect->Create(&m_pAnalSD, &m_AnalInfo, &m_hwndInspect);
  328. }
  329. /*
  330. BUG 147087 - don't display message, since this may have been canceled
  331. if (NULL == m_hwndInspect) {
  332. CString str;
  333. str.LoadString(IDS_CANT_SHOW_SECURITY);
  334. AfxMessageBox(str);
  335. }
  336. */
  337. }
  338. }
  339. void CAttrObject::OnTemplateSecurity()
  340. {
  341. SE_OBJECT_TYPE SeType;
  342. //
  343. // If we already have the inspected security window up then
  344. // don't bring up a second.
  345. //
  346. if (IsWindow(m_hwndTemplate)) {
  347. ::BringWindowToTop(m_hwndTemplate);
  348. return;
  349. }
  350. switch (m_dwType) {
  351. case ITEM_REGSD:
  352. SeType = SE_REGISTRY_KEY;
  353. break;
  354. case ITEM_FILESD:
  355. SeType = SE_FILE_OBJECT;
  356. break;
  357. default:
  358. ASSERT(FALSE);
  359. return;
  360. }
  361. INT_PTR nRet;
  362. nRet = -1;
  363. if ( SE_DS_OBJECT == SeType ) {
  364. if ( !m_pfnCreateDsPage ) {
  365. if (!g_hDsSecDll)
  366. g_hDsSecDll = LoadLibrary(TEXT("dssec.dll"));
  367. if ( g_hDsSecDll) {
  368. m_pfnCreateDsPage = (PFNDSCREATEISECINFO)GetProcAddress(g_hDsSecDll,
  369. "DSCreateISecurityInfoObject");
  370. }
  371. }
  372. if ( m_pfnCreateDsPage ) {
  373. nRet= MyCreateDsSecurityPage(&m_pSI,
  374. m_pfnCreateDsPage,
  375. &m_pNewSD,
  376. &m_NewSeInfo,
  377. (LPCTSTR)(m_strName),
  378. CONFIG_SECURITY_PAGE,
  379. GetSafeHwnd());
  380. } else
  381. nRet = -1;
  382. } else {
  383. BOOL bContainer = TRUE;
  384. if ( !m_pNewSD ) {
  385. //
  386. // if SD is NULL, then inherit is set.
  387. //
  388. DWORD SDSize;
  389. if ( SE_FILE_OBJECT == SeType ) {
  390. GetDefaultFileSecurity(&m_pNewSD,&m_NewSeInfo);
  391. } else {
  392. GetDefaultRegKeySecurity(&m_pNewSD,&m_NewSeInfo);
  393. }
  394. }
  395. // use m_pSceTemplate to create a modeless
  396. if (NULL == m_pSceTemplate)
  397. {
  398. m_pSceTemplate = new CModelessSceEditor(TRUE,
  399. CONFIG_SECURITY_PAGE,
  400. GetSafeHwnd(),
  401. SeType,
  402. m_strName);
  403. }
  404. if (NULL != m_pSceTemplate)
  405. m_pSceTemplate->Create(&m_pNewSD, &m_NewSeInfo, &m_hwndTemplate);
  406. }
  407. if (NULL == m_hwndTemplate ) {
  408. /*
  409. BUG 147098 - don't display message, since this may have been canceled
  410. CString str;
  411. str.LoadString(IDS_CANT_ASSIGN_SECURITY);
  412. AfxMessageBox(str);
  413. */
  414. } else {
  415. SetModified(TRUE);
  416. }
  417. }
  418. BOOL CAttrObject::OnInitDialog()
  419. {
  420. CAttribute::OnInitDialog();
  421. GetDlgItem(IDC_INSPECTED_SECURITY)->EnableWindow(!m_bNotAnalyzed);
  422. UpdateData(FALSE);
  423. AddUserControl(IDC_OVERWRITE);
  424. AddUserControl(IDC_INHERIT);
  425. AddUserControl(IDC_CONFIG);
  426. AddUserControl(IDC_PREVENT);
  427. AddUserControl(IDC_TEMPLATE_SECURITY);
  428. // AddUserControl(IDC_INSPECTED_SECURITY);
  429. OnConfigure();
  430. if (ITEM_REGSD == m_dwType) {
  431. CString str;
  432. str.LoadString(IDS_REGISTRY_CONFIGURE);
  433. SetDlgItemText(IDC_CONFIG,str);
  434. str.LoadString(IDS_REGISTRY_APPLY);
  435. SetDlgItemText(IDC_OVERWRITE,str);
  436. str.LoadString(IDS_REGISTRY_INHERIT);
  437. SetDlgItemText(IDC_INHERIT,str);
  438. str.LoadString(IDS_REGISTRY_PREVENT);
  439. SetDlgItemText(IDC_PREVENT,str);
  440. }
  441. if (m_bConfigure) {
  442. if (0 == m_radConfigPrevent) {
  443. OnConfig();
  444. } else {
  445. OnPrevent();
  446. }
  447. }
  448. return TRUE; // return TRUE unless you set the focus to a control
  449. // EXCEPTION: OCX Property Pages should return FALSE
  450. }
  451. BOOL CAttrObject::OnApply()
  452. {
  453. // OnQueryCancel does all gestures and returns false if child windows are up
  454. if (!OnQueryCancel())
  455. return FALSE;
  456. if ( !m_bReadOnly )
  457. {
  458. LPTSTR szPath;
  459. UpdateData(TRUE);
  460. AREA_INFORMATION Area = 0;
  461. switch (m_dwType) {
  462. case ITEM_REGSD:
  463. Area = AREA_REGISTRY_SECURITY;
  464. break;
  465. case ITEM_FILESD:
  466. Area = AREA_FILE_SECURITY;
  467. break;
  468. default:
  469. ASSERT(FALSE);
  470. }
  471. if ( (NULL != m_pHandle) && (0 != Area) ) {
  472. SCESTATUS sceStatus=SCESTATUS_SUCCESS;
  473. BYTE status;
  474. if ( (m_pSnapin && m_pSnapin->CheckEngineTransaction()) ||
  475. (m_pCDI && m_pCDI->EngineTransactionStarted()) ) {
  476. if (!m_bConfigure ) {
  477. if ( NULL != posTemplate ) {
  478. BOOL bContainer;
  479. if ( m_pObject ) {
  480. bContainer = m_pObject->IsContainer;
  481. } else {
  482. bContainer = TRUE;
  483. }
  484. //
  485. // delete the SMP entry
  486. //
  487. szPath = m_strPath.GetBuffer(1);
  488. sceStatus = SceUpdateObjectInfo(
  489. m_pHandle,
  490. Area,
  491. szPath,
  492. wcslen(szPath),
  493. (BYTE)SCE_NO_VALUE,
  494. bContainer,
  495. NULL,
  496. 0,
  497. &status
  498. );
  499. m_strPath.ReleaseBuffer();
  500. /*
  501. if ( SCESTATUS_SUCCESS == sceStatus &&
  502. (BYTE)SCE_NO_VALUE != status &&
  503. (DWORD)SCE_NO_VALUE != (DWORD)status ) {
  504. */
  505. if (SCESTATUS_SUCCESS == sceStatus) {
  506. if ((BYTE) SCE_NO_VALUE == status) {
  507. status = SCE_STATUS_NOT_CONFIGURED;
  508. }
  509. if (m_pData) {
  510. m_pData->SetStatus(status);
  511. }
  512. if ( m_pObject ) {
  513. m_pObject->Status = status;
  514. }
  515. }
  516. }
  517. } else {
  518. BYTE dw;
  519. switch (m_radConfigPrevent) {
  520. case 0:
  521. // config
  522. switch(m_radInheritOverwrite) {
  523. case 0:
  524. // inherit
  525. dw = SCE_STATUS_CHECK;
  526. break;
  527. case 1:
  528. // overwrite
  529. dw = SCE_STATUS_OVERWRITE;
  530. break;
  531. }
  532. break;
  533. case 1:
  534. // prevent
  535. dw = SCE_STATUS_IGNORE;
  536. break;
  537. }
  538. szPath = m_strPath.GetBuffer(1);
  539. sceStatus = SceUpdateObjectInfo(
  540. m_pHandle,
  541. Area,
  542. szPath,
  543. wcslen(szPath),
  544. dw,
  545. TRUE, //IsContainer
  546. m_pNewSD,
  547. m_NewSeInfo,
  548. &status
  549. );
  550. status = SCE_STATUS_NOT_ANALYZED;
  551. m_strPath.ReleaseBuffer();
  552. //
  553. // This should never happen, but does because
  554. // of engine bugs
  555. //
  556. if ((BYTE) SCE_NO_VALUE == status) {
  557. status = SCE_STATUS_NOT_CONFIGURED;
  558. }
  559. if (SCESTATUS_SUCCESS == sceStatus) {
  560. if (m_pData) {
  561. m_pData->SetStatus(status);
  562. }
  563. if ( m_pObject ) {
  564. m_pObject->Status = status;
  565. }
  566. }
  567. }
  568. if(m_pFolder){
  569. //
  570. // Update status information.
  571. //
  572. m_pCDI->UpdateObjectStatus( m_pFolder, TRUE );
  573. }
  574. } else {
  575. sceStatus = SCESTATUS_OTHER_ERROR;
  576. }
  577. if ( SCESTATUS_SUCCESS == sceStatus ) {
  578. PEDITTEMPLATE pet=NULL;
  579. if (m_pSnapin) {
  580. pet = m_pSnapin->GetTemplate(GT_COMPUTER_TEMPLATE,Area);
  581. } else if (m_pCDI) {
  582. pet = m_pCDI->GetTemplate(GT_COMPUTER_TEMPLATE,Area);
  583. }
  584. if ( pet ) {
  585. pet->SetDirty(Area);
  586. }
  587. if (m_pData) {
  588. m_pData->Update(m_pSnapin);
  589. }
  590. } else {
  591. CString str,strBase; //Raid #494798, yanggao
  592. strBase.LoadString(IDS_SAVE_FAILED);
  593. strBase += L"it.";
  594. MyFormatMessage(sceStatus,strBase,NULL,str);
  595. AfxMessageBox(str);
  596. return FALSE;
  597. }
  598. }
  599. SceFreeMemory((PVOID)posTemplate, SCE_STRUCT_OBJECT_SECURITY);
  600. posTemplate = NULL;
  601. SceFreeMemory((PVOID)posInspect, SCE_STRUCT_OBJECT_SECURITY);
  602. posInspect = NULL;
  603. if ( m_pNewSD ) {
  604. LocalFree(m_pNewSD);
  605. m_pNewSD = NULL;
  606. }
  607. m_NewSeInfo = 0;
  608. m_pAnalSD=NULL;
  609. m_AnalInfo=0;
  610. m_hwndParent = NULL;
  611. if ( m_pSI ) {
  612. m_pSI->Release();
  613. m_pSI = NULL;
  614. }
  615. m_pfnCreateDsPage=NULL;
  616. }
  617. return CAttribute::OnApply();
  618. }
  619. void CAttrObject::OnCancel()
  620. {
  621. SceFreeMemory((PVOID)posTemplate, SCE_STRUCT_OBJECT_SECURITY);
  622. posTemplate = NULL;
  623. SceFreeMemory((PVOID)posInspect, SCE_STRUCT_OBJECT_SECURITY);
  624. posInspect = NULL;
  625. if ( m_pNewSD ) {
  626. LocalFree(m_pNewSD);
  627. m_pNewSD = NULL;
  628. }
  629. m_NewSeInfo = 0;
  630. m_pAnalSD=NULL;
  631. m_AnalInfo=0;
  632. m_hwndParent = NULL;
  633. if ( m_pSI ) {
  634. m_pSI->Release();
  635. m_pSI = NULL;
  636. }
  637. m_pfnCreateDsPage=NULL;
  638. CAttribute::OnCancel();
  639. }
  640. void CAttrObject::OnConfig()
  641. {
  642. CWnd *pRadio;
  643. pRadio = GetDlgItem(IDC_INHERIT);
  644. pRadio->EnableWindow(TRUE);
  645. pRadio = GetDlgItem(IDC_OVERWRITE);
  646. pRadio->EnableWindow(TRUE);
  647. int prevValue = m_radConfigPrevent; //Raid #491006, Yanggao
  648. UpdateData();
  649. if(m_radConfigPrevent != prevValue)
  650. {
  651. SetModified(TRUE);
  652. }
  653. GetDlgItem(IDC_TEMPLATE_SECURITY)->EnableWindow(TRUE); //Raid #477266, Yanggao
  654. }
  655. void CAttrObject::OnPrevent()
  656. {
  657. CWnd *pRadio;
  658. pRadio = GetDlgItem(IDC_INHERIT);
  659. pRadio->EnableWindow(FALSE);
  660. pRadio = GetDlgItem(IDC_OVERWRITE);
  661. pRadio->EnableWindow(FALSE);
  662. int prevValue = m_radConfigPrevent; //Raid #491006, Yanggao
  663. UpdateData();
  664. if(m_radConfigPrevent != prevValue)
  665. {
  666. SetModified(TRUE);
  667. }
  668. GetDlgItem(IDC_TEMPLATE_SECURITY)->EnableWindow(FALSE); //Raid #477266, Yanggao
  669. }
  670. void CAttrObject::OnOverwrite()
  671. {
  672. int prevValue = m_radInheritOverwrite; //Raid #491006, Yanggao
  673. UpdateData();
  674. if(m_radInheritOverwrite != prevValue)
  675. {
  676. SetModified(TRUE);
  677. }
  678. }
  679. void CAttrObject::OnInherit()
  680. {
  681. int prevValue = m_radInheritOverwrite; //Raid #491006, Yanggao
  682. UpdateData();
  683. if(m_radInheritOverwrite != prevValue)
  684. {
  685. SetModified(TRUE);
  686. }
  687. }
  688. //------------------------------------------------------------------
  689. // override to prevent the sheet from being destroyed when there is
  690. // child dialogs still up and running.
  691. //------------------------------------------------------------------
  692. BOOL CAttrObject::OnQueryCancel()
  693. {
  694. if (::IsWindow(m_hwndInspect) || ::IsWindow(m_hwndTemplate))
  695. {
  696. CString strMsg;
  697. strMsg.LoadString(IDS_CLOSESUBSHEET_BEFORE_APPLY);
  698. AfxMessageBox(strMsg);
  699. return FALSE;
  700. }
  701. else
  702. return TRUE;
  703. }