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.

1306 lines
43 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000 - 2001.
  5. //
  6. // File: AttrMap.cpp
  7. //
  8. // Contents: Attribute maps to define a property page
  9. //
  10. // History: 8-2001 Hiteshr Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "headers.h"
  14. //+----------------------------------------------------------------------------
  15. // Function:InitOneAttribute
  16. // Synopsis: Initializes one attribute defined by pAttrMapEntry
  17. // Arguments:pBaseAz: BaseAz object whose attribute is to be initialized
  18. // pAttrMapEntry: Map entry defining the attribute
  19. // bDlgReadOnly: If dialog box is readonly
  20. // pWnd: Control Associated with attribute
  21. // bNewObject: If the object is a newly created object.
  22. // pbErrorDisplayed: Is Error Displayed by this function
  23. // Returns:
  24. // Note: if Object is newly created, we directly set the value,
  25. // For existing objects, get the current value of attribute and
  26. // only if its different from new value, set it.
  27. //-----------------------------------------------------------------------------
  28. HRESULT
  29. InitOneAttribute(IN CDialog *pDlg,
  30. IN CBaseAz * pBaseAz,
  31. IN ATTR_MAP* pAttrMap,
  32. IN BOOL bDlgReadOnly,
  33. IN CWnd* pWnd,
  34. OUT BOOL *pbErrorDisplayed)
  35. {
  36. TRACE_FUNCTION_EX(DEB_SNAPIN,InitOneAttribute)
  37. if(!pDlg || !pAttrMap || !pWnd || !pbErrorDisplayed)
  38. {
  39. //ASSERT(pBaseAz); For New Dialogs this value is null
  40. ASSERT(pDlg);
  41. ASSERT(pAttrMap);
  42. ASSERT(pWnd);
  43. ASSERT(pbErrorDisplayed);
  44. return E_POINTER;
  45. }
  46. HRESULT hr = S_OK;
  47. //If a function is provided, delegate initialization to it.
  48. PATTR_FCN pAttrFcn = pAttrMap->pAttrInitFcn;
  49. if(pAttrFcn)
  50. {
  51. hr = (*pAttrFcn)(pDlg,
  52. pBaseAz,
  53. pAttrMap,
  54. bDlgReadOnly,
  55. pWnd,
  56. !pBaseAz,
  57. pbErrorDisplayed);
  58. CHECK_HRESULT(hr);
  59. return hr;
  60. }
  61. ATTR_INFO* pAttrInfo = &(pAttrMap->attrInfo);
  62. switch (pAttrInfo->attrType)
  63. {
  64. case ARG_TYPE_STR:
  65. {
  66. CEdit* pEdit = (CEdit*)pWnd;
  67. if(pBaseAz)
  68. {
  69. //For existing object, Get the value of attribute and
  70. //set it in the control
  71. CString strValue;
  72. hr = pBaseAz->GetProperty(pAttrInfo->ulPropId, &strValue);
  73. BREAK_ON_FAIL_HRESULT(hr);
  74. pEdit->SetWindowText(strValue);
  75. }
  76. else if(pAttrMap->bDefaultValue)
  77. {
  78. //For new objects, if default value is provided for
  79. //the attribute, set it in the control
  80. CString strValue;
  81. if(IS_INTRESOURCE(pAttrMap->pszValue))
  82. VERIFY(strValue.LoadString((ULONG)((ULONG_PTR)pAttrMap->pszValue)));
  83. else
  84. strValue = pAttrMap->pszValue;
  85. pEdit->SetWindowText(strValue);
  86. }
  87. if(pAttrMap->bReadOnly || bDlgReadOnly)
  88. pEdit->SetReadOnly(TRUE);
  89. if(pAttrInfo->ulMaxLen)
  90. pEdit->SetLimitText(pAttrInfo->ulMaxLen);
  91. break;
  92. }
  93. case ARG_TYPE_LONG:
  94. {
  95. CEdit* pEdit = (CEdit*)pWnd;
  96. if(pBaseAz)
  97. {
  98. LONG lValue;
  99. hr = pBaseAz->GetProperty(pAttrInfo->ulPropId, &lValue);
  100. BREAK_ON_FAIL_HRESULT(hr);
  101. SetLongValue(pEdit,lValue);
  102. }
  103. else if(pAttrMap->bDefaultValue)
  104. {
  105. SetLongValue(pEdit, pAttrMap->lValue);
  106. }
  107. if(pAttrMap->bReadOnly || bDlgReadOnly)
  108. pEdit->SetReadOnly(TRUE);
  109. if(pAttrInfo->ulMaxLen)
  110. pEdit->SetLimitText(pAttrInfo->ulMaxLen);
  111. break;
  112. }
  113. case ARG_TYPE_BOOL:
  114. {
  115. CButton* pBtn = (CButton*)pWnd;
  116. if(pBaseAz)
  117. {
  118. BOOL bValue;
  119. hr = pBaseAz->GetProperty(pAttrInfo->ulPropId, &bValue);
  120. BREAK_ON_FAIL_HRESULT(hr);
  121. if(bValue)
  122. pBtn->SetCheck(1);
  123. }
  124. if(pAttrMap->bReadOnly || bDlgReadOnly)
  125. {
  126. pBtn->EnableWindow(FALSE);
  127. }
  128. }
  129. }
  130. return hr;
  131. }
  132. //+----------------------------------------------------------------------------
  133. // Function:SaveOneAttribute
  134. // Synopsis:Saves one attribute defined by pAttrMapEntry
  135. // Arguments:pBaseAz: BaseAz object whose attribute is to be saved
  136. // pAttrMapEntry: Map entry defining the attribute
  137. // pWnd: Control Associated with attribute
  138. // bNewObject: If the object is a newly created object.
  139. // pbErrorDisplayed: Is Error Displayed by this function
  140. // Returns:
  141. // Note: if Object is newly created, we directly set the value,
  142. // For existing objects, get the current value of attribute and
  143. // only if its different from new value, set it.
  144. //-----------------------------------------------------------------------------
  145. HRESULT
  146. SaveOneAttribute(CDialog* pDlg,
  147. CBaseAz * pBaseAz,
  148. ATTR_MAP* pAttrMap,
  149. CWnd* pWnd,
  150. BOOL bNewObject,
  151. BOOL *pbErrorDisplayed)
  152. {
  153. TRACE_FUNCTION_EX(DEB_SNAPIN,SaveOneAttribute)
  154. if(!pDlg || !pBaseAz || !pAttrMap || !pWnd || !pbErrorDisplayed)
  155. {
  156. ASSERT(pBaseAz);
  157. ASSERT(pAttrMap);
  158. ASSERT(pWnd);
  159. ASSERT(pbErrorDisplayed);
  160. return E_POINTER;
  161. }
  162. HRESULT hr = S_OK;
  163. //
  164. //bRequired assumes that its EditBox
  165. //
  166. if(pAttrMap->bRequired)
  167. {
  168. if(!((CEdit*)pWnd)->GetWindowTextLength())
  169. {
  170. DisplayError(pDlg->m_hWnd, pAttrMap->idRequired);
  171. *pbErrorDisplayed = TRUE;
  172. SetSel(*(CEdit*)pWnd);
  173. return E_INVALIDARG;
  174. }
  175. }
  176. //
  177. //If a function is provided delegate saving to it.
  178. //
  179. PATTR_FCN pAttrFcn = pAttrMap->pAttrSaveFcn;
  180. if(pAttrFcn)
  181. {
  182. hr = (*pAttrFcn)(pDlg,
  183. pBaseAz,
  184. pAttrMap,
  185. FALSE, //This is ignored by save functions
  186. pWnd,
  187. bNewObject,
  188. pbErrorDisplayed);
  189. CHECK_HRESULT(hr);
  190. return hr;
  191. }
  192. ATTR_INFO* pAttrInfo = &(pAttrMap->attrInfo);
  193. switch (pAttrInfo->attrType)
  194. {
  195. case ARG_TYPE_STR:
  196. {
  197. CString strNewValue;
  198. CEdit* pEdit = (CEdit*)pWnd;
  199. pEdit->GetWindowText(strNewValue);
  200. if(!bNewObject)
  201. {
  202. //
  203. //For existing object save the attribute value only if it has
  204. //changed
  205. //
  206. CString strOldValue;
  207. hr = pBaseAz->GetProperty(pAttrInfo->ulPropId, &strOldValue);
  208. BREAK_ON_FAIL_HRESULT(hr);
  209. if(strOldValue == strNewValue)
  210. break;
  211. }
  212. hr = pBaseAz->SetProperty(pAttrInfo->ulPropId, strNewValue);
  213. CHECK_HRESULT(hr);
  214. break;
  215. }
  216. case ARG_TYPE_LONG:
  217. {
  218. CString strNewValue;
  219. CEdit* pEdit = (CEdit*)pWnd;
  220. pEdit->GetWindowText(strNewValue);
  221. LONG lNewValue;
  222. if(!ConvertStringToLong(strNewValue,lNewValue,pDlg->m_hWnd))
  223. {
  224. if(pbErrorDisplayed)
  225. *pbErrorDisplayed = TRUE;
  226. SetSel(*(CEdit*)pWnd);
  227. return E_INVALIDARG;
  228. }
  229. lNewValue = _wtol(strNewValue);
  230. if(!bNewObject)
  231. {
  232. //
  233. //For existing object save the attribute value only if it has
  234. //changed
  235. //
  236. LONG lOldValue;
  237. hr = pBaseAz->GetProperty(pAttrInfo->ulPropId, &lOldValue);
  238. BREAK_ON_FAIL_HRESULT(hr);
  239. if(lNewValue == lOldValue)
  240. break;
  241. }
  242. hr = pBaseAz->SetProperty(pAttrInfo->ulPropId, lNewValue);
  243. CHECK_HRESULT(hr);
  244. break;
  245. }
  246. case ARG_TYPE_BOOL:
  247. {
  248. BOOL bNewValue;
  249. CButton* pCheckBox = (CButton*)pWnd;
  250. bNewValue = pCheckBox->GetCheck();
  251. if(!bNewObject)
  252. {
  253. BOOL bOldValue;
  254. hr = pBaseAz->GetProperty(pAttrInfo->ulPropId, &bOldValue);
  255. BREAK_ON_FAIL_HRESULT(hr);
  256. if(bNewValue == bOldValue)
  257. break;
  258. }
  259. hr = pBaseAz->SetProperty(pAttrInfo->ulPropId, bNewValue);
  260. CHECK_HRESULT(hr);
  261. break;
  262. }
  263. }
  264. return hr;
  265. }
  266. //+----------------------------------------------------------------------------
  267. // Function:InitDlgFromAttrMap
  268. // Synopsis:Initializes Dialog box from Attribute Map
  269. // Arguments:
  270. // pDlg: Dialog Box
  271. // pAttrMap: Attribute Map
  272. // pBaseAz: BaseAz object corresponding to attribute map
  273. // bDlgReadOnly: Dialog box is in Readonly Mode
  274. //-----------------------------------------------------------------------------
  275. BOOL
  276. InitDlgFromAttrMap(IN CDialog* pDlg,
  277. IN ATTR_MAP* pAttrMap,
  278. IN CBaseAz* pBaseAz,
  279. IN BOOL bDlgReadOnly)
  280. {
  281. if(!pDlg || !pAttrMap)
  282. {
  283. ASSERT(pDlg);
  284. //ASSERT(pBaseAz); //For new objects this value is null
  285. ASSERT(pAttrMap);
  286. return FALSE;
  287. }
  288. HRESULT hr = S_OK;
  289. BOOL bErrorDisplayed;
  290. while(pAttrMap->nControlId)
  291. {
  292. CWnd* pWnd = pDlg->GetDlgItem(pAttrMap->nControlId);
  293. if(!pWnd)
  294. {
  295. ASSERT(pWnd);
  296. hr = E_UNEXPECTED;
  297. break;
  298. }
  299. hr = InitOneAttribute(pDlg,
  300. pBaseAz,
  301. pAttrMap,
  302. bDlgReadOnly,
  303. pWnd,
  304. &bErrorDisplayed);
  305. if(FAILED(hr))
  306. {
  307. return FALSE;
  308. }
  309. pAttrMap++;
  310. }
  311. return TRUE;
  312. }
  313. //+----------------------------------------------------------------------------
  314. // Function:SaveAttrMapChanges
  315. // Synopsis:Saves the attributes defined in AttrMap
  316. // Arguments:pDlg: Dialog box
  317. // pAttrMap: Attribute Map
  318. // pBaseAz: BaseAz object corresponding to attribute map
  319. // bNewObject if the object is new created
  320. // pbErrorDisplayed: Is Error Displayed by this function
  321. // ppErrorAttrMapEntry: In case of failuer get pointer to error
  322. // Attribute Map Entry.
  323. // Returns:
  324. //-----------------------------------------------------------------------------
  325. HRESULT
  326. SaveAttrMapChanges(IN CDialog* pDlg,
  327. IN ATTR_MAP* pAttrMap,
  328. IN CBaseAz* pBaseAz,
  329. IN BOOL bNewObject,
  330. OUT BOOL *pbErrorDisplayed,
  331. OUT ATTR_MAP** ppErrorAttrMap)
  332. {
  333. if(!pDlg || !pAttrMap || !pBaseAz || !pbErrorDisplayed )
  334. {
  335. ASSERT(pDlg);
  336. ASSERT(pBaseAz);
  337. ASSERT(pAttrMap);
  338. ASSERT(pbErrorDisplayed);
  339. return E_POINTER;
  340. }
  341. HRESULT hr = S_OK;
  342. while(pAttrMap->nControlId)
  343. {
  344. CWnd* pWnd = pDlg->GetDlgItem(pAttrMap->nControlId);
  345. if(!pWnd)
  346. {
  347. ASSERT(pWnd);
  348. hr = E_UNEXPECTED;
  349. break;
  350. }
  351. if(pAttrMap->bReadOnly || pAttrMap->bUseForInitOnly)
  352. {
  353. ++pAttrMap;
  354. continue;
  355. }
  356. //
  357. //Save this attribute
  358. //
  359. hr = SaveOneAttribute(pDlg,
  360. pBaseAz,
  361. pAttrMap,
  362. pWnd,
  363. bNewObject,
  364. pbErrorDisplayed);
  365. if(FAILED(hr))
  366. {
  367. if(ppErrorAttrMap)
  368. *ppErrorAttrMap = pAttrMap;
  369. return hr;
  370. }
  371. ++pAttrMap;
  372. }
  373. return S_OK;
  374. }
  375. #define CMD_TYPE void*
  376. #define DECLARE_ATTR_FN(fnname) \
  377. HRESULT fnname(CDialog *pDlg, \
  378. CBaseAz* pBaseAz, \
  379. ATTR_MAP * pAttrMap, \
  380. BOOL bDlgReadOnly, \
  381. CWnd* pWnd, \
  382. BOOL bNewObject, \
  383. BOOL *bpSilent);
  384. #define ATTR_MAP_ENTRY(attrType, \
  385. ulPropId, \
  386. ulMaxLen, \
  387. bReadOnly, \
  388. bUsedForInitOnly, \
  389. bRequired, \
  390. idRequired, \
  391. bDefaultValue, \
  392. value, \
  393. nControlId, \
  394. pAttrInitFcn, \
  395. pAttrSaveFcn) \
  396. {{attrType,ulPropId,ulMaxLen}, \
  397. bReadOnly, \
  398. bUsedForInitOnly, \
  399. bRequired, \
  400. idRequired, \
  401. bDefaultValue, \
  402. value, \
  403. nControlId, \
  404. pAttrInitFcn, \
  405. pAttrSaveFcn}
  406. #define ATTR_END_ENTRY ATTR_MAP_ENTRY(((ATTR_TYPE)0),0,0,0,0,0,0,0,0,0,0,0)
  407. #define ATTR_NORMAL_STRING_ENTRY( ulPropId, ulMaxLen, bReadOnly, nControlId) \
  408. ATTR_MAP_ENTRY(ARG_TYPE_STR,ulPropId,ulMaxLen,bReadOnly,FALSE,FALSE,0,FALSE,0,nControlId,NULL,NULL)
  409. #define ATTR_NORMAL_STRING_ENTRY_WITH_INIT_FP( ulPropId, ulMaxLen, bReadOnly, nControlId, fp) \
  410. ATTR_MAP_ENTRY(ARG_TYPE_STR,ulPropId,ulMaxLen,bReadOnly,FALSE,FALSE,0,FALSE,0,nControlId,fp,NULL)
  411. #define ATTR_NORMAL_STRING_ENTRY_WITH_SAVE_FP( ulPropId, ulMaxLen, bReadOnly, nControlId, fp) \
  412. ATTR_MAP_ENTRY(ARG_TYPE_STR,ulPropId,ulMaxLen,bReadOnly,FALSE,FALSE,0,FALSE,0,nControlId,NULL,fp)
  413. #define ATTR_REQUIRED_STRING_ENTRY(ulPropId, ulMaxLen, idRequired, nControlId) \
  414. ATTR_MAP_ENTRY(ARG_TYPE_STR,ulPropId,ulMaxLen,FALSE,FALSE,TRUE,idRequired,FALSE,0,nControlId,NULL,NULL)
  415. #define ATTR_REQUIRED_STRING_ENTRY_WITH_SAVE_FP(ulPropId, ulMaxLen, idRequired, nControlId, fp) \
  416. ATTR_MAP_ENTRY(ARG_TYPE_STR,ulPropId,ulMaxLen,FALSE,FALSE,TRUE,idRequired,FALSE,0,nControlId,NULL,fp)
  417. #define ATTR_STRING_ENTRY_FOR_INIT_ONLY(ulMaxLen, nControlId) \
  418. ATTR_MAP_ENTRY(ARG_TYPE_STR,0,ulMaxLen,FALSE,TRUE,FALSE,0,FALSE,0,nControlId,NULL,NULL)
  419. #define ATTR_NORMAL_LONG_ENTRY(ulPropId, bReadOnly, nControlId) \
  420. ATTR_MAP_ENTRY(ARG_TYPE_LONG,ulPropId,0,bReadOnly,FALSE,FALSE,0,FALSE,0,nControlId,NULL, NULL)
  421. #define ATTR_REQUIRED_LONG_ENTRY(ulPropId, idRequired, nControlId) \
  422. ATTR_MAP_ENTRY(ARG_TYPE_LONG,ulPropId,0,FALSE,FALSE,TRUE,idRequired,FALSE,0,nControlId,NULL,NULL)
  423. #define ATTR_REQUIRED_LONG_ENTRY_WITH_SAVE_FP(ulPropId, idRequired, nControlId, fp) \
  424. ATTR_MAP_ENTRY(ARG_TYPE_LONG,ulPropId,0,FALSE,FALSE,TRUE,idRequired,FALSE,0,nControlId,NULL,fp)
  425. #define ATTR_REQUIRED_LONG_ENTRY_WITH_INIT_AND_SAVE_FP(ulPropId, idRequired, nControlId, ifp,sfp) \
  426. ATTR_MAP_ENTRY(ARG_TYPE_LONG,ulPropId,0,FALSE,FALSE,TRUE,idRequired,FALSE,0,nControlId,ifp,sfp)
  427. #define ATTR_REQUIRED_LONG_ENTRY_WITH_DEFAULT(ulPropId, idRequired, lValue, nControlId) \
  428. ATTR_MAP_ENTRY(ARG_TYPE_LONG,ulPropId,0,FALSE,FALSE,TRUE,idRequired,TRUE,(CMD_TYPE)lValue,nControlId,NULL,NULL)
  429. #define ATTR_NORMAL_BOOL_ENTRY(ulPropId, nControlId) \
  430. ATTR_MAP_ENTRY(ARG_TYPE_BOOL,ulPropId, 0, FALSE,FALSE,FALSE,0,FALSE,0,nControlId,NULL,NULL)
  431. //Functions
  432. DECLARE_ATTR_FN(ATTR_INIT_FN_ADMIN_MANAGER_NAME)
  433. DECLARE_ATTR_FN(ATTR_INIT_FN_ADMIN_MANAGER_STORE_TYPE)
  434. DECLARE_ATTR_FN(ATTR_SAVE_FN_NAME)
  435. DECLARE_ATTR_FN(ATTR_INIT_FN_GROUP_TYPE)
  436. DECLARE_ATTR_FN(ATTR_SAVE_FN_OPERATION_ID)
  437. DECLARE_ATTR_FN(ATTR_SAVE_FN_ADMIN_MANAGER_SCRIPT_ENGINE_TIMEOUT)
  438. DECLARE_ATTR_FN(ATTR_INIT_FN_ADMIN_MANAGER_SCRIPT_ENGINE_TIMEOUT)
  439. DECLARE_ATTR_FN(ATTR_SAVE_FN_ADMIN_MANAGER_LDAP_QUERY_TIMEOUT)
  440. #define ATTR_DESCRIPTION \
  441. ATTR_NORMAL_STRING_ENTRY(AZ_PROP_DESCRIPTION,AZ_MAX_DESCRIPTION_LENGTH,FALSE,IDC_EDIT_DESCRIPTION)
  442. //
  443. //ADMIN_MANAGER General Property page entry
  444. //
  445. #define ATTR_ADMIN_MANAGER_NAME \
  446. ATTR_NORMAL_STRING_ENTRY_WITH_INIT_FP(AZ_PROP_NAME, \
  447. AZ_MAX_POLICY_URL_LENGTH, \
  448. TRUE, \
  449. IDC_EDIT_NAME, \
  450. ATTR_INIT_FN_ADMIN_MANAGER_NAME)
  451. #define ATTR_ADMIN_MANAGER_STORE_TYPE \
  452. ATTR_NORMAL_STRING_ENTRY_WITH_INIT_FP(AZ_PROP_NAME, \
  453. 0, \
  454. TRUE, \
  455. IDC_EDIT_STORE_TYPE, \
  456. ATTR_INIT_FN_ADMIN_MANAGER_STORE_TYPE)
  457. ATTR_MAP ATTR_MAP_ADMIN_MANAGER_GENERAL_PROPERTY[] =
  458. {
  459. ATTR_ADMIN_MANAGER_NAME,
  460. ATTR_DESCRIPTION,
  461. ATTR_ADMIN_MANAGER_STORE_TYPE,
  462. ATTR_END_ENTRY,
  463. };
  464. //
  465. //ADMIN_MANAGER new/open dialog entry
  466. //
  467. #define ATTR_NEW_ADMIN_MANAGER_NAME \
  468. ATTR_STRING_ENTRY_FOR_INIT_ONLY(AZ_MAX_POLICY_URL_LENGTH, \
  469. IDC_EDIT_NAME)
  470. #define ATTR_NEW_ADMIN_MANAGER_DESC \
  471. ATTR_STRING_ENTRY_FOR_INIT_ONLY(AZ_MAX_DESCRIPTION_LENGTH, \
  472. IDC_EDIT_NAME)
  473. ATTR_MAP ATTR_MAP_NEW_ADMIN_MANAGER[] =
  474. {
  475. ATTR_NEW_ADMIN_MANAGER_NAME,
  476. ATTR_NEW_ADMIN_MANAGER_DESC,
  477. ATTR_END_ENTRY,
  478. };
  479. ATTR_MAP ATTR_MAP_OPEN_ADMIN_MANAGER[] =
  480. {
  481. ATTR_NEW_ADMIN_MANAGER_NAME,
  482. ATTR_END_ENTRY,
  483. };
  484. //
  485. //ADMIN_MANAGER Advanced Property Page
  486. //
  487. #define ATTR_ADMIN_MANAGER_DOMAIN_TIMEOUT \
  488. ATTR_REQUIRED_LONG_ENTRY_WITH_SAVE_FP(AZ_PROP_AZSTORE_DOMAIN_TIMEOUT, \
  489. IDS_DOMAIN_TIMEOUT_REQUIRED, \
  490. IDC_EDIT_DOMAIN_TIMEOUT, \
  491. ATTR_SAVE_FN_ADMIN_MANAGER_LDAP_QUERY_TIMEOUT)
  492. #define ATTR_ADMIN_MANAGER_SCRIPT_ENGINE_TIMEOUT \
  493. ATTR_REQUIRED_LONG_ENTRY_WITH_INIT_AND_SAVE_FP(AZ_PROP_AZSTORE_SCRIPT_ENGINE_TIMEOUT, \
  494. IDS_SCRIPT_ENGINE_TIMEOUT_REQUIRED, \
  495. IDC_EDIT_SCRIPT_ENGINE_TIMEOUT, \
  496. ATTR_INIT_FN_ADMIN_MANAGER_SCRIPT_ENGINE_TIMEOUT, \
  497. ATTR_SAVE_FN_ADMIN_MANAGER_SCRIPT_ENGINE_TIMEOUT)
  498. #define ATTR_ADMIN_MANAGER_MAX_SCRIPT_ENGINES \
  499. ATTR_REQUIRED_LONG_ENTRY(AZ_PROP_AZSTORE_MAX_SCRIPT_ENGINES, \
  500. IDS_MAX_SCRIPT_ENGINES_REQUIRED, \
  501. IDC_EDIT_MAX_SCRIPT_ENGINE)
  502. ATTR_MAP ATTR_MAP_ADMIN_MANAGER_ADVANCED_PROPERTY[] =
  503. {
  504. ATTR_ADMIN_MANAGER_DOMAIN_TIMEOUT,
  505. ATTR_ADMIN_MANAGER_SCRIPT_ENGINE_TIMEOUT,
  506. ATTR_ADMIN_MANAGER_MAX_SCRIPT_ENGINES,
  507. ATTR_END_ENTRY,
  508. };
  509. //
  510. //APPLICATION General Property Page Entry
  511. //
  512. #define ATTR_APPLICATION_NAME \
  513. ATTR_REQUIRED_STRING_ENTRY_WITH_SAVE_FP(AZ_PROP_NAME, \
  514. AZ_MAX_APPLICATION_NAME_LENGTH, \
  515. IDS_NAME_REQUIRED, \
  516. IDC_EDIT_NAME, \
  517. ATTR_SAVE_FN_NAME)
  518. #define ATTR_APPLICATION_VERSION \
  519. ATTR_NORMAL_STRING_ENTRY(AZ_PROP_APPLICATION_VERSION, \
  520. AZ_MAX_APPLICATION_VERSION_LENGTH, \
  521. FALSE, \
  522. IDC_EDIT_VERSION)
  523. ATTR_MAP ATTR_MAP_APPLICATION_GENERAL_PROPERTY[] =
  524. {
  525. ATTR_APPLICATION_NAME,
  526. ATTR_DESCRIPTION,
  527. ATTR_APPLICATION_VERSION,
  528. ATTR_END_ENTRY,
  529. };
  530. //
  531. //New Application Dlg Map
  532. //
  533. #define ATTR_NEW_APPLICATION_NAME \
  534. ATTR_STRING_ENTRY_FOR_INIT_ONLY(AZ_MAX_APPLICATION_NAME_LENGTH, \
  535. IDC_EDIT_NAME)
  536. ATTR_MAP ATTR_MAP_NEW_APPLICATION[] =
  537. {
  538. ATTR_NEW_APPLICATION_NAME,
  539. ATTR_DESCRIPTION,
  540. ATTR_APPLICATION_VERSION,
  541. ATTR_END_ENTRY,
  542. };
  543. //
  544. //Scope General Property Page Entry
  545. //
  546. #define ATTR_SCOPE_NAME \
  547. ATTR_REQUIRED_STRING_ENTRY_WITH_SAVE_FP(AZ_PROP_NAME, \
  548. AZ_MAX_SCOPE_NAME_LENGTH, \
  549. IDS_NAME_REQUIRED, \
  550. IDC_EDIT_NAME, \
  551. ATTR_SAVE_FN_NAME)
  552. ATTR_MAP ATTR_MAP_SCOPE_GENERAL_PROPERTY[] =
  553. {
  554. ATTR_SCOPE_NAME,
  555. ATTR_DESCRIPTION,
  556. ATTR_END_ENTRY,
  557. };
  558. //
  559. //New SCOPE Dlg Map
  560. //
  561. #define ATTR_NEW_SCOPE_NAME \
  562. ATTR_STRING_ENTRY_FOR_INIT_ONLY(AZ_MAX_SCOPE_NAME_LENGTH, \
  563. IDC_EDIT_NAME)
  564. ATTR_MAP ATTR_MAP_NEW_SCOPE[] =
  565. {
  566. ATTR_NEW_SCOPE_NAME,
  567. ATTR_DESCRIPTION,
  568. ATTR_END_ENTRY,
  569. };
  570. //
  571. //Group General Property Page Entry
  572. //
  573. #define ATTR_GROUP_NAME \
  574. ATTR_REQUIRED_STRING_ENTRY_WITH_SAVE_FP(AZ_PROP_NAME, \
  575. AZ_MAX_GROUP_NAME_LENGTH, \
  576. IDS_NAME_REQUIRED, \
  577. IDC_EDIT_NAME, \
  578. ATTR_SAVE_FN_NAME)
  579. #define ATTR_GROUP_TYPE \
  580. ATTR_NORMAL_STRING_ENTRY_WITH_INIT_FP(AZ_PROP_GROUP_TYPE, \
  581. 0, \
  582. TRUE, \
  583. IDC_EDIT_GROUP_TYPE, \
  584. ATTR_INIT_FN_GROUP_TYPE)
  585. ATTR_MAP ATTR_MAP_GROUP_GENERAL_PROPERTY[] =
  586. {
  587. ATTR_GROUP_NAME,
  588. ATTR_DESCRIPTION,
  589. ATTR_GROUP_TYPE,
  590. ATTR_END_ENTRY,
  591. };
  592. //
  593. //New GROUP Dlg Map
  594. //
  595. #define ATTR_NEW_GROUP_NAME \
  596. ATTR_STRING_ENTRY_FOR_INIT_ONLY(AZ_MAX_GROUP_NAME_LENGTH, \
  597. IDC_EDIT_NAME)
  598. ATTR_MAP ATTR_MAP_NEW_GROUP[] =
  599. {
  600. ATTR_NEW_GROUP_NAME,
  601. ATTR_DESCRIPTION,
  602. ATTR_END_ENTRY,
  603. };
  604. //
  605. //Group LDAP Query Property Page Entry
  606. //
  607. #define ATTR_GROUP_LDAP_QUERY \
  608. ATTR_NORMAL_STRING_ENTRY(AZ_PROP_GROUP_LDAP_QUERY, \
  609. AZ_MAX_GROUP_LDAP_QUERY_LENGTH, \
  610. FALSE, \
  611. IDC_EDIT_LDAP_QUERY)
  612. ATTR_MAP ATTR_MAP_GROUP_QUERY_PROPERTY[] =
  613. {
  614. ATTR_GROUP_LDAP_QUERY,
  615. ATTR_END_ENTRY,
  616. };
  617. //
  618. //Task General Property Page Entry
  619. //
  620. #define ATTR_TASK_NAME \
  621. ATTR_REQUIRED_STRING_ENTRY_WITH_SAVE_FP(AZ_PROP_NAME, \
  622. AZ_MAX_TASK_NAME_LENGTH, \
  623. IDS_NAME_REQUIRED, \
  624. IDC_EDIT_NAME, \
  625. ATTR_SAVE_FN_NAME)
  626. ATTR_MAP ATTR_MAP_TASK_GENERAL_PROPERTY[] =
  627. {
  628. ATTR_TASK_NAME,
  629. ATTR_DESCRIPTION,
  630. ATTR_END_ENTRY,
  631. };
  632. //
  633. //New TASK Dlg Map
  634. //
  635. #define ATTR_NEW_TASK_NAME \
  636. ATTR_STRING_ENTRY_FOR_INIT_ONLY(AZ_MAX_TASK_NAME_LENGTH, \
  637. IDC_EDIT_NAME)
  638. ATTR_MAP ATTR_MAP_NEW_TASK[] =
  639. {
  640. ATTR_NEW_TASK_NAME,
  641. ATTR_DESCRIPTION,
  642. ATTR_END_ENTRY,
  643. };
  644. //
  645. //Role General Property Page
  646. //
  647. #define ATTR_ROLE_NAME \
  648. ATTR_REQUIRED_STRING_ENTRY_WITH_SAVE_FP(AZ_PROP_NAME, \
  649. AZ_MAX_ROLE_NAME_LENGTH, \
  650. IDS_NAME_REQUIRED, \
  651. IDC_EDIT_NAME, \
  652. ATTR_SAVE_FN_NAME)
  653. ATTR_MAP ATTR_MAP_ROLE_GENERAL_PROPERTY[] =
  654. {
  655. ATTR_ROLE_NAME,
  656. ATTR_DESCRIPTION,
  657. ATTR_END_ENTRY,
  658. };
  659. //
  660. //Operation General Property Page Entry
  661. //
  662. #define ATTR_OPERATION_NAME \
  663. ATTR_REQUIRED_STRING_ENTRY_WITH_SAVE_FP(AZ_PROP_NAME, \
  664. AZ_MAX_OPERATION_NAME_LENGTH, \
  665. IDS_NAME_REQUIRED, \
  666. IDC_EDIT_NAME, \
  667. ATTR_SAVE_FN_NAME)
  668. #define ATTR_OPERATION_ID \
  669. ATTR_REQUIRED_LONG_ENTRY_WITH_SAVE_FP(AZ_PROP_OPERATION_ID, \
  670. IDS_OPERATION_ID_REQUIRED, \
  671. IDC_EDIT_OPERATION_NUMBER, \
  672. ATTR_SAVE_FN_OPERATION_ID)
  673. ATTR_MAP ATTR_MAP_OPERATION_GENERAL_PROPERTY[] =
  674. {
  675. ATTR_OPERATION_NAME,
  676. ATTR_DESCRIPTION,
  677. ATTR_OPERATION_ID,
  678. ATTR_END_ENTRY,
  679. };
  680. //
  681. //New Operation Dlg Map
  682. //
  683. #define ATTR_NEW_OPERATION_NAME \
  684. ATTR_STRING_ENTRY_FOR_INIT_ONLY(AZ_MAX_OPERATION_NAME_LENGTH, \
  685. IDC_EDIT_NAME)
  686. ATTR_MAP ATTR_MAP_NEW_OPERATION[] =
  687. {
  688. ATTR_NEW_OPERATION_NAME,
  689. ATTR_DESCRIPTION,
  690. ATTR_OPERATION_ID,
  691. ATTR_END_ENTRY,
  692. };
  693. //
  694. //Script Dialog
  695. //
  696. #define ATTR_SCRIPT_CODE \
  697. ATTR_NORMAL_STRING_ENTRY(AZ_PROP_TASK_BIZRULE, \
  698. AZ_MAX_TASK_BIZRULE_LENGTH, \
  699. TRUE, \
  700. IDC_EDIT_CODE)
  701. #define ATTR_SCRIPT_PATH \
  702. ATTR_NORMAL_STRING_ENTRY(AZ_PROP_TASK_BIZRULE_IMPORTED_PATH, \
  703. AZ_MAX_TASK_BIZRULE_IMPORTED_PATH_LENGTH, \
  704. FALSE, \
  705. IDC_EDIT_PATH)
  706. ATTR_MAP ATTR_MAP_SCRIPT_DIALOG[] =
  707. {
  708. ATTR_SCRIPT_CODE,
  709. ATTR_SCRIPT_PATH,
  710. ATTR_END_ENTRY,
  711. };
  712. HRESULT
  713. ATTR_INIT_FN_ADMIN_MANAGER_NAME(CDialog* /*pDlg*/,
  714. CBaseAz* pBaseAz,
  715. ATTR_MAP * pAttrMap,
  716. BOOL /*bDlgReadOnly*/,
  717. CWnd* pWnd,
  718. BOOL /*bNewObject*/,
  719. BOOL*)
  720. {
  721. TRACE_FUNCTION_EX(DEB_SNAPIN,ATTR_INIT_FN_ADMIN_MANAGER_NAME)
  722. if(!pBaseAz || !pAttrMap || !pWnd)
  723. {
  724. ASSERT(pBaseAz);
  725. ASSERT(pAttrMap);
  726. ASSERT(pWnd);
  727. return E_POINTER;
  728. }
  729. CString strName = pBaseAz->GetName();
  730. CEdit *pEdit = (CEdit*)pWnd;
  731. pEdit->SetWindowText(strName);
  732. pEdit->SetReadOnly(TRUE);
  733. pEdit->SetLimitText(pAttrMap->attrInfo.ulMaxLen);
  734. return S_OK;
  735. }
  736. HRESULT
  737. ATTR_INIT_FN_ADMIN_MANAGER_STORE_TYPE(CDialog* /*pDlg*/,
  738. CBaseAz* pBaseAz,
  739. ATTR_MAP * pAttrMap,
  740. BOOL /*bDlgReadOnly*/,
  741. CWnd* pWnd,
  742. BOOL /*bNewObject*/,
  743. BOOL*)
  744. {
  745. TRACE_FUNCTION_EX(DEB_SNAPIN,ATTR_INIT_FN_ADMIN_MANAGER_STORE_TYPE)
  746. if(!pBaseAz || !pAttrMap || !pWnd)
  747. {
  748. ASSERT(pBaseAz);
  749. ASSERT(pAttrMap);
  750. ASSERT(pWnd);
  751. return E_POINTER;
  752. }
  753. CAdminManagerAz* pAdminManagerAz = dynamic_cast<CAdminManagerAz*>(pBaseAz);
  754. if(!pAdminManagerAz)
  755. {
  756. ASSERT(pAdminManagerAz);
  757. return E_UNEXPECTED;
  758. }
  759. //Set Store Type
  760. ULONG ulStoreType = pAdminManagerAz->GetStoreType();
  761. CEdit* pEditStoreType = (CEdit*)pWnd;
  762. CString strStoreType;
  763. strStoreType.LoadString((ulStoreType == AZ_ADMIN_STORE_XML) ? IDS_SCOPE_TYPE_XML:IDS_SCOPE_TYPE_AD);
  764. pEditStoreType->SetWindowText(strStoreType);
  765. pEditStoreType->SetReadOnly(TRUE);
  766. return S_OK;
  767. }
  768. HRESULT
  769. ATTR_SAVE_FN_ADMIN_MANAGER_SCRIPT_ENGINE_TIMEOUT(CDialog* pDlg,
  770. CBaseAz* pBaseAz,
  771. ATTR_MAP * pAttrMap,
  772. BOOL /*bDlgReadOnly*/,
  773. CWnd* pWnd,
  774. BOOL /*bNewObject*/,
  775. BOOL* pbErrorDisplayed)
  776. {
  777. TRACE_FUNCTION_EX(DEB_SNAPIN,ATTR_SAVE_FN_ADMIN_MANAGER_SCRIPT_ENGINE_TIMEOUT)
  778. if(!pDlg || !pBaseAz || !pAttrMap || !pWnd || !pbErrorDisplayed)
  779. {
  780. ASSERT(pDlg);
  781. ASSERT(pBaseAz);
  782. ASSERT(pAttrMap);
  783. ASSERT(pWnd);
  784. ASSERT(pbErrorDisplayed);
  785. return E_POINTER;
  786. }
  787. HRESULT hr = S_OK;
  788. //Get new value of authorization script
  789. LONG lNewValue = 0;
  790. //Authorization script is disabled
  791. if( ((CButton*)(pDlg->GetDlgItem(IDC_RADIO_AUTH_SCRIPT_DISABLED)))->GetCheck() == BST_CHECKED)
  792. {
  793. lNewValue = 0;
  794. }
  795. //Authorization script is enabled with no timeout value.
  796. else if( ((CButton*)(pDlg->GetDlgItem(IDC_RADIO_AUTH_SCRIPT_ENABLED_NO_TIMEOUT)))->GetCheck() == BST_CHECKED)
  797. {
  798. lNewValue = -1;
  799. }
  800. //Authorization script is enabled with timeout
  801. else if( ((CButton*)(pDlg->GetDlgItem(IDC_RADIO_AUTH_SCRIPT_ENABLED_WITH_TIMEOUT)))->GetCheck() == BST_CHECKED)
  802. {
  803. if(!GetLongValue((*(CEdit*)pWnd), lNewValue,pDlg->m_hWnd))
  804. {
  805. SetSel(*(CEdit*)pWnd);
  806. *pbErrorDisplayed = TRUE;
  807. return E_INVALIDARG;
  808. }
  809. }
  810. LONG lOldValue = 0;
  811. hr = pBaseAz->GetProperty(pAttrMap->attrInfo.ulPropId,&lOldValue);
  812. if(FAILED(hr))
  813. {
  814. return hr;
  815. }
  816. if(lNewValue == lOldValue)
  817. return S_OK;
  818. if(lNewValue != 0 && lNewValue != -1)
  819. {
  820. //
  821. //There is a minimum for scipt engine timeout
  822. //
  823. if(lNewValue < AZ_AZSTORE_MIN_SCRIPT_ENGINE_TIMEOUT)
  824. {
  825. DisplayError(pDlg->m_hWnd,
  826. IDS_ADMIN_MIN_SCRIPT_ENGINE_TIMEOUT,
  827. lNewValue,
  828. AZ_AZSTORE_MIN_SCRIPT_ENGINE_TIMEOUT);
  829. SetSel(*(CEdit*)pWnd);
  830. *pbErrorDisplayed = TRUE;
  831. return E_INVALIDARG;
  832. }
  833. }
  834. hr = pBaseAz->SetProperty(pAttrMap->attrInfo.ulPropId,lNewValue);
  835. return hr;
  836. }
  837. HRESULT
  838. ATTR_INIT_FN_ADMIN_MANAGER_SCRIPT_ENGINE_TIMEOUT(CDialog* pDlg,
  839. CBaseAz* pBaseAz,
  840. ATTR_MAP * pAttrMap,
  841. BOOL bDlgReadOnly,
  842. CWnd* pWnd,
  843. BOOL /*bNewObject*/,
  844. BOOL* pbErrorDisplayed)
  845. {
  846. TRACE_FUNCTION_EX(DEB_SNAPIN,ATTR_SAVE_FN_ADMIN_MANAGER_SCRIPT_ENGINE_TIMEOUT)
  847. if(!pDlg || !pBaseAz || !pAttrMap || !pWnd || !pbErrorDisplayed)
  848. {
  849. ASSERT(pDlg);
  850. ASSERT(pBaseAz);
  851. ASSERT(pAttrMap);
  852. ASSERT(pWnd);
  853. ASSERT(pbErrorDisplayed);
  854. return E_POINTER;
  855. }
  856. //Get Authorization Script timeout value
  857. LONG lAuthScriptTimout = 0;
  858. HRESULT hr = pBaseAz->GetProperty(pAttrMap->attrInfo.ulPropId,&lAuthScriptTimout);
  859. if(FAILED(hr))
  860. {
  861. return hr;
  862. }
  863. //Script timeout is infinite
  864. if(-1 == lAuthScriptTimout)
  865. {
  866. ((CButton*)pDlg->GetDlgItem(IDC_RADIO_AUTH_SCRIPT_ENABLED_NO_TIMEOUT))->SetCheck(BST_CHECKED);
  867. //Disabel autorization script timeout textbox and set text to infinite
  868. CString strInfinite;
  869. VERIFY(strInfinite.LoadString(IDS_INFINITE));
  870. ((CEdit*)pWnd)->SetWindowText(strInfinite);
  871. pWnd->EnableWindow(FALSE);
  872. }
  873. else
  874. {
  875. SetLongValue((CEdit*)pWnd,lAuthScriptTimout);
  876. //Script is disabled
  877. if(0 == lAuthScriptTimout)
  878. {
  879. ((CButton*)pDlg->GetDlgItem(IDC_RADIO_AUTH_SCRIPT_DISABLED))->SetCheck(BST_CHECKED);
  880. //Disable max script engine textbox
  881. (pDlg->GetDlgItem(IDC_EDIT_MAX_SCRIPT_ENGINE))->EnableWindow(FALSE);
  882. //Disable autorization script timeout textbox
  883. pWnd->EnableWindow(FALSE);
  884. }
  885. else
  886. {
  887. ((CButton*)pDlg->GetDlgItem(IDC_RADIO_AUTH_SCRIPT_ENABLED_WITH_TIMEOUT))->SetCheck(BST_CHECKED);
  888. }
  889. }
  890. if(bDlgReadOnly)
  891. {
  892. pDlg->GetDlgItem(IDC_RADIO_AUTH_SCRIPT_DISABLED)->EnableWindow(FALSE);
  893. pDlg->GetDlgItem(IDC_RADIO_AUTH_SCRIPT_ENABLED_NO_TIMEOUT)->EnableWindow(FALSE);
  894. pDlg->GetDlgItem(IDC_RADIO_AUTH_SCRIPT_ENABLED_WITH_TIMEOUT)->EnableWindow(FALSE);
  895. ((CEdit*)pWnd)->SetReadOnly();
  896. }
  897. return hr;
  898. }
  899. HRESULT
  900. ATTR_SAVE_FN_ADMIN_MANAGER_LDAP_QUERY_TIMEOUT(CDialog* pDlg,
  901. CBaseAz* pBaseAz,
  902. ATTR_MAP * pAttrMap,
  903. BOOL /*bDlgReadOnly*/,
  904. CWnd* pWnd,
  905. BOOL /*bNewObject*/,
  906. BOOL* pbErrorDisplayed)
  907. {
  908. TRACE_FUNCTION_EX(DEB_SNAPIN,ATTR_SAVE_FN_ADMIN_MANAGER_LDAP_QUERY_TIMEOUT)
  909. if(!pDlg || !pBaseAz || !pAttrMap || !pWnd || !pbErrorDisplayed)
  910. {
  911. ASSERT(pDlg);
  912. ASSERT(pBaseAz);
  913. ASSERT(pAttrMap);
  914. ASSERT(pWnd);
  915. ASSERT(pbErrorDisplayed);
  916. return E_POINTER;
  917. }
  918. HRESULT hr = S_OK;
  919. LONG lNewValue = 0;
  920. if(!GetLongValue((*(CEdit*)pWnd), lNewValue,pDlg->m_hWnd))
  921. {
  922. pWnd->SetFocus();
  923. SetSel(*(CEdit*)pWnd);
  924. *pbErrorDisplayed = TRUE;
  925. return E_INVALIDARG;
  926. }
  927. LONG lOldValue = 0;
  928. hr = pBaseAz->GetProperty(pAttrMap->attrInfo.ulPropId,&lOldValue);
  929. if(FAILED(hr))
  930. {
  931. return hr;
  932. }
  933. if(lNewValue == lOldValue)
  934. return S_OK;
  935. //
  936. //There is a minimum for scipt engine timeout
  937. //
  938. if(lNewValue < AZ_AZSTORE_MIN_DOMAIN_TIMEOUT)
  939. {
  940. DisplayError(pDlg->m_hWnd,
  941. IDS_MIN_QUERY_TIMEOUT,
  942. lNewValue,
  943. AZ_AZSTORE_MIN_DOMAIN_TIMEOUT);
  944. *pbErrorDisplayed = TRUE;
  945. SetSel(*(CEdit*)pWnd);
  946. return E_INVALIDARG;
  947. }
  948. hr = pBaseAz->SetProperty(pAttrMap->attrInfo.ulPropId,lNewValue);
  949. return hr;
  950. }
  951. HRESULT
  952. ATTR_SAVE_FN_NAME(CDialog* pDlg,
  953. CBaseAz* pBaseAz,
  954. ATTR_MAP * pAttrMap,
  955. BOOL /*bDlgReadOnly*/,
  956. CWnd* pWnd,
  957. BOOL /*bNewObject*/,
  958. BOOL* pbErrorDisplayed)
  959. {
  960. TRACE_FUNCTION_EX(DEB_SNAPIN,ATTR_SAVE_FN_NAME)
  961. if(!pDlg || !pBaseAz || !pAttrMap || !pWnd)
  962. {
  963. ASSERT(pDlg);
  964. ASSERT(pBaseAz);
  965. ASSERT(pAttrMap);
  966. ASSERT(pWnd);
  967. return E_POINTER;
  968. }
  969. CString strNewName;
  970. ((CEdit*)pWnd)->GetWindowText(strNewName);
  971. CString strOldName = pBaseAz->GetName();
  972. if(strOldName == strNewName)
  973. return S_OK;
  974. HRESULT hr = pBaseAz->SetName(strNewName);
  975. if(FAILED(hr))
  976. {
  977. ErrorMap * pErrorMap = GetErrorMap(pBaseAz->GetObjectType());
  978. if(!pErrorMap)
  979. {
  980. ASSERT(FALSE);
  981. return E_UNEXPECTED;
  982. }
  983. if(hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS))
  984. {
  985. if((pBaseAz->GetObjectType() == TASK_AZ) && ((CTaskAz*)pBaseAz)->IsRoleDefinition())
  986. {
  987. ::DisplayError(pDlg->m_hWnd,IDS_ROLE_DEFINITION_NAME_EXIST,strNewName);
  988. }
  989. else
  990. {
  991. ::DisplayError(pDlg->m_hWnd,pErrorMap->idNameAlreadyExist,strNewName);
  992. }
  993. *pbErrorDisplayed = TRUE;
  994. }
  995. if(hr == HRESULT_FROM_WIN32(ERROR_INVALID_NAME))
  996. {
  997. ::DisplayError(pDlg->m_hWnd,pErrorMap->idInvalidName,pErrorMap->pszInvalidChars);
  998. *pbErrorDisplayed = TRUE;
  999. }
  1000. }
  1001. return hr;
  1002. }
  1003. HRESULT
  1004. ATTR_INIT_FN_GROUP_TYPE(CDialog* /*pDlg*/,
  1005. CBaseAz* pBaseAz,
  1006. ATTR_MAP * pAttrMap,
  1007. BOOL /*bDlgReadOnly*/,
  1008. CWnd* pWnd,
  1009. BOOL /*bNewObject*/,
  1010. BOOL*)
  1011. {
  1012. TRACE_FUNCTION_EX(DEB_SNAPIN,ATTR_INIT_FN_GROUP_TYPE)
  1013. if(!pBaseAz || !pAttrMap || !pWnd)
  1014. {
  1015. ASSERT(pBaseAz);
  1016. ASSERT(pAttrMap);
  1017. ASSERT(pWnd);
  1018. return E_POINTER;
  1019. }
  1020. CGroupAz* pGroupAz = dynamic_cast<CGroupAz*>(pBaseAz);
  1021. if(!pGroupAz)
  1022. {
  1023. ASSERT(pGroupAz);
  1024. return E_UNEXPECTED;
  1025. }
  1026. //Get Store Type
  1027. LONG lGroupType;
  1028. HRESULT hr = pGroupAz->GetGroupType(&lGroupType);
  1029. if(FAILED(hr))
  1030. {
  1031. return hr;
  1032. }
  1033. CEdit* pEditGroupType = (CEdit*)pWnd;
  1034. CString strGroupType;
  1035. strGroupType.LoadString((lGroupType == AZ_GROUPTYPE_LDAP_QUERY) ? IDS_TYPE_LDAP_GROUP:IDS_TYPE_BASIC_GROUP);
  1036. pEditGroupType->SetWindowText(strGroupType);
  1037. pEditGroupType->SetReadOnly(TRUE);
  1038. return S_OK;
  1039. }
  1040. HRESULT
  1041. ATTR_SAVE_FN_OPERATION_ID(CDialog* pDlg,
  1042. CBaseAz* pBaseAz,
  1043. ATTR_MAP * pAttrMap,
  1044. BOOL /*bDlgReadOnly*/,
  1045. CWnd* pWnd,
  1046. BOOL bNewObject,
  1047. BOOL* pbErrorDisplayed)
  1048. {
  1049. TRACE_FUNCTION_EX(DEB_SNAPIN,ATTR_SAVE_FN_OPERATION_ID)
  1050. if(!pDlg || !pBaseAz || !pAttrMap || !pWnd)
  1051. {
  1052. ASSERT(pDlg);
  1053. ASSERT(pBaseAz);
  1054. ASSERT(pAttrMap);
  1055. ASSERT(pWnd);
  1056. return E_POINTER;
  1057. }
  1058. COperationAz* pOperationAz = dynamic_cast<COperationAz*>(pBaseAz);
  1059. if(!pOperationAz)
  1060. {
  1061. ASSERT(pOperationAz);
  1062. return E_UNEXPECTED;
  1063. }
  1064. //Get new Operation ID
  1065. LONG lNewOperationId = 0;
  1066. if(!GetLongValue((*(CEdit*)pWnd), lNewOperationId,pDlg->m_hWnd))
  1067. {
  1068. SetSel(*(CEdit*)pWnd);
  1069. *pbErrorDisplayed = TRUE;
  1070. return E_INVALIDARG;
  1071. }
  1072. if(bNewObject)
  1073. {
  1074. LONG lOldOperationId = 0;
  1075. HRESULT hr = pOperationAz->GetProperty(AZ_PROP_OPERATION_ID,&lOldOperationId);
  1076. if(FAILED(hr))
  1077. {
  1078. return hr;
  1079. }
  1080. if(lNewOperationId == lOldOperationId)
  1081. return S_OK;
  1082. }
  1083. HRESULT hr = pOperationAz->SetProperty(AZ_PROP_OPERATION_ID,lNewOperationId);
  1084. if(FAILED(hr))
  1085. {
  1086. if(hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS))
  1087. {
  1088. CString strOperationId;
  1089. ((CEdit*)pWnd)->GetWindowText(strOperationId);
  1090. ::DisplayError(pDlg->m_hWnd,
  1091. IDS_ERROR_OPERATION_ID_EXISTS,
  1092. strOperationId);
  1093. *pbErrorDisplayed = TRUE;
  1094. SetSel(*(CEdit*)pWnd);
  1095. }
  1096. }
  1097. return hr;
  1098. }