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.

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