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.

1525 lines
35 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: var2nds.cxx
  7. //
  8. // Contents: NDS Object to Variant Copy Routines
  9. //
  10. // Functions:
  11. //
  12. // History: 25-Apr-96 KrishnaG Created.
  13. //
  14. //
  15. // Issues: Check null ptrs for AllocADsMem and AllocADsStr
  16. //
  17. //
  18. // NDS_ASN1_TYPE_1
  19. //
  20. // NDS_ASN1_TYPE_2
  21. //
  22. // NDS_ASN1_TYPE_3
  23. //
  24. // NDS_ASN1_TYPE_4
  25. //
  26. // NDS_ASN1_TYPE_5
  27. //
  28. // NDS_ASN1_TYPE_6
  29. //
  30. // NDS_ASN1_TYPE_7
  31. //
  32. // NDS_ASN1_TYPE_8
  33. //
  34. // NDS_ASN1_TYPE_9
  35. //
  36. // NDS_ASN1_TYPE_10
  37. //
  38. // NDS_ASN1_TYPE_11
  39. //
  40. // NDS_ASN1_TYPE_12
  41. //
  42. // NDS_ASN1_TYPE_13
  43. //
  44. // NDS_ASN1_TYPE_14
  45. //
  46. // NDS_ASN1_TYPE_15
  47. //
  48. // NDS_ASN1_TYPE_16
  49. //
  50. // NDS_ASN1_TYPE_17
  51. //
  52. // NDS_ASN1_TYPE_18
  53. //
  54. // NDS_ASN1_TYPE_19
  55. //
  56. // NDS_ASN1_TYPE_20
  57. //
  58. // NDS_ASN1_TYPE_21
  59. //
  60. // NDS_ASN1_TYPE_22
  61. //
  62. // NDS_ASN1_TYPE_23
  63. //
  64. // NDS_ASN1_TYPE_24
  65. //
  66. // NDS_ASN1_TYPE_25
  67. //
  68. // NDS_ASN1_TYPE_26
  69. //
  70. // NDS_ASN1_TYPE_27
  71. //
  72. //
  73. //----------------------------------------------------------------------------
  74. #include "nds.hxx"
  75. //
  76. // NdsType objects copy code
  77. //
  78. HRESULT
  79. VarTypeToNdsTypeCopyNDSSynId1(
  80. PVARIANT lpVarSrcObject,
  81. PNDSOBJECT lpNdsDestObject
  82. )
  83. {
  84. HRESULT hr = S_OK;
  85. if(lpVarSrcObject->vt != VT_BSTR){
  86. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  87. }
  88. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_1;
  89. lpNdsDestObject->NdsValue.value_1.DNString =
  90. AllocADsStr(
  91. lpVarSrcObject->bstrVal
  92. );
  93. RRETURN(hr);
  94. }
  95. HRESULT
  96. VarTypeToNdsTypeCopyNDSSynId2(
  97. PVARIANT lpVarSrcObject,
  98. PNDSOBJECT lpNdsDestObject
  99. )
  100. {
  101. HRESULT hr = S_OK;
  102. if(lpVarSrcObject->vt != VT_BSTR){
  103. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  104. }
  105. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_2;
  106. lpNdsDestObject->NdsValue.value_2.CaseExactString =
  107. AllocADsStr(
  108. lpVarSrcObject->bstrVal
  109. );
  110. RRETURN(hr);
  111. }
  112. HRESULT
  113. VarTypeToNdsTypeCopyNDSSynId3(
  114. PVARIANT lpVarSrcObject,
  115. PNDSOBJECT lpNdsDestObject
  116. )
  117. {
  118. HRESULT hr = S_OK;
  119. if(lpVarSrcObject->vt != VT_BSTR){
  120. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  121. }
  122. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_3;
  123. lpNdsDestObject->NdsValue.value_3.CaseIgnoreString =
  124. AllocADsStr(
  125. lpVarSrcObject->bstrVal
  126. );
  127. RRETURN(hr);
  128. }
  129. HRESULT
  130. VarTypeToNdsTypeCopyNDSSynId4(
  131. PVARIANT lpVarSrcObject,
  132. PNDSOBJECT lpNdsDestObject
  133. )
  134. {
  135. HRESULT hr = S_OK;
  136. if(lpVarSrcObject->vt != VT_BSTR){
  137. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  138. }
  139. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_4;
  140. lpNdsDestObject->NdsValue.value_4.PrintableString =
  141. AllocADsStr(
  142. lpVarSrcObject->bstrVal
  143. );
  144. RRETURN(hr);
  145. }
  146. HRESULT
  147. VarTypeToNdsTypeCopyNDSSynId5(
  148. PVARIANT lpVarSrcObject,
  149. PNDSOBJECT lpNdsDestObject
  150. )
  151. {
  152. HRESULT hr = S_OK;
  153. if(lpVarSrcObject->vt != VT_BSTR){
  154. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  155. }
  156. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_5;
  157. lpNdsDestObject->NdsValue.value_5.NumericString =
  158. AllocADsStr(
  159. lpVarSrcObject->bstrVal
  160. );
  161. RRETURN(hr);
  162. }
  163. HRESULT
  164. VarTypeToNdsTypeCopyNDSSynId6(
  165. PVARIANT lpVarSrcObject,
  166. PNDSOBJECT lpNdsDestObject
  167. )
  168. {
  169. HRESULT hr = S_OK;
  170. DWORD dwSLBound = 0;
  171. DWORD dwSUBound = 0;
  172. long i;
  173. LPNDS_ASN1_TYPE_6 pCurrent = NULL;
  174. IADsCaseIgnoreList FAR * pCaseIgnoreList = NULL;
  175. IDispatch FAR * pDispatch = NULL;
  176. BYTE* pbParameter = NULL;
  177. VARIANT varCaseIgnoreList;
  178. VARIANT varElement;
  179. VariantInit(&varCaseIgnoreList);
  180. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  181. hr = E_FAIL;
  182. BAIL_ON_FAILURE(hr);
  183. }
  184. pDispatch = V_DISPATCH(lpVarSrcObject);
  185. hr = pDispatch->QueryInterface(
  186. IID_IADsCaseIgnoreList,
  187. (void **)&pCaseIgnoreList
  188. );
  189. BAIL_ON_FAILURE(hr);
  190. hr = pCaseIgnoreList->get_CaseIgnoreList(
  191. &varCaseIgnoreList
  192. );
  193. BAIL_ON_FAILURE(hr);
  194. if(!((V_VT(&varCaseIgnoreList) & VT_VARIANT) && V_ISARRAY(&varCaseIgnoreList))) {
  195. return(E_FAIL);
  196. }
  197. if ((V_ARRAY(&varCaseIgnoreList))->cDims != 1) {
  198. hr = E_FAIL;
  199. BAIL_ON_FAILURE(hr);
  200. }
  201. if ((V_ARRAY(&varCaseIgnoreList))->rgsabound[0].cElements <= 0) {
  202. hr = E_FAIL;
  203. BAIL_ON_FAILURE(hr);
  204. }
  205. hr = SafeArrayGetLBound(V_ARRAY(&varCaseIgnoreList),
  206. 1,
  207. (long FAR *)&dwSLBound
  208. );
  209. BAIL_ON_FAILURE(hr);
  210. hr = SafeArrayGetUBound(V_ARRAY(&varCaseIgnoreList),
  211. 1,
  212. (long FAR *)&dwSUBound
  213. );
  214. BAIL_ON_FAILURE(hr);
  215. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_6;
  216. pCurrent = &lpNdsDestObject->NdsValue.value_6;
  217. for (i = dwSLBound; i <= (long)dwSUBound; i++) {
  218. VariantInit(&varElement);
  219. hr = SafeArrayGetElement(V_ARRAY(&varCaseIgnoreList),
  220. (long FAR *)&i,
  221. &varElement
  222. );
  223. BAIL_ON_FAILURE(hr);
  224. pCurrent->String = AllocADsStr(V_BSTR(&varElement));
  225. if (i != (long)dwSUBound) {
  226. pCurrent->Next = (LPNDS_ASN1_TYPE_6)AllocADsMem(sizeof(NDS_ASN1_TYPE_6));
  227. if (!pCurrent->Next) {
  228. hr = E_OUTOFMEMORY;
  229. BAIL_ON_FAILURE(hr);
  230. }
  231. pCurrent = pCurrent->Next;
  232. }
  233. VariantClear(&varElement);
  234. }
  235. pCurrent->Next = NULL;
  236. RRETURN(S_OK);
  237. error:
  238. VariantClear(&varCaseIgnoreList);
  239. if (pCaseIgnoreList) {
  240. pCaseIgnoreList->Release();
  241. }
  242. RRETURN(hr);
  243. }
  244. HRESULT
  245. VarTypeToNdsTypeCopyNDSSynId7(
  246. PVARIANT lpVarSrcObject,
  247. PNDSOBJECT lpNdsDestObject
  248. )
  249. {
  250. HRESULT hr = S_OK;
  251. if(lpVarSrcObject->vt != VT_BOOL){
  252. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  253. }
  254. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_7;
  255. lpNdsDestObject->NdsValue.value_7.Boolean =
  256. (lpVarSrcObject->boolVal)? TRUE:FALSE;
  257. RRETURN(hr);
  258. }
  259. HRESULT
  260. VarTypeToNdsTypeCopyNDSSynId8(
  261. PVARIANT lpVarSrcObject,
  262. PNDSOBJECT lpNdsDestObject
  263. )
  264. {
  265. HRESULT hr = S_OK;
  266. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_8;
  267. if (lpVarSrcObject->vt == VT_I4)
  268. lpNdsDestObject->NdsValue.value_8.Integer = lpVarSrcObject->lVal;
  269. else if (lpVarSrcObject->vt == VT_I2)
  270. lpNdsDestObject->NdsValue.value_8.Integer = lpVarSrcObject->iVal;
  271. else
  272. hr = E_ADS_CANT_CONVERT_DATATYPE;
  273. RRETURN(hr);
  274. }
  275. HRESULT
  276. VarTypeToNdsTypeCopyNDSSynId9(
  277. PVARIANT lpVarSrcObject,
  278. PNDSOBJECT lpNdsDestObject
  279. )
  280. {
  281. HRESULT hr;
  282. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_9;
  283. hr = VariantToBinary(
  284. lpVarSrcObject,
  285. &lpNdsDestObject->NdsValue.value_9.Length,
  286. &lpNdsDestObject->NdsValue.value_9.OctetString
  287. );
  288. RRETURN(hr);
  289. }
  290. HRESULT
  291. VarTypeToNdsTypeCopyNDSSynId10(
  292. PVARIANT lpVarSrcObject,
  293. PNDSOBJECT lpNdsDestObject
  294. )
  295. {
  296. HRESULT hr = S_OK;
  297. if(lpVarSrcObject->vt != VT_BSTR){
  298. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  299. }
  300. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_10;
  301. lpNdsDestObject->NdsValue.value_10.TelephoneNumber =
  302. AllocADsStr(
  303. lpVarSrcObject->bstrVal
  304. );
  305. RRETURN(hr);
  306. }
  307. HRESULT
  308. VarTypeToNdsTypeCopyNDSSynId11(
  309. PVARIANT lpVarSrcObject,
  310. PNDSOBJECT lpNdsDestObject
  311. )
  312. {
  313. HRESULT hr = S_OK;
  314. IADsFaxNumber FAR * pFaxNumber = NULL;
  315. IDispatch FAR * pDispatch = NULL;
  316. BYTE* pbParameter = NULL;
  317. VARIANT varParameters;
  318. BSTR bstrVal;
  319. VariantInit(&varParameters);
  320. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  321. hr = E_FAIL;
  322. BAIL_ON_FAILURE(hr);
  323. }
  324. pDispatch = V_DISPATCH(lpVarSrcObject);
  325. hr = pDispatch->QueryInterface(
  326. IID_IADsFaxNumber,
  327. (void **)&pFaxNumber
  328. );
  329. BAIL_ON_FAILURE(hr);
  330. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_11;
  331. hr = pFaxNumber->get_TelephoneNumber(
  332. &bstrVal
  333. );
  334. BAIL_ON_FAILURE(hr);
  335. lpNdsDestObject->NdsValue.value_11.TelephoneNumber =
  336. AllocADsStr(
  337. bstrVal
  338. );
  339. hr = pFaxNumber->get_Parameters(
  340. &varParameters
  341. );
  342. BAIL_ON_FAILURE(hr);
  343. hr = VariantToBinary(
  344. &varParameters,
  345. &lpNdsDestObject->NdsValue.value_11.NumberOfBits,
  346. &lpNdsDestObject->NdsValue.value_11.Parameters
  347. );
  348. BAIL_ON_FAILURE(hr);
  349. error:
  350. VariantClear(&varParameters);
  351. if (pFaxNumber) {
  352. pFaxNumber->Release();
  353. }
  354. RRETURN(hr);
  355. }
  356. HRESULT
  357. VarTypeToNdsTypeCopyNDSSynId12(
  358. PVARIANT lpVarSrcObject,
  359. PNDSOBJECT lpNdsDestObject
  360. )
  361. {
  362. HRESULT hr = S_OK;
  363. IADsNetAddress FAR * pNetAddress = NULL;
  364. IDispatch FAR * pDispatch = NULL;
  365. long dwAddressType = 0;
  366. BYTE* pbAddress = NULL;
  367. VARIANT varAddress;
  368. VariantInit(&varAddress);
  369. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  370. hr = E_FAIL;
  371. BAIL_ON_FAILURE(hr);
  372. }
  373. pDispatch = V_DISPATCH(lpVarSrcObject);
  374. hr = pDispatch->QueryInterface(
  375. IID_IADsNetAddress,
  376. (void **)&pNetAddress
  377. );
  378. BAIL_ON_FAILURE(hr);
  379. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_12;
  380. hr = pNetAddress->get_AddressType(
  381. &dwAddressType
  382. );
  383. BAIL_ON_FAILURE(hr);
  384. lpNdsDestObject->NdsValue.value_12.AddressType = dwAddressType;
  385. VariantInit(&varAddress);
  386. hr = pNetAddress->get_Address(
  387. &varAddress
  388. );
  389. BAIL_ON_FAILURE(hr);
  390. hr = VariantToBinary(
  391. &varAddress,
  392. &lpNdsDestObject->NdsValue.value_12.AddressLength,
  393. &lpNdsDestObject->NdsValue.value_12.Address
  394. );
  395. BAIL_ON_FAILURE(hr);
  396. error:
  397. VariantClear(&varAddress);
  398. if (pNetAddress) {
  399. pNetAddress->Release();
  400. }
  401. RRETURN(hr);
  402. }
  403. HRESULT
  404. VarTypeToNdsTypeCopyNDSSynId13(
  405. PVARIANT lpVarSrcObject,
  406. PNDSOBJECT lpNdsDestObject
  407. )
  408. {
  409. HRESULT hr = S_OK;
  410. DWORD dwSLBound = 0;
  411. DWORD dwSUBound = 0;
  412. long i;
  413. LPNDS_ASN1_TYPE_13 pCurrent = NULL;
  414. IADsOctetList FAR * pOctetList= NULL;
  415. IDispatch FAR * pDispatch = NULL;
  416. BYTE* pbParameter = NULL;
  417. VARIANT varOctetList;
  418. VARIANT varElement;
  419. VariantInit(&varOctetList);
  420. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  421. hr = E_FAIL;
  422. BAIL_ON_FAILURE(hr);
  423. }
  424. pDispatch = V_DISPATCH(lpVarSrcObject);
  425. hr = pDispatch->QueryInterface(
  426. IID_IADsOctetList,
  427. (void **)&pOctetList
  428. );
  429. BAIL_ON_FAILURE(hr);
  430. hr = pOctetList->get_OctetList(&varOctetList);
  431. BAIL_ON_FAILURE(hr);
  432. if(!((V_VT(&varOctetList) & VT_VARIANT) && V_ISARRAY(&varOctetList))) {
  433. return(E_FAIL);
  434. }
  435. if ((V_ARRAY(&varOctetList))->cDims != 1) {
  436. hr = E_FAIL;
  437. BAIL_ON_FAILURE(hr);
  438. }
  439. if ((V_ARRAY(&varOctetList))->rgsabound[0].cElements <= 0) {
  440. hr = E_FAIL;
  441. BAIL_ON_FAILURE(hr);
  442. }
  443. hr = SafeArrayGetLBound(V_ARRAY(&varOctetList),
  444. 1,
  445. (long FAR *)&dwSLBound
  446. );
  447. BAIL_ON_FAILURE(hr);
  448. hr = SafeArrayGetUBound(V_ARRAY(&varOctetList),
  449. 1,
  450. (long FAR *)&dwSUBound
  451. );
  452. BAIL_ON_FAILURE(hr);
  453. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_13;
  454. pCurrent = &lpNdsDestObject->NdsValue.value_13;
  455. for (i = dwSLBound; i <= (long)dwSUBound; i++) {
  456. VariantInit(&varElement);
  457. hr = SafeArrayGetElement(V_ARRAY(&varOctetList),
  458. (long FAR *)&i,
  459. &varElement
  460. );
  461. BAIL_ON_FAILURE(hr);
  462. hr = VariantToBinary(
  463. &varElement,
  464. &pCurrent->Length,
  465. &pCurrent->Data
  466. );
  467. BAIL_ON_FAILURE(hr);
  468. if (i != (long)dwSUBound) {
  469. pCurrent->Next = (LPNDS_ASN1_TYPE_13)AllocADsMem(sizeof(NDS_ASN1_TYPE_13));
  470. if (!pCurrent->Next) {
  471. hr = E_OUTOFMEMORY;
  472. BAIL_ON_FAILURE(hr);
  473. }
  474. pCurrent = pCurrent->Next;
  475. }
  476. VariantClear(&varElement);
  477. }
  478. pCurrent->Next = NULL;
  479. error:
  480. VariantClear(&varOctetList);
  481. if (pOctetList) {
  482. pOctetList->Release();
  483. }
  484. RRETURN(hr);
  485. }
  486. HRESULT
  487. VarTypeToNdsTypeCopyNDSSynId14(
  488. PVARIANT lpVarSrcObject,
  489. PNDSOBJECT lpNdsDestObject
  490. )
  491. {
  492. HRESULT hr = S_OK;
  493. IADsEmail FAR * pEmail = NULL;
  494. IDispatch FAR * pDispatch = NULL;
  495. long dwAddressType = 0;
  496. BSTR bstrAddress;
  497. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  498. hr = E_FAIL;
  499. BAIL_ON_FAILURE(hr);
  500. }
  501. pDispatch = V_DISPATCH(lpVarSrcObject);
  502. hr = pDispatch->QueryInterface(
  503. IID_IADsEmail,
  504. (void **)&pEmail
  505. );
  506. BAIL_ON_FAILURE(hr);
  507. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_14;
  508. hr = pEmail->get_Type(
  509. &dwAddressType
  510. );
  511. BAIL_ON_FAILURE(hr);
  512. lpNdsDestObject->NdsValue.value_14.Type = dwAddressType;
  513. hr = pEmail->get_Address(
  514. &bstrAddress
  515. );
  516. BAIL_ON_FAILURE(hr);
  517. lpNdsDestObject->NdsValue.value_14.Address=
  518. AllocADsStr(
  519. bstrAddress
  520. );
  521. error:
  522. if (pEmail) {
  523. pEmail->Release();
  524. }
  525. RRETURN(hr);
  526. }
  527. HRESULT
  528. VarTypeToNdsTypeCopyNDSSynId15(
  529. PVARIANT lpVarSrcObject,
  530. PNDSOBJECT lpNdsDestObject
  531. )
  532. {
  533. HRESULT hr = S_OK;
  534. IADsPath FAR * pPath = NULL;
  535. IDispatch FAR * pDispatch = NULL;
  536. DWORD dwType = 0;
  537. BSTR bstrVolumeName = NULL;
  538. BSTR bstrPath = NULL;
  539. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  540. hr = E_FAIL;
  541. BAIL_ON_FAILURE(hr);
  542. }
  543. pDispatch = V_DISPATCH(lpVarSrcObject);
  544. hr = pDispatch->QueryInterface(
  545. IID_IADsPath,
  546. (void **)&pPath
  547. );
  548. BAIL_ON_FAILURE(hr);
  549. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_15;
  550. hr = pPath->get_VolumeName(
  551. &bstrVolumeName
  552. );
  553. BAIL_ON_FAILURE(hr);
  554. lpNdsDestObject->NdsValue.value_15.VolumeName=
  555. AllocADsStr(bstrVolumeName);
  556. hr = pPath->get_Path(
  557. &bstrPath
  558. );
  559. BAIL_ON_FAILURE(hr);
  560. lpNdsDestObject->NdsValue.value_15.Path=
  561. AllocADsStr(bstrPath);
  562. hr = pPath->get_Type((LONG *)&dwType);
  563. BAIL_ON_FAILURE(hr);
  564. lpNdsDestObject->NdsValue.value_15.Type = dwType;
  565. error:
  566. if (pPath) {
  567. pPath->Release();
  568. }
  569. RRETURN(hr);
  570. }
  571. HRESULT
  572. VarTypeToNdsTypeCopyNDSSynId16(
  573. PVARIANT lpVarSrcObject,
  574. PNDSOBJECT lpNdsDestObject
  575. )
  576. {
  577. HRESULT hr = S_OK;
  578. IADsReplicaPointer FAR * pReplicaPointer = NULL;
  579. IDispatch FAR * pDispatch = NULL;
  580. DWORD dwReplicaType = 0;
  581. DWORD dwReplicaNumber = 0;
  582. DWORD dwCount = 0;
  583. BSTR bstrServerName = NULL;
  584. NDSOBJECT object;
  585. VARIANT varAddress;
  586. VariantInit(&varAddress);
  587. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  588. hr = E_FAIL;
  589. BAIL_ON_FAILURE(hr);
  590. }
  591. pDispatch = V_DISPATCH(lpVarSrcObject);
  592. hr = pDispatch->QueryInterface(
  593. IID_IADsReplicaPointer,
  594. (void **)&pReplicaPointer
  595. );
  596. BAIL_ON_FAILURE(hr);
  597. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_16;
  598. hr = pReplicaPointer->get_ServerName(
  599. &bstrServerName
  600. );
  601. BAIL_ON_FAILURE(hr);
  602. lpNdsDestObject->NdsValue.value_16.ServerName=
  603. AllocADsStr(bstrServerName);
  604. hr = pReplicaPointer->get_ReplicaType((LONG *)&dwReplicaType);
  605. BAIL_ON_FAILURE(hr);
  606. lpNdsDestObject->NdsValue.value_16.ReplicaType= dwReplicaType;
  607. hr = pReplicaPointer->get_ReplicaNumber((LONG *)&dwReplicaNumber);
  608. BAIL_ON_FAILURE(hr);
  609. lpNdsDestObject->NdsValue.value_16.ReplicaNumber= dwReplicaNumber;
  610. hr = pReplicaPointer->get_Count((LONG *)&dwCount);
  611. BAIL_ON_FAILURE(hr);
  612. lpNdsDestObject->NdsValue.value_16.Count= dwCount;
  613. hr = pReplicaPointer->get_ReplicaAddressHints(&varAddress);
  614. BAIL_ON_FAILURE(hr);
  615. hr = VarTypeToNdsTypeCopyNDSSynId12(
  616. &varAddress,
  617. &object
  618. );
  619. BAIL_ON_FAILURE(hr);
  620. memcpy(&lpNdsDestObject->NdsValue.value_16.ReplicaAddressHints,
  621. object.NdsValue.value_16.ReplicaAddressHints,
  622. sizeof(NDS_ASN1_TYPE_12));
  623. error:
  624. VariantClear(&varAddress);
  625. if (pReplicaPointer) {
  626. pReplicaPointer->Release();
  627. }
  628. RRETURN(hr);
  629. }
  630. HRESULT
  631. VarTypeToNdsTypeCopyNDSSynId17(
  632. PVARIANT lpVarSrcObject,
  633. PNDSOBJECT lpNdsDestObject
  634. )
  635. {
  636. HRESULT hr = S_OK;
  637. IADsAcl FAR * pSecDes = NULL;
  638. IDispatch FAR * pDispatch = NULL;
  639. DWORD dwPrivileges = 0;
  640. BSTR bstrProtectedAttrName = NULL;
  641. BSTR bstrSubjectName = NULL;
  642. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  643. hr = E_FAIL;
  644. BAIL_ON_FAILURE(hr);
  645. }
  646. pDispatch = V_DISPATCH(lpVarSrcObject);
  647. hr = pDispatch->QueryInterface(
  648. IID_IADsAcl,
  649. (void **)&pSecDes
  650. );
  651. BAIL_ON_FAILURE(hr);
  652. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_17;
  653. hr = pSecDes->get_ProtectedAttrName(
  654. &bstrProtectedAttrName
  655. );
  656. BAIL_ON_FAILURE(hr);
  657. lpNdsDestObject->NdsValue.value_17.ProtectedAttrName =
  658. AllocADsStr(bstrProtectedAttrName);
  659. hr = pSecDes->get_SubjectName(
  660. &bstrSubjectName
  661. );
  662. BAIL_ON_FAILURE(hr);
  663. lpNdsDestObject->NdsValue.value_17.SubjectName=
  664. AllocADsStr(bstrSubjectName);
  665. hr = pSecDes->get_Privileges((LONG *)&dwPrivileges);
  666. BAIL_ON_FAILURE(hr);
  667. lpNdsDestObject->NdsValue.value_17.Privileges= dwPrivileges;
  668. error:
  669. if (pSecDes) {
  670. pSecDes->Release();
  671. }
  672. RRETURN(hr);
  673. }
  674. HRESULT
  675. VarTypeToNdsTypeCopyNDSSynId18(
  676. PVARIANT lpVarSrcObject,
  677. PNDSOBJECT lpNdsDestObject
  678. )
  679. {
  680. HRESULT hr = S_OK;
  681. DWORD dwSLBound = 0;
  682. DWORD dwSUBound = 0;
  683. long i;
  684. IADsPostalAddress FAR * pPostalAddress = NULL;
  685. IDispatch FAR * pDispatch = NULL;
  686. VARIANT varPostalAddress;
  687. VARIANT varElement;
  688. BSTR bstrElement;
  689. VariantInit(&varPostalAddress);
  690. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  691. hr = E_FAIL;
  692. BAIL_ON_FAILURE(hr);
  693. }
  694. pDispatch = V_DISPATCH(lpVarSrcObject);
  695. hr = pDispatch->QueryInterface(
  696. IID_IADsPostalAddress,
  697. (void **)&pPostalAddress
  698. );
  699. BAIL_ON_FAILURE(hr);
  700. hr = pPostalAddress->get_PostalAddress(
  701. &varPostalAddress
  702. );
  703. BAIL_ON_FAILURE(hr);
  704. if(!((V_VT(&varPostalAddress) & VT_VARIANT) && V_ISARRAY(&varPostalAddress))) {
  705. return(E_FAIL);
  706. }
  707. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_18;
  708. if ((V_ARRAY(&varPostalAddress))->cDims != 1) {
  709. hr = E_FAIL;
  710. BAIL_ON_FAILURE(hr);
  711. }
  712. if ( ((V_ARRAY(&varPostalAddress))->rgsabound[0].cElements <= 0) ||
  713. ((V_ARRAY(&varPostalAddress))->rgsabound[0].cElements >6) ) {
  714. hr = E_FAIL;
  715. BAIL_ON_FAILURE(hr);
  716. }
  717. hr = SafeArrayGetLBound(V_ARRAY(&varPostalAddress),
  718. 1,
  719. (long FAR *)&dwSLBound
  720. );
  721. BAIL_ON_FAILURE(hr);
  722. hr = SafeArrayGetUBound(V_ARRAY(&varPostalAddress),
  723. 1,
  724. (long FAR *)&dwSUBound
  725. );
  726. BAIL_ON_FAILURE(hr);
  727. for (i = dwSLBound; i <= (long)dwSUBound; i++) {
  728. VariantInit(&varElement);
  729. hr = SafeArrayGetElement(V_ARRAY(&varPostalAddress),
  730. (long FAR *)&i,
  731. &varElement
  732. );
  733. BAIL_ON_FAILURE(hr);
  734. lpNdsDestObject->NdsValue.value_18.PostalAddress[i-dwSLBound] =
  735. AllocADsStr(V_BSTR(&varElement));
  736. VariantClear(&varElement);
  737. }
  738. error:
  739. VariantClear(&varPostalAddress);
  740. if (pPostalAddress) {
  741. pPostalAddress->Release();
  742. }
  743. RRETURN(hr);
  744. }
  745. HRESULT
  746. VarTypeToNdsTypeCopyNDSSynId19(
  747. PVARIANT lpVarSrcObject,
  748. PNDSOBJECT lpNdsDestObject
  749. )
  750. {
  751. HRESULT hr = S_OK;
  752. IADsTimestamp FAR * pTime = NULL;
  753. IDispatch FAR * pDispatch = NULL;
  754. long dwEventID = 0;
  755. long dwWholeSeconds = 0;
  756. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  757. hr = E_FAIL;
  758. BAIL_ON_FAILURE(hr);
  759. }
  760. pDispatch = V_DISPATCH(lpVarSrcObject);
  761. hr = pDispatch->QueryInterface(
  762. IID_IADsTimestamp,
  763. (void **)&pTime
  764. );
  765. BAIL_ON_FAILURE(hr);
  766. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_19;
  767. hr = pTime->get_WholeSeconds(
  768. &dwWholeSeconds
  769. );
  770. BAIL_ON_FAILURE(hr);
  771. lpNdsDestObject->NdsValue.value_19.WholeSeconds= dwWholeSeconds;
  772. BAIL_ON_FAILURE(hr);
  773. hr = pTime->get_EventID(
  774. &dwEventID
  775. );
  776. BAIL_ON_FAILURE(hr);
  777. lpNdsDestObject->NdsValue.value_19.EventID = dwEventID;
  778. BAIL_ON_FAILURE(hr);
  779. error:
  780. if (pTime) {
  781. pTime->Release();
  782. }
  783. RRETURN(hr);
  784. }
  785. HRESULT
  786. VarTypeToNdsTypeCopyNDSSynId20(
  787. PVARIANT lpVarSrcObject,
  788. PNDSOBJECT lpNdsDestObject
  789. )
  790. {
  791. HRESULT hr = S_OK;
  792. if(lpVarSrcObject->vt != VT_BSTR){
  793. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  794. }
  795. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_20;
  796. lpNdsDestObject->NdsValue.value_20.ClassName =
  797. AllocADsStr(
  798. lpVarSrcObject->bstrVal
  799. );
  800. RRETURN(hr);
  801. }
  802. HRESULT
  803. VarTypeToNdsTypeCopyNDSSynId21(
  804. PVARIANT lpVarSrcObject,
  805. PNDSOBJECT lpNdsDestObject
  806. )
  807. {
  808. HRESULT hr;
  809. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_21;
  810. hr = VariantToBinary(
  811. lpVarSrcObject,
  812. &lpNdsDestObject->NdsValue.value_21.Length,
  813. &lpNdsDestObject->NdsValue.value_21.Data
  814. );
  815. RRETURN(hr);
  816. }
  817. HRESULT
  818. VarTypeToNdsTypeCopyNDSSynId22(
  819. PVARIANT lpVarSrcObject,
  820. PNDSOBJECT lpNdsDestObject
  821. )
  822. {
  823. HRESULT hr = S_OK;
  824. if(lpVarSrcObject->vt != VT_I4){
  825. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  826. }
  827. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_22;
  828. lpNdsDestObject->NdsValue.value_22.Counter =
  829. lpVarSrcObject->lVal;
  830. RRETURN(hr);
  831. }
  832. HRESULT
  833. VarTypeToNdsTypeCopyNDSSynId23(
  834. PVARIANT lpVarSrcObject,
  835. PNDSOBJECT lpNdsDestObject
  836. )
  837. {
  838. HRESULT hr = S_OK;
  839. IADsBackLink FAR * pBackLink = NULL;
  840. IDispatch FAR * pDispatch = NULL;
  841. long dwRemoteID = 0;
  842. BSTR bstrObjectName = NULL;
  843. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  844. hr = E_FAIL;
  845. BAIL_ON_FAILURE(hr);
  846. }
  847. pDispatch = V_DISPATCH(lpVarSrcObject);
  848. hr = pDispatch->QueryInterface(
  849. IID_IADsBackLink,
  850. (void **)&pBackLink
  851. );
  852. BAIL_ON_FAILURE(hr);
  853. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_23;
  854. hr = pBackLink->get_ObjectName(
  855. &bstrObjectName
  856. );
  857. BAIL_ON_FAILURE(hr);
  858. lpNdsDestObject->NdsValue.value_23.ObjectName=
  859. AllocADsStr(bstrObjectName);
  860. hr = pBackLink->get_RemoteID((LONG *)&dwRemoteID);
  861. BAIL_ON_FAILURE(hr);
  862. lpNdsDestObject->NdsValue.value_23.RemoteID = dwRemoteID;
  863. error:
  864. if (pBackLink) {
  865. pBackLink->Release();
  866. }
  867. RRETURN(hr);
  868. }
  869. HRESULT
  870. VarTypeToNdsTypeCopyNDSSynId24(
  871. PVARIANT lpVarSrcObject,
  872. PNDSOBJECT lpNdsDestObject
  873. )
  874. {
  875. HRESULT hr = S_OK;
  876. if(lpVarSrcObject->vt != VT_DATE){
  877. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  878. }
  879. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_24;
  880. hr = ConvertDATEtoDWORD(
  881. lpVarSrcObject->date,
  882. &(lpNdsDestObject->NdsValue.value_24.Time),
  883. TRUE
  884. );
  885. RRETURN(hr);
  886. }
  887. HRESULT
  888. VarTypeToNdsTypeCopyNDSSynId25(
  889. PVARIANT lpVarSrcObject,
  890. PNDSOBJECT lpNdsDestObject
  891. )
  892. {
  893. HRESULT hr = S_OK;
  894. IADsTypedName FAR * pTypedName = NULL;
  895. IDispatch FAR * pDispatch = NULL;
  896. DWORD dwLevel = 0;
  897. DWORD dwInterval = 0;
  898. BSTR bstrObjectName = NULL;
  899. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  900. hr = E_FAIL;
  901. BAIL_ON_FAILURE(hr);
  902. }
  903. pDispatch = V_DISPATCH(lpVarSrcObject);
  904. hr = pDispatch->QueryInterface(
  905. IID_IADsTypedName,
  906. (void **)&pTypedName
  907. );
  908. BAIL_ON_FAILURE(hr);
  909. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_25;
  910. hr = pTypedName->get_ObjectName(
  911. &bstrObjectName
  912. );
  913. BAIL_ON_FAILURE(hr);
  914. lpNdsDestObject->NdsValue.value_25.ObjectName=
  915. AllocADsStr(bstrObjectName);
  916. hr = pTypedName->get_Level((LONG *)&dwLevel);
  917. BAIL_ON_FAILURE(hr);
  918. lpNdsDestObject->NdsValue.value_25.Level = dwLevel;
  919. hr = pTypedName->get_Interval((LONG *)&dwInterval);
  920. BAIL_ON_FAILURE(hr);
  921. lpNdsDestObject->NdsValue.value_25.Interval= dwInterval;
  922. error:
  923. if (pTypedName) {
  924. pTypedName->Release();
  925. }
  926. RRETURN(hr);
  927. }
  928. HRESULT
  929. VarTypeToNdsTypeCopyNDSSynId26(
  930. PVARIANT lpVarSrcObject,
  931. PNDSOBJECT lpNdsDestObject
  932. )
  933. {
  934. HRESULT hr = S_OK;
  935. IADsHold FAR * pHold = NULL;
  936. IDispatch FAR * pDispatch = NULL;
  937. DWORD dwAmount = 0;
  938. BSTR bstrObjectName = NULL;
  939. if (V_VT(lpVarSrcObject) != VT_DISPATCH){
  940. hr = E_FAIL;
  941. BAIL_ON_FAILURE(hr);
  942. }
  943. pDispatch = V_DISPATCH(lpVarSrcObject);
  944. hr = pDispatch->QueryInterface(
  945. IID_IADsHold,
  946. (void **)&pHold
  947. );
  948. BAIL_ON_FAILURE(hr);
  949. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_26;
  950. hr = pHold->get_ObjectName(
  951. &bstrObjectName
  952. );
  953. BAIL_ON_FAILURE(hr);
  954. lpNdsDestObject->NdsValue.value_26.ObjectName=
  955. AllocADsStr(bstrObjectName);
  956. hr = pHold->get_Amount((LONG *)&dwAmount);
  957. BAIL_ON_FAILURE(hr);
  958. lpNdsDestObject->NdsValue.value_26.Amount = dwAmount;
  959. error:
  960. if (pHold) {
  961. pHold->Release();
  962. }
  963. RRETURN(hr);
  964. }
  965. HRESULT
  966. VarTypeToNdsTypeCopyNDSSynId27(
  967. PVARIANT lpVarSrcObject,
  968. PNDSOBJECT lpNdsDestObject
  969. )
  970. {
  971. HRESULT hr = S_OK;
  972. if(lpVarSrcObject->vt != VT_I4){
  973. RRETURN(hr = E_ADS_CANT_CONVERT_DATATYPE);
  974. }
  975. lpNdsDestObject->NdsType = NDS_SYNTAX_ID_27;
  976. lpNdsDestObject->NdsValue.value_27.Interval =
  977. lpVarSrcObject->lVal;
  978. RRETURN(hr);
  979. }
  980. HRESULT
  981. VarTypeToNdsTypeCopy(
  982. DWORD dwNdsType,
  983. PVARIANT lpVarSrcObject,
  984. PNDSOBJECT lpNdsDestObject
  985. )
  986. {
  987. HRESULT hr = S_OK;
  988. switch (dwNdsType){
  989. case 1:
  990. hr = VarTypeToNdsTypeCopyNDSSynId1(
  991. lpVarSrcObject,
  992. lpNdsDestObject
  993. );
  994. break;
  995. case 2:
  996. hr = VarTypeToNdsTypeCopyNDSSynId2(
  997. lpVarSrcObject,
  998. lpNdsDestObject
  999. );
  1000. break;
  1001. case 3:
  1002. hr = VarTypeToNdsTypeCopyNDSSynId3(
  1003. lpVarSrcObject,
  1004. lpNdsDestObject
  1005. );
  1006. break;
  1007. case 4:
  1008. hr = VarTypeToNdsTypeCopyNDSSynId4(
  1009. lpVarSrcObject,
  1010. lpNdsDestObject
  1011. );
  1012. break;
  1013. case 5:
  1014. hr = VarTypeToNdsTypeCopyNDSSynId5(
  1015. lpVarSrcObject,
  1016. lpNdsDestObject
  1017. );
  1018. break;
  1019. case 6:
  1020. hr = VarTypeToNdsTypeCopyNDSSynId6(
  1021. lpVarSrcObject,
  1022. lpNdsDestObject
  1023. );
  1024. break;
  1025. case 7:
  1026. hr = VarTypeToNdsTypeCopyNDSSynId7(
  1027. lpVarSrcObject,
  1028. lpNdsDestObject
  1029. );
  1030. break;
  1031. case 8:
  1032. hr = VarTypeToNdsTypeCopyNDSSynId8(
  1033. lpVarSrcObject,
  1034. lpNdsDestObject
  1035. );
  1036. break;
  1037. case 9:
  1038. hr = VarTypeToNdsTypeCopyNDSSynId9(
  1039. lpVarSrcObject,
  1040. lpNdsDestObject
  1041. );
  1042. break;
  1043. case 10:
  1044. hr = VarTypeToNdsTypeCopyNDSSynId10(
  1045. lpVarSrcObject,
  1046. lpNdsDestObject
  1047. );
  1048. break;
  1049. case 11:
  1050. hr = VarTypeToNdsTypeCopyNDSSynId11(
  1051. lpVarSrcObject,
  1052. lpNdsDestObject
  1053. );
  1054. break;
  1055. case 12:
  1056. hr = VarTypeToNdsTypeCopyNDSSynId12(
  1057. lpVarSrcObject,
  1058. lpNdsDestObject
  1059. );
  1060. break;
  1061. case 13:
  1062. hr = VarTypeToNdsTypeCopyNDSSynId13(
  1063. lpVarSrcObject,
  1064. lpNdsDestObject
  1065. );
  1066. break;
  1067. case 14:
  1068. hr = VarTypeToNdsTypeCopyNDSSynId14(
  1069. lpVarSrcObject,
  1070. lpNdsDestObject
  1071. );
  1072. break;
  1073. case 15:
  1074. hr = VarTypeToNdsTypeCopyNDSSynId15(
  1075. lpVarSrcObject,
  1076. lpNdsDestObject
  1077. );
  1078. break;
  1079. case 16:
  1080. hr = VarTypeToNdsTypeCopyNDSSynId16(
  1081. lpVarSrcObject,
  1082. lpNdsDestObject
  1083. );
  1084. break;
  1085. case 17:
  1086. hr = VarTypeToNdsTypeCopyNDSSynId17(
  1087. lpVarSrcObject,
  1088. lpNdsDestObject
  1089. );
  1090. break;
  1091. case 18:
  1092. hr = VarTypeToNdsTypeCopyNDSSynId18(
  1093. lpVarSrcObject,
  1094. lpNdsDestObject
  1095. );
  1096. break;
  1097. case 19:
  1098. hr = VarTypeToNdsTypeCopyNDSSynId19(
  1099. lpVarSrcObject,
  1100. lpNdsDestObject
  1101. );
  1102. break;
  1103. case 20:
  1104. hr = VarTypeToNdsTypeCopyNDSSynId20(
  1105. lpVarSrcObject,
  1106. lpNdsDestObject
  1107. );
  1108. break;
  1109. case 21:
  1110. hr = VarTypeToNdsTypeCopyNDSSynId21(
  1111. lpVarSrcObject,
  1112. lpNdsDestObject
  1113. );
  1114. break;
  1115. case 22:
  1116. hr = VarTypeToNdsTypeCopyNDSSynId22(
  1117. lpVarSrcObject,
  1118. lpNdsDestObject
  1119. );
  1120. break;
  1121. case 23:
  1122. hr = VarTypeToNdsTypeCopyNDSSynId23(
  1123. lpVarSrcObject,
  1124. lpNdsDestObject
  1125. );
  1126. break;
  1127. case 24:
  1128. hr = VarTypeToNdsTypeCopyNDSSynId24(
  1129. lpVarSrcObject,
  1130. lpNdsDestObject
  1131. );
  1132. break;
  1133. case 25:
  1134. hr = VarTypeToNdsTypeCopyNDSSynId25(
  1135. lpVarSrcObject,
  1136. lpNdsDestObject
  1137. );
  1138. break;
  1139. case 26:
  1140. hr = VarTypeToNdsTypeCopyNDSSynId26(
  1141. lpVarSrcObject,
  1142. lpNdsDestObject
  1143. );
  1144. break;
  1145. case 27:
  1146. hr = VarTypeToNdsTypeCopyNDSSynId27(
  1147. lpVarSrcObject,
  1148. lpNdsDestObject
  1149. );
  1150. break;
  1151. default:
  1152. hr = E_FAIL;
  1153. break;
  1154. }
  1155. RRETURN(hr);
  1156. }
  1157. HRESULT
  1158. VarTypeToNdsTypeCopyConstruct(
  1159. DWORD dwNdsType,
  1160. LPVARIANT pVarSrcObjects,
  1161. DWORD *pdwNumObjects,
  1162. LPNDSOBJECT * ppNdsDestObjects
  1163. )
  1164. {
  1165. DWORD i = 0;
  1166. LPNDSOBJECT pNdsDestObjects = NULL;
  1167. HRESULT hr = S_OK;
  1168. VARIANT varNDSAcl;
  1169. IDispatch * pDispatch = NULL;
  1170. IADsSecurityDescriptor * pSecDes = NULL;
  1171. DWORD dwNumObjects = *pdwNumObjects;
  1172. //
  1173. // If it is a security descriptor, do special conversion
  1174. //
  1175. if (dwNdsType == 17) {
  1176. //
  1177. // Bail out if it contains more than 1 object
  1178. //
  1179. if (dwNumObjects != 1) {
  1180. hr = E_FAIL;
  1181. BAIL_ON_FAILURE(hr);
  1182. }
  1183. if (V_VT(pVarSrcObjects) != VT_DISPATCH){
  1184. hr = E_FAIL;
  1185. BAIL_ON_FAILURE(hr);
  1186. }
  1187. pDispatch = V_DISPATCH(pVarSrcObjects);
  1188. hr = pDispatch->QueryInterface(
  1189. IID_IADsSecurityDescriptor,
  1190. (void **)&pSecDes
  1191. );
  1192. BAIL_ON_FAILURE(hr);
  1193. hr = ConvertSecDesToNDSAclVarArray(
  1194. pSecDes,
  1195. &varNDSAcl
  1196. );
  1197. BAIL_ON_FAILURE(hr);
  1198. hr = ConvertSafeArrayToVariantArray(
  1199. varNDSAcl,
  1200. &pVarSrcObjects,
  1201. &dwNumObjects
  1202. );
  1203. BAIL_ON_FAILURE(hr);
  1204. pNdsDestObjects = (LPNDSOBJECT)AllocADsMem(
  1205. dwNumObjects * sizeof(NDSOBJECT)
  1206. );
  1207. if (!pNdsDestObjects) {
  1208. RRETURN(E_FAIL);
  1209. }
  1210. *pdwNumObjects = dwNumObjects;
  1211. }
  1212. else {
  1213. pNdsDestObjects = (LPNDSOBJECT)AllocADsMem(
  1214. dwNumObjects * sizeof(NDSOBJECT)
  1215. );
  1216. if (!pNdsDestObjects) {
  1217. RRETURN(E_FAIL);
  1218. }
  1219. }
  1220. for (i = 0; i < dwNumObjects; i++ ) {
  1221. hr = VarTypeToNdsTypeCopy(
  1222. dwNdsType,
  1223. pVarSrcObjects + i,
  1224. pNdsDestObjects + i
  1225. );
  1226. BAIL_ON_FAILURE(hr);
  1227. }
  1228. *ppNdsDestObjects = pNdsDestObjects;
  1229. if (pSecDes) {
  1230. pSecDes->Release();
  1231. }
  1232. RRETURN(S_OK);
  1233. error:
  1234. if (pNdsDestObjects) {
  1235. NdsTypeFreeNdsObjects(
  1236. pNdsDestObjects,
  1237. dwNumObjects
  1238. );
  1239. }
  1240. if (pSecDes) {
  1241. pSecDes->Release();
  1242. }
  1243. *ppNdsDestObjects = NULL;
  1244. RRETURN(hr);
  1245. }