Source code of Windows XP (NT5)
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.

910 lines
19 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: cipolicy.cpp
  7. //
  8. // Contents: Cert Server Policy dispatch support
  9. //
  10. // History: 20-Jan-97 vich created
  11. //
  12. //---------------------------------------------------------------------------
  13. #include <pch.cpp>
  14. #pragma hdrstop
  15. #include "csdisp.h"
  16. #include "csprop.h"
  17. //+------------------------------------------------------------------------
  18. // ICertServerPolicy dispatch support
  19. //TCHAR const g_wszRegKeyCIPolicyClsid[] = wszCLASS_CERTSERVERPOLICY TEXT("\\Clsid");
  20. //+------------------------------------
  21. // SetContext method:
  22. static OLECHAR *policy_apszSetContext[] = {
  23. TEXT("SetContext"),
  24. TEXT("Context"),
  25. };
  26. //+------------------------------------
  27. // GetRequestProperty method:
  28. static OLECHAR *policy_apszGetRequestProp[] = {
  29. TEXT("GetRequestProperty"),
  30. TEXT("strPropertyName"),
  31. TEXT("PropertyType"),
  32. };
  33. //+------------------------------------
  34. // GetRequestAttribute method:
  35. static OLECHAR *policy_apszGetRequestAttr[] = {
  36. TEXT("GetRequestAttribute"),
  37. TEXT("strAttributeName"),
  38. };
  39. //+------------------------------------
  40. // GetCertificateProperty method:
  41. static OLECHAR *policy_apszGetCertificateProp[] = {
  42. TEXT("GetCertificateProperty"),
  43. TEXT("strPropertyName"),
  44. TEXT("PropertyType"),
  45. };
  46. //+------------------------------------
  47. // SetCertificateProperty method:
  48. static OLECHAR *policy_apszSetCertificateProp[] = {
  49. TEXT("SetCertificateProperty"),
  50. TEXT("strPropertyName"),
  51. TEXT("PropertyType"),
  52. TEXT("pvarPropertyValue"),
  53. };
  54. //+------------------------------------
  55. // GetCertificateExtension method:
  56. static OLECHAR *policy_apszGetCertificateExt[] = {
  57. TEXT("GetCertificateExtension"),
  58. TEXT("strExtensionName"),
  59. TEXT("Type"),
  60. };
  61. //+------------------------------------
  62. // GetCertificateExtensionFlags method:
  63. static OLECHAR *policy_apszGetCertificateExtFlags[] = {
  64. TEXT("GetCertificateExtensionFlags"),
  65. };
  66. //+------------------------------------
  67. // SetCertificateExtension method:
  68. static OLECHAR *policy_apszSetCertificateExt[] = {
  69. TEXT("SetCertificateExtension"),
  70. TEXT("strExtensionName"),
  71. TEXT("Type"),
  72. TEXT("ExtFlags"),
  73. TEXT("pvarValue"),
  74. };
  75. //+------------------------------------
  76. // EnumerateExtensionsSetup method:
  77. static OLECHAR *policy_apszEnumerateExtensionsSetup[] = {
  78. TEXT("EnumerateExtensionsSetup"),
  79. TEXT("Flags"),
  80. };
  81. //+------------------------------------
  82. // EnumerateExtensions method:
  83. static OLECHAR *policy_apszEnumerateExtensions[] = {
  84. TEXT("EnumerateExtensions"),
  85. };
  86. //+------------------------------------
  87. // EnumerateExtensionsClose method:
  88. static OLECHAR *policy_apszEnumerateExtensionsClose[] = {
  89. TEXT("EnumerateExtensionsClose"),
  90. };
  91. //+------------------------------------
  92. // EnumerateAttributesSetup method:
  93. static OLECHAR *policy_apszEnumerateAttributesSetup[] = {
  94. TEXT("EnumerateAttributesSetup"),
  95. TEXT("Flags"),
  96. };
  97. //+------------------------------------
  98. // EnumerateAttributes method:
  99. static OLECHAR *policy_apszEnumerateAttributes[] = {
  100. TEXT("EnumerateAttributes"),
  101. };
  102. //+------------------------------------
  103. // EnumerateAttributesClose method:
  104. static OLECHAR *policy_apszEnumerateAttributesClose[] = {
  105. TEXT("EnumerateAttributesClose"),
  106. };
  107. //+------------------------------------
  108. // Dispatch Table:
  109. DISPATCHTABLE g_adtCIPolicy[] =
  110. {
  111. #define POLICY_SETCONTEXT 0
  112. DECLARE_DISPATCH_ENTRY(policy_apszSetContext)
  113. #define POLICY_GETREQUESTPROPERTY 1
  114. DECLARE_DISPATCH_ENTRY(policy_apszGetRequestProp)
  115. #define POLICY_GETREQUESTATTRIBUTE 1
  116. DECLARE_DISPATCH_ENTRY(policy_apszGetRequestAttr)
  117. #define POLICY_GETCERTIFICATEPROPERTY 2
  118. DECLARE_DISPATCH_ENTRY(policy_apszGetCertificateProp)
  119. #define POLICY_SETCERTIFICATEPROPERTY 3
  120. DECLARE_DISPATCH_ENTRY(policy_apszSetCertificateProp)
  121. #define POLICY_GETCERTIFICATEEXTENSION 4
  122. DECLARE_DISPATCH_ENTRY(policy_apszGetCertificateExt)
  123. #define POLICY_GETCERTIFICATEEXTENSIONFLAGS 5
  124. DECLARE_DISPATCH_ENTRY(policy_apszGetCertificateExtFlags)
  125. #define POLICY_SETCERTIFICATEEXTENSION 6
  126. DECLARE_DISPATCH_ENTRY(policy_apszSetCertificateExt)
  127. #define POLICY_ENUMERATEEXTENSIONSSETUP 7
  128. DECLARE_DISPATCH_ENTRY(policy_apszEnumerateExtensionsSetup)
  129. #define POLICY_ENUMERATEEXTENSIONS 8
  130. DECLARE_DISPATCH_ENTRY(policy_apszEnumerateExtensions)
  131. #define POLICY_ENUMERATEEXTENSIONSCLOSE 9
  132. DECLARE_DISPATCH_ENTRY(policy_apszEnumerateExtensionsClose)
  133. #define POLICY_ENUMERATEATTRIBUTESSETUP 10
  134. DECLARE_DISPATCH_ENTRY(policy_apszEnumerateAttributesSetup)
  135. #define POLICY_ENUMERATEATTRIBUTES 11
  136. DECLARE_DISPATCH_ENTRY(policy_apszEnumerateAttributes)
  137. #define POLICY_ENUMERATEATTRIBUTESCLOSE 12
  138. DECLARE_DISPATCH_ENTRY(policy_apszEnumerateAttributesClose)
  139. };
  140. #define CPOLICYDISPATCH (ARRAYSIZE(g_adtCIPolicy))
  141. HRESULT
  142. CIPolicy_Init(
  143. IN DWORD Flags,
  144. OUT DISPATCHINTERFACE *pdiCIPolicy)
  145. {
  146. HRESULT hr;
  147. hr = DispatchSetup(
  148. Flags,
  149. CLSCTX_INPROC_SERVER,
  150. wszCLASS_CERTSERVERPOLICY, // g_wszRegKeyCIPolicyClsid,
  151. &CLSID_CCertServerPolicy,
  152. &IID_ICertServerPolicy,
  153. CPOLICYDISPATCH,
  154. g_adtCIPolicy,
  155. pdiCIPolicy);
  156. _JumpIfError(hr, error, "DispatchSetup");
  157. pdiCIPolicy->pDispatchTable = g_adtCIPolicy;
  158. error:
  159. return(hr);
  160. }
  161. VOID
  162. CIPolicy_Release(
  163. IN OUT DISPATCHINTERFACE *pdiCIPolicy)
  164. {
  165. DispatchRelease(pdiCIPolicy);
  166. }
  167. HRESULT
  168. CIPolicy_SetContext(
  169. IN DISPATCHINTERFACE *pdiCIPolicy,
  170. IN LONG Context)
  171. {
  172. HRESULT hr;
  173. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  174. if (NULL != pdiCIPolicy->pDispatch)
  175. {
  176. VARIANT avar[1];
  177. avar[0].vt = VT_I4;
  178. avar[0].lVal = Context;
  179. hr = DispatchInvoke(
  180. pdiCIPolicy,
  181. POLICY_SETCONTEXT,
  182. ARRAYSIZE(avar),
  183. avar,
  184. 0,
  185. NULL);
  186. _JumpIfError(hr, error, "Invoke(SetContext)");
  187. }
  188. else
  189. {
  190. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->SetContext(Context);
  191. _JumpIfError(hr, error, "ICertServerPolicy::SetContext");
  192. }
  193. error:
  194. return(hr);
  195. }
  196. HRESULT
  197. cipolicyGetProperty(
  198. IN DISPATCHINTERFACE *pdiCIPolicy,
  199. IN DWORD IPolicyTable,
  200. IN WCHAR const *pwszPropName,
  201. IN LONG PropertyType,
  202. OUT BSTR *pbstrPropValue)
  203. {
  204. HRESULT hr;
  205. BSTR bstrPropName = NULL;
  206. LONG RetType;
  207. VARIANT varResult;
  208. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  209. CSASSERT(
  210. POLICY_GETCERTIFICATEPROPERTY == IPolicyTable ||
  211. POLICY_GETREQUESTPROPERTY == IPolicyTable);
  212. VariantInit(&varResult);
  213. *pbstrPropValue = NULL;
  214. if (!ConvertWszToBstr(&bstrPropName, pwszPropName, -1))
  215. {
  216. hr = E_OUTOFMEMORY;
  217. goto error;
  218. }
  219. switch (PropertyType)
  220. {
  221. case PROPTYPE_BINARY:
  222. case PROPTYPE_STRING:
  223. RetType = VT_BSTR;
  224. break;
  225. case PROPTYPE_DATE:
  226. RetType = VT_DATE;
  227. break;
  228. case PROPTYPE_LONG:
  229. RetType = VT_I4;
  230. break;
  231. default:
  232. hr = E_INVALIDARG;
  233. _JumpError(hr, error, "PropertyType");
  234. }
  235. if (NULL != pdiCIPolicy->pDispatch)
  236. {
  237. VARIANT avar[2];
  238. avar[0].vt = VT_BSTR;
  239. avar[0].bstrVal = bstrPropName;
  240. avar[1].vt = VT_I4;
  241. avar[1].lVal = PropertyType;
  242. hr = DispatchInvoke(
  243. pdiCIPolicy,
  244. IPolicyTable,
  245. ARRAYSIZE(avar),
  246. avar,
  247. RetType,
  248. pbstrPropValue);
  249. _JumpIfError(
  250. hr,
  251. error,
  252. POLICY_GETCERTIFICATEPROPERTY == IPolicyTable?
  253. "Invoke(Policy::GetCertificateProperty)" :
  254. POLICY_GETREQUESTPROPERTY == IPolicyTable?
  255. "Invoke(Policy::GetRequestProperty)" :
  256. "Invoke(Policy::GetRequestAttribute)");
  257. }
  258. else
  259. {
  260. if (POLICY_GETCERTIFICATEPROPERTY == IPolicyTable)
  261. {
  262. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->GetCertificateProperty(
  263. bstrPropName,
  264. PropertyType,
  265. &varResult);
  266. }
  267. else if (POLICY_GETREQUESTPROPERTY == IPolicyTable)
  268. {
  269. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->GetRequestProperty(
  270. bstrPropName,
  271. PropertyType,
  272. &varResult);
  273. }
  274. else
  275. {
  276. CSASSERT(POLICY_GETREQUESTATTRIBUTE == IPolicyTable);
  277. CSASSERT(PROPTYPE_STRING == PropertyType);
  278. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->GetRequestAttribute(
  279. bstrPropName,
  280. &varResult.bstrVal);
  281. if (S_OK == hr)
  282. {
  283. varResult.vt = VT_BSTR;
  284. }
  285. }
  286. _JumpIfError(
  287. hr,
  288. error,
  289. POLICY_GETCERTIFICATEPROPERTY == IPolicyTable?
  290. "ICertServerPolicy::GetCertificateProperty" :
  291. POLICY_GETREQUESTPROPERTY == IPolicyTable?
  292. "ICertServerPolicy::GetRequestProperty" :
  293. "ICertServerPolicy::GetRequestAttribute");
  294. hr = DispatchGetReturnValue(&varResult, RetType, pbstrPropValue);
  295. _JumpIfError(hr, error, "DispatchGetReturnValue");
  296. }
  297. error:
  298. VariantClear(&varResult);
  299. if (NULL != bstrPropName)
  300. {
  301. SysFreeString(bstrPropName);
  302. }
  303. return(hr);
  304. }
  305. HRESULT
  306. CIPolicy_GetRequestProperty(
  307. IN DISPATCHINTERFACE *pdiCIPolicy,
  308. IN WCHAR const *pwszPropName,
  309. IN LONG PropertyType,
  310. OUT BSTR *pbstrPropValue)
  311. {
  312. return(cipolicyGetProperty(
  313. pdiCIPolicy,
  314. POLICY_GETREQUESTPROPERTY,
  315. pwszPropName,
  316. PropertyType,
  317. pbstrPropValue));
  318. }
  319. HRESULT
  320. CIPolicy_GetRequestAttribute(
  321. IN DISPATCHINTERFACE *pdiCIPolicy,
  322. IN WCHAR const *pwszPropName,
  323. OUT BSTR *pbstrPropValue)
  324. {
  325. return(cipolicyGetProperty(
  326. pdiCIPolicy,
  327. POLICY_GETREQUESTATTRIBUTE,
  328. pwszPropName,
  329. PROPTYPE_STRING,
  330. pbstrPropValue));
  331. }
  332. HRESULT
  333. CIPolicy_GetCertificateProperty(
  334. IN DISPATCHINTERFACE *pdiCIPolicy,
  335. IN WCHAR const *pwszPropName,
  336. IN LONG PropertyType,
  337. OUT BSTR *pbstrPropValue)
  338. {
  339. return(cipolicyGetProperty(
  340. pdiCIPolicy,
  341. POLICY_GETCERTIFICATEPROPERTY,
  342. pwszPropName,
  343. PropertyType,
  344. pbstrPropValue));
  345. }
  346. HRESULT
  347. CIPolicy_SetCertificateProperty(
  348. IN DISPATCHINTERFACE *pdiCIPolicy,
  349. IN WCHAR const *pwszPropName,
  350. IN LONG PropertyType,
  351. IN WCHAR const *pwszPropValue)
  352. {
  353. HRESULT hr;
  354. VARIANT avar[3];
  355. BSTR bstrPropName = NULL;
  356. BSTR bstrPropValue = NULL;
  357. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  358. if (!ConvertWszToBstr(&bstrPropName, pwszPropName, -1))
  359. {
  360. hr = E_OUTOFMEMORY;
  361. goto error;
  362. }
  363. switch (PropertyType)
  364. {
  365. case PROPTYPE_BINARY:
  366. case PROPTYPE_STRING:
  367. if (!ConvertWszToBstr(&bstrPropValue, pwszPropValue, -1))
  368. {
  369. hr = E_OUTOFMEMORY;
  370. goto error;
  371. }
  372. avar[2].vt = VT_BSTR;
  373. avar[2].bstrVal = bstrPropValue;
  374. break;
  375. case PROPTYPE_DATE:
  376. avar[2].vt = VT_DATE;
  377. avar[2].date = *(DATE *) pwszPropValue;
  378. break;
  379. case PROPTYPE_LONG:
  380. avar[2].vt = VT_I4;
  381. avar[2].lVal = *(LONG *) pwszPropValue;
  382. break;
  383. }
  384. if (NULL != pdiCIPolicy->pDispatch)
  385. {
  386. avar[0].vt = VT_BSTR;
  387. avar[0].bstrVal = bstrPropName;
  388. avar[1].vt = VT_I4;
  389. avar[1].lVal = PropertyType;
  390. hr = DispatchInvoke(
  391. pdiCIPolicy,
  392. POLICY_SETCERTIFICATEPROPERTY,
  393. ARRAYSIZE(avar),
  394. avar,
  395. 0,
  396. NULL);
  397. _JumpIfError(hr, error, "Invoke(SetCertificateProperty)");
  398. }
  399. else
  400. {
  401. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->SetCertificateProperty(
  402. bstrPropName,
  403. PropertyType,
  404. &avar[2]);
  405. _JumpIfError(hr, error, "ICertServerPolicy::SetCertificateProperty");
  406. }
  407. error:
  408. if (NULL != bstrPropName)
  409. {
  410. SysFreeString(bstrPropName);
  411. }
  412. if (NULL != bstrPropValue)
  413. {
  414. SysFreeString(bstrPropValue);
  415. }
  416. return(hr);
  417. }
  418. HRESULT
  419. CIPolicy_GetCertificateExtension(
  420. IN DISPATCHINTERFACE *pdiCIPolicy,
  421. IN WCHAR const *pwszExtensionName,
  422. IN LONG Type,
  423. OUT BSTR *pbstrValue)
  424. {
  425. HRESULT hr;
  426. BSTR bstrExtensionName = NULL;
  427. LONG RetType;
  428. VARIANT varResult;
  429. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  430. VariantInit(&varResult);
  431. *pbstrValue = NULL;
  432. if (!ConvertWszToBstr(&bstrExtensionName, pwszExtensionName, -1))
  433. {
  434. hr = E_OUTOFMEMORY;
  435. goto error;
  436. }
  437. switch (Type)
  438. {
  439. case PROPTYPE_BINARY:
  440. case PROPTYPE_STRING:
  441. RetType = VT_BSTR;
  442. break;
  443. case PROPTYPE_DATE:
  444. RetType = VT_DATE;
  445. break;
  446. case PROPTYPE_LONG:
  447. RetType = VT_I4;
  448. break;
  449. default:
  450. hr = E_INVALIDARG;
  451. _JumpError(hr, error, "PropertyType");
  452. }
  453. if (NULL != pdiCIPolicy->pDispatch)
  454. {
  455. VARIANT avar[2];
  456. avar[0].vt = VT_BSTR;
  457. avar[0].bstrVal = bstrExtensionName;
  458. avar[1].vt = VT_I4;
  459. avar[1].lVal = Type;
  460. hr = DispatchInvoke(
  461. pdiCIPolicy,
  462. POLICY_GETCERTIFICATEEXTENSION,
  463. ARRAYSIZE(avar),
  464. avar,
  465. RetType,
  466. pbstrValue);
  467. _JumpIfError(hr, error, "Invoke(Policy::GetCertificateExtension)");
  468. }
  469. else
  470. {
  471. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->GetCertificateExtension(
  472. bstrExtensionName,
  473. Type,
  474. &varResult);
  475. _JumpIfError(hr, error, "ICertServerPolicy::GetCertificateExtension");
  476. hr = DispatchGetReturnValue(&varResult, RetType, pbstrValue);
  477. _JumpIfError(hr, error, "DispatchGetReturnValue");
  478. }
  479. error:
  480. VariantClear(&varResult);
  481. if (NULL != bstrExtensionName)
  482. {
  483. SysFreeString(bstrExtensionName);
  484. }
  485. return(hr);
  486. }
  487. HRESULT
  488. CIPolicy_GetCertificateExtensionFlags(
  489. IN DISPATCHINTERFACE *pdiCIPolicy,
  490. OUT LONG *pExtFlags)
  491. {
  492. HRESULT hr;
  493. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  494. if (NULL != pdiCIPolicy->pDispatch)
  495. {
  496. hr = DispatchInvoke(
  497. pdiCIPolicy,
  498. POLICY_GETCERTIFICATEEXTENSIONFLAGS,
  499. 0,
  500. NULL,
  501. VT_I4,
  502. pExtFlags);
  503. _JumpIfError(hr, error, "Invoke(Policy::GetCertificateExtensionFlags)");
  504. }
  505. else
  506. {
  507. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->GetCertificateExtensionFlags(
  508. pExtFlags);
  509. _JumpIfError(hr, error, "ICertServerPolicy::GetCertificateExtensionFlags");
  510. }
  511. error:
  512. return(hr);
  513. }
  514. HRESULT
  515. CIPolicy_SetCertificateExtension(
  516. IN DISPATCHINTERFACE *pdiCIPolicy,
  517. IN WCHAR const *pwszExtensionName,
  518. IN LONG Type,
  519. IN LONG ExtFlags,
  520. IN void const *pvValue)
  521. {
  522. HRESULT hr;
  523. VARIANT avar[4];
  524. BSTR bstrExtensionName = NULL;
  525. if (!ConvertWszToBstr(&bstrExtensionName, pwszExtensionName, -1))
  526. {
  527. hr = E_OUTOFMEMORY;
  528. goto error;
  529. }
  530. switch (Type)
  531. {
  532. case PROPTYPE_BINARY:
  533. case PROPTYPE_STRING:
  534. avar[3].vt = VT_BSTR;
  535. avar[3].bstrVal = (BSTR)pvValue;
  536. break;
  537. case PROPTYPE_DATE:
  538. avar[3].vt = VT_DATE;
  539. avar[3].date = *(DATE *) pvValue;
  540. break;
  541. case PROPTYPE_LONG:
  542. avar[3].vt = VT_I4;
  543. avar[3].lVal = *(LONG *) pvValue;
  544. break;
  545. }
  546. if (NULL != pdiCIPolicy->pDispatch)
  547. {
  548. avar[0].vt = VT_BSTR;
  549. avar[0].bstrVal = bstrExtensionName;
  550. avar[1].vt = VT_I4;
  551. avar[1].lVal = Type;
  552. avar[2].vt = VT_I4;
  553. avar[2].lVal = ExtFlags;
  554. hr = DispatchInvoke(
  555. pdiCIPolicy,
  556. POLICY_SETCERTIFICATEEXTENSION,
  557. ARRAYSIZE(avar),
  558. avar,
  559. 0,
  560. NULL);
  561. _JumpIfError(hr, error, "Invoke(SetCertificateExtension)");
  562. }
  563. else
  564. {
  565. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->SetCertificateExtension(
  566. bstrExtensionName,
  567. Type,
  568. ExtFlags,
  569. &avar[2]);
  570. _JumpIfError(hr, error, "ICertServerPolicy::SetCertificateExtension");
  571. }
  572. error:
  573. if (NULL != bstrExtensionName)
  574. {
  575. SysFreeString(bstrExtensionName);
  576. }
  577. return(hr);
  578. }
  579. HRESULT
  580. CIPolicy_EnumerateExtensionsSetup(
  581. IN DISPATCHINTERFACE *pdiCIPolicy,
  582. IN LONG Flags)
  583. {
  584. HRESULT hr;
  585. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  586. if (NULL != pdiCIPolicy->pDispatch)
  587. {
  588. VARIANT avar[1];
  589. avar[0].vt = VT_I4;
  590. avar[0].lVal = Flags;
  591. hr = DispatchInvoke(
  592. pdiCIPolicy,
  593. POLICY_ENUMERATEEXTENSIONSSETUP,
  594. ARRAYSIZE(avar),
  595. avar,
  596. 0,
  597. NULL);
  598. _JumpIfError(hr, error, "Invoke(EnumerateExtensionsSetup)");
  599. }
  600. else
  601. {
  602. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->EnumerateExtensionsSetup(
  603. Flags);
  604. _JumpIfError(hr, error, "ICertServerPolicy::EnumerateExtensionsSetup");
  605. }
  606. error:
  607. return(hr);
  608. }
  609. HRESULT
  610. CIPolicy_EnumerateExtensions(
  611. IN DISPATCHINTERFACE *pdiCIPolicy,
  612. OUT BSTR *pstrExtensionName)
  613. {
  614. HRESULT hr;
  615. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  616. if (NULL != pdiCIPolicy->pDispatch)
  617. {
  618. hr = DispatchInvoke(
  619. pdiCIPolicy,
  620. POLICY_ENUMERATEEXTENSIONS,
  621. 0,
  622. NULL,
  623. VT_BSTR,
  624. pstrExtensionName);
  625. _JumpIfError(hr, error, "Invoke(EnumerateExtensions)");
  626. }
  627. else
  628. {
  629. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->EnumerateExtensions(
  630. pstrExtensionName);
  631. _JumpIfError(hr, error, "ICertServerPolicy::EnumerateExtensions");
  632. }
  633. error:
  634. return(hr);
  635. }
  636. HRESULT
  637. CIPolicy_EnumerateExtensionsClose(
  638. IN DISPATCHINTERFACE *pdiCIPolicy)
  639. {
  640. HRESULT hr;
  641. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  642. if (NULL != pdiCIPolicy->pDispatch)
  643. {
  644. hr = DispatchInvoke(
  645. pdiCIPolicy,
  646. POLICY_ENUMERATEEXTENSIONSCLOSE,
  647. 0,
  648. NULL,
  649. 0,
  650. NULL);
  651. _JumpIfError(hr, error, "Invoke(EnumerateExtensionsClose)");
  652. }
  653. else
  654. {
  655. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->EnumerateExtensionsClose();
  656. _JumpIfError(hr, error, "ICertServerPolicy::EnumerateExtensionsClose");
  657. }
  658. error:
  659. return(hr);
  660. }
  661. HRESULT
  662. CIPolicy_EnumerateAttributesSetup(
  663. IN DISPATCHINTERFACE *pdiCIPolicy,
  664. IN LONG Flags)
  665. {
  666. HRESULT hr;
  667. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  668. if (NULL != pdiCIPolicy->pDispatch)
  669. {
  670. VARIANT avar[1];
  671. avar[0].vt = VT_I4;
  672. avar[0].lVal = Flags;
  673. hr = DispatchInvoke(
  674. pdiCIPolicy,
  675. POLICY_ENUMERATEATTRIBUTESSETUP,
  676. ARRAYSIZE(avar),
  677. avar,
  678. 0,
  679. NULL);
  680. _JumpIfError(hr, error, "Invoke(EnumerateAttributesSetup)");
  681. }
  682. else
  683. {
  684. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->EnumerateAttributesSetup(
  685. Flags);
  686. _JumpIfError(hr, error, "ICertServerPolicy::EnumerateAttributesSetup");
  687. }
  688. error:
  689. return(hr);
  690. }
  691. HRESULT
  692. CIPolicy_EnumerateAttributes(
  693. IN DISPATCHINTERFACE *pdiCIPolicy,
  694. OUT BSTR *pstrAttributeName)
  695. {
  696. HRESULT hr;
  697. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  698. if (NULL != pdiCIPolicy->pDispatch)
  699. {
  700. hr = DispatchInvoke(
  701. pdiCIPolicy,
  702. POLICY_ENUMERATEATTRIBUTES,
  703. 0,
  704. NULL,
  705. 0,
  706. pstrAttributeName);
  707. _JumpIfError(hr, error, "Invoke(EnumerateAttributes)");
  708. }
  709. else
  710. {
  711. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->EnumerateAttributes(
  712. pstrAttributeName);
  713. _JumpIfError(hr, error, "ICertServerPolicy::EnumerateAttributes");
  714. }
  715. error:
  716. return(hr);
  717. }
  718. HRESULT
  719. CIPolicy_EnumerateAttributesClose(
  720. IN DISPATCHINTERFACE *pdiCIPolicy)
  721. {
  722. HRESULT hr;
  723. CSASSERT(NULL != pdiCIPolicy && NULL != pdiCIPolicy->pDispatchTable);
  724. if (NULL != pdiCIPolicy->pDispatch)
  725. {
  726. hr = DispatchInvoke(
  727. pdiCIPolicy,
  728. POLICY_ENUMERATEATTRIBUTESCLOSE,
  729. 0,
  730. NULL,
  731. 0,
  732. NULL);
  733. _JumpIfError(hr, error, "Invoke(EnumerateAttributesClose)");
  734. }
  735. else
  736. {
  737. hr = ((ICertServerPolicy *) pdiCIPolicy->pUnknown)->EnumerateAttributesClose();
  738. _JumpIfError(hr, error, "ICertServerPolicy::EnumerateAttributesClose");
  739. }
  740. error:
  741. return(hr);
  742. }