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.

1033 lines
27 KiB

  1. /+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: ndsmrshl.cxx
  7. //
  8. // Contents:
  9. //
  10. // Functions:
  11. //
  12. //
  13. // History: 25-Apr-96 KrishnaG Created.
  14. //
  15. //----------------------------------------------------------------------------
  16. #include "nds.hxx"
  17. HRESULT
  18. CopyNDSNetAddressToNDS12(
  19. pNet_Address_T lpSrcNetAddress,
  20. LPNDS_ASN1_TYPE_12 lpDest12
  21. )
  22. {
  23. LPBYTE pBuffer = NULL;
  24. lpDest12->AddressType = lpSrcNetAddress->addressType;
  25. lpDest12->AddressLength = lpSrcNetAddress->addressLength;
  26. if (lpSrcNetAddress->addressLength) {
  27. pBuffer = (LPBYTE)AllocADsMem(lpSrcNetAddress->addressLength);
  28. if (!pBuffer) {
  29. RRETURN(E_OUTOFMEMORY);
  30. }
  31. memcpy(pBuffer, lpSrcNetAddress->address, lpSrcNetAddress->addressLength);
  32. lpDest12->Address = pBuffer;
  33. }else {
  34. lpDest12->Address = NULL;
  35. }
  36. RRETURN(S_OK);
  37. }
  38. HRESULT
  39. CopyNDS12ToNDSNetAddress(
  40. LPNDS_ASN1_TYPE_12 lpSrc12,
  41. pNet_Address_T lpDestNetAddress
  42. )
  43. {
  44. LPBYTE pBuffer = NULL;
  45. lpDestNetAddress->addressType = lpSrc12->AddressType;
  46. lpDestNetAddress->addressLength = lpSrc12->AddressLength;
  47. if (lpSrc12->AddressLength) {
  48. pBuffer = (LPBYTE)AllocADsMem(lpSrc12->AddressLength);
  49. if (!pBuffer) {
  50. RRETURN(E_OUTOFMEMORY);
  51. }
  52. memcpy(pBuffer, lpSrc12->Address, lpSrc12->AddressLength);
  53. lpDestNetAddress->address = pBuffer;
  54. }else {
  55. lpDestNetAddress->address = NULL;
  56. }
  57. RRETURN(S_OK);
  58. }
  59. HRESULT
  60. CopyNdsValueToNdsObject(
  61. nptr attrVal,
  62. nuint32 luAttrValSize,
  63. nuint32 luSyntax,
  64. PNDSOBJECT pNdsObject
  65. )
  66. {
  67. HRESULT hr = S_OK;
  68. if (!pNdsObject || !attrVal) {
  69. RRETURN (E_ADS_BAD_PARAMETER);
  70. }
  71. pNdsObject->NdsType = luSyntax;
  72. switch (luSyntax) {
  73. case 1:
  74. pNdsObject->NdsValue.value_1.DNString = AllocADsStr( (LPWSTR) attrVal);
  75. break;
  76. case 2:
  77. pNdsObject->NdsValue.value_2.CaseExactString = AllocADsStr( (LPWSTR) attrVal);
  78. break;
  79. case 3:
  80. pNdsObject->NdsValue.value_3.CaseIgnoreString = AllocADsStr( (LPWSTR) attrVal);
  81. break;
  82. case 4:
  83. pNdsObject->NdsValue.value_4.PrintableString = AllocADsStr( (LPWSTR) attrVal);
  84. break;
  85. case 5:
  86. pNdsObject->NdsValue.value_5.NumericString = AllocADsStr( (LPWSTR) attrVal);
  87. break;
  88. case 6: {
  89. pCI_List_T pCaseIgnoreList = (pCI_List_T) attrVal;
  90. LPNDS_ASN1_TYPE_6 pNdsTempASN1_6 = NULL;
  91. LPNDS_ASN1_TYPE_6 pNdsNextASN1_6 = NULL;
  92. pNdsTempASN1_6 = &(pNdsObject->NdsValue.value_6);
  93. pNdsObject->NdsType = NDS_SYNTAX_ID_6;
  94. if (! pCaseIgnoreList->s) {
  95. pNdsTempASN1_6->String = NULL;
  96. pNdsTempASN1_6->Next = NULL;
  97. RRETURN (S_OK);
  98. }
  99. pNdsTempASN1_6->String =
  100. (LPWSTR)AllocADsStr((LPWSTR) pCaseIgnoreList->s);
  101. while ( pCaseIgnoreList->next != NULL )
  102. {
  103. pCaseIgnoreList = pCaseIgnoreList->next;
  104. pNdsNextASN1_6 =
  105. (LPNDS_ASN1_TYPE_6)AllocADsMem(sizeof(NDS_ASN1_TYPE_6));
  106. if (!pNdsNextASN1_6) {
  107. //
  108. // BUGBUG: need to clean up the list
  109. //
  110. RRETURN(E_OUTOFMEMORY);
  111. }
  112. pNdsNextASN1_6->String =
  113. (LPWSTR)AllocADsStr((LPWSTR) pCaseIgnoreList->s);
  114. if (!pNdsNextASN1_6->String) {
  115. //
  116. // BUGBUG: need to clean up the list
  117. //
  118. RRETURN(E_OUTOFMEMORY);
  119. }
  120. pNdsTempASN1_6->Next = pNdsNextASN1_6;
  121. pNdsTempASN1_6 = pNdsNextASN1_6;
  122. }
  123. pNdsTempASN1_6->Next = NULL;
  124. break;
  125. }
  126. case 7:
  127. pNdsObject->NdsValue.value_7.Boolean = *((Boolean_T *) attrVal);
  128. break;
  129. case 8:
  130. pNdsObject->NdsValue.value_8.Integer = *((Integer_T *) attrVal);
  131. break;
  132. case 9: {
  133. pOctet_String_T lpNdsOctetString = (pOctet_String_T) attrVal;
  134. if (lpNdsOctetString->length) {
  135. pNdsObject->NdsValue.value_9.Length = lpNdsOctetString->length;
  136. pNdsObject->NdsValue.value_9.OctetString =
  137. (LPBYTE) AllocADsMem(lpNdsOctetString->length);
  138. if (!pNdsObject->NdsValue.value_9.OctetString) {
  139. RRETURN(E_OUTOFMEMORY);
  140. }
  141. memcpy(
  142. pNdsObject->NdsValue.value_9.OctetString,
  143. lpNdsOctetString->data,
  144. lpNdsOctetString->length
  145. );
  146. }
  147. else {
  148. pNdsObject->NdsValue.value_9.OctetString = NULL;
  149. pNdsObject->NdsValue.value_9.Length = 0;
  150. }
  151. break;
  152. }
  153. case 10:
  154. pNdsObject->NdsValue.value_10.TelephoneNumber = AllocADsStr( (LPWSTR) attrVal);
  155. break;
  156. case 11: {
  157. pFax_Number_T pNdsFaxNumber = (pFax_Number_T) attrVal;
  158. LPNDS_ASN1_TYPE_11 pNdsASN1_11 = &(pNdsObject->NdsValue.value_11);
  159. pNdsASN1_11->TelephoneNumber = AllocADsStr((LPWSTR)pNdsFaxNumber->telephoneNumber);
  160. pNdsASN1_11->NumberOfBits = pNdsFaxNumber->parameters.numOfBits;
  161. pNdsASN1_11->Parameters = (LPBYTE) AllocADsMem((pNdsASN1_11->NumberOfBits + 7) / 8);
  162. if (!pNdsASN1_11->Parameters) {
  163. RRETURN (E_OUTOFMEMORY);
  164. }
  165. memcpy(
  166. pNdsASN1_11->Parameters,
  167. pNdsFaxNumber->parameters.data,
  168. ((pNdsASN1_11->NumberOfBits+7) / 8)
  169. );
  170. break;
  171. }
  172. case 12: {
  173. pNet_Address_T pNetAddress = (pNet_Address_T) attrVal;
  174. LPBYTE pBuffer = NULL;
  175. pNdsObject->NdsValue.value_12.AddressType = pNetAddress->addressType;
  176. pNdsObject->NdsValue.value_12.AddressLength = pNetAddress->addressLength;
  177. if (pNetAddress->addressLength) {
  178. pBuffer = (LPBYTE)AllocADsMem(pNetAddress->addressLength);
  179. if (!pBuffer) {
  180. RRETURN(E_OUTOFMEMORY);
  181. }
  182. memcpy(pBuffer, pNetAddress->address, pNetAddress->addressLength);
  183. pNdsObject->NdsValue.value_12.Address = pBuffer;
  184. }
  185. break;
  186. }
  187. case 13: {
  188. pOctet_List_T pOctetList = (pOctet_List_T) attrVal;
  189. LPNDS_ASN1_TYPE_13 * lppNext = NULL;
  190. LPBYTE lpBuffer = NULL;
  191. LPNDS_ASN1_TYPE_13 pNextObj = NULL;
  192. lpBuffer = (LPBYTE)AllocADsMem(pOctetList->length);
  193. if (!lpBuffer) {
  194. RRETURN(E_OUTOFMEMORY);
  195. }
  196. memcpy(lpBuffer, pOctetList->data, pOctetList->length);
  197. pNdsObject->NdsValue.value_13.Length = pOctetList->length;
  198. pNdsObject->NdsValue.value_13.Data = lpBuffer;
  199. lppNext = &(pNdsObject->NdsValue.value_13.Next);
  200. while ( pOctetList->next != NULL )
  201. {
  202. pOctetList = pOctetList->next;
  203. pNextObj =
  204. (LPNDS_ASN1_TYPE_13)AllocADsMem(sizeof(NDS_ASN1_TYPE_13));
  205. if (!pNextObj) {
  206. // BUGBUG: need to clean up list
  207. RRETURN(E_OUTOFMEMORY);
  208. }
  209. lpBuffer = (LPBYTE)AllocADsMem(pOctetList->length);
  210. memcpy(lpBuffer, pOctetList->data, pOctetList->length);
  211. pNextObj->Length = pOctetList->length;
  212. pNextObj->Data = lpBuffer;
  213. *lppNext = pNextObj;
  214. lppNext = &pNextObj->Next;
  215. }
  216. break;
  217. }
  218. case 14: {
  219. pEMail_Address_T pEmailAddress = (pEMail_Address_T) attrVal;
  220. pNdsObject->NdsValue.value_14.Type = pEmailAddress->type;
  221. pNdsObject->NdsValue.value_14.Address =
  222. (LPWSTR)AllocADsStr((LPWSTR) pEmailAddress->address);
  223. break;
  224. }
  225. case 15: {
  226. pPath_T pPath = (pPath_T) attrVal;
  227. pNdsObject->NdsValue.value_15.Type = pPath->nameSpaceType;
  228. pNdsObject->NdsValue.value_15.VolumeName =
  229. (LPWSTR)AllocADsStr( (LPWSTR) pPath->volumeName);
  230. pNdsObject->NdsValue.value_15.Path =
  231. (LPWSTR)AllocADsStr( (LPWSTR) pPath->path);
  232. if (!pNdsObject->NdsValue.value_15.Path) {
  233. RRETURN(E_OUTOFMEMORY);
  234. }
  235. break;
  236. }
  237. case 16: {
  238. pReplica_Pointer_T pReplicaPtr = (pReplica_Pointer_T) attrVal;
  239. LPNDS_ASN1_TYPE_12 pNdsASN1_12 = NULL;
  240. DWORD iter = 0;
  241. pNdsObject->NdsValue.value_16.ServerName =
  242. (LPWSTR)AllocADsStr((LPWSTR) pReplicaPtr->serverName);
  243. pNdsObject->NdsValue.value_16.ReplicaType = pReplicaPtr->replicaType;
  244. pNdsObject->NdsValue.value_16.ReplicaNumber = pReplicaPtr->replicaNumber;
  245. pNdsObject->NdsValue.value_16.Count = pReplicaPtr->count;
  246. //
  247. // NDS is kinda goofy. It stores one substructure as part of the
  248. // containing data type instead of a pointer to the object.
  249. //
  250. pNdsASN1_12 = (LPNDS_ASN1_TYPE_12)AllocADsMem(
  251. pReplicaPtr->count * sizeof(NDS_ASN1_TYPE_12)
  252. );
  253. if (!pNdsASN1_12) {
  254. RRETURN (E_OUTOFMEMORY);
  255. }
  256. pNdsObject->NdsValue.value_16.ReplicaAddressHints = pNdsASN1_12;
  257. for ( iter = 0; iter < pReplicaPtr->count; iter++ )
  258. {
  259. hr = CopyNDSNetAddressToNDS12(
  260. pReplicaPtr->replicaAddressHint + iter,
  261. (pNdsASN1_12 + iter)
  262. );
  263. BAIL_ON_FAILURE(hr);
  264. }
  265. break;
  266. }
  267. case 17: {
  268. pObject_ACL_T pObjectACL = (pObject_ACL_T) attrVal;
  269. pNdsObject->NdsValue.value_17.ProtectedAttrName =
  270. (LPWSTR)AllocADsStr((LPWSTR) pObjectACL->protectedAttrName);
  271. pNdsObject->NdsValue.value_17.SubjectName =
  272. (LPWSTR)AllocADsStr((LPWSTR) pObjectACL->subjectName);
  273. pNdsObject->NdsValue.value_17.Privileges =
  274. pObjectACL->privileges;
  275. break;
  276. }
  277. case 18: {
  278. LPWSTR *pPostalAddresses = (LPWSTR *) attrVal;
  279. for (DWORD i = 0; i < 6; i++) {
  280. pNdsObject->NdsValue.value_18.PostalAddress[i] =
  281. (LPWSTR)AllocADsStr((LPWSTR) pPostalAddresses[i]);
  282. }
  283. break;
  284. }
  285. case 19: {
  286. pNWDS_TimeStamp_T pTimeStamp = (pNWDS_TimeStamp_T) attrVal;
  287. pNdsObject->NdsValue.value_19.WholeSeconds = pTimeStamp->wholeSeconds;
  288. pNdsObject->NdsValue.value_19.EventID = pTimeStamp->eventID;
  289. break;
  290. }
  291. case 20:
  292. pNdsObject->NdsValue.value_20.ClassName = AllocADsStr( (LPWSTR) attrVal);
  293. break;
  294. case 21: {
  295. pStream_T lpASN1_21 = (pStream_T) attrVal;
  296. //
  297. // The Length value is supposedly always zero!!
  298. //
  299. pNdsObject->NdsValue.value_21.Length = lpASN1_21->length;
  300. pNdsObject->NdsValue.value_21.Data = NULL;
  301. break;
  302. }
  303. case 22:
  304. pNdsObject->NdsValue.value_22.Counter = *((DWORD *) attrVal);
  305. break;
  306. case 23: {
  307. pBack_Link_T pBackLink = (pBack_Link_T) attrVal;
  308. pNdsObject->NdsValue.value_23.RemoteID = pBackLink->remoteID;
  309. pNdsObject->NdsValue.value_23.ObjectName =
  310. (LPWSTR)AllocADsStr( (LPWSTR) pBackLink->objectName);
  311. if (!pBackLink->objectName) {
  312. RRETURN (E_OUTOFMEMORY);
  313. }
  314. break;
  315. }
  316. case 24:
  317. pNdsObject->NdsValue.value_24.Time = *((DWORD *) attrVal);
  318. break;
  319. case 25: {
  320. pTyped_Name_T pTypedName = (pTyped_Name_T) attrVal;
  321. pNdsObject->NdsValue.value_25.ObjectName =
  322. (LPWSTR)AllocADsStr( (LPWSTR) pTypedName->objectName);
  323. pNdsObject->NdsValue.value_25.Level = pTypedName->level;
  324. pNdsObject->NdsValue.value_25.Interval = pTypedName->interval;
  325. break;
  326. }
  327. case 26: {
  328. pHold_T pHold = (pHold_T) attrVal;
  329. pNdsObject->NdsValue.value_26.ObjectName =
  330. (LPWSTR)AllocADsStr( (LPWSTR) pHold->objectName);
  331. pNdsObject->NdsValue.value_26.Amount = pHold->amount;
  332. break;
  333. }
  334. case 27:
  335. pNdsObject->NdsValue.value_27.Interval = *((DWORD *) attrVal);
  336. break;
  337. default:
  338. //
  339. // BugBug. Get the proper value from NDS
  340. //
  341. RRETURN(E_ADS_CANT_CONVERT_DATATYPE);
  342. break;
  343. }
  344. error:
  345. RRETURN (hr);
  346. }
  347. HRESULT
  348. CopyNdsObjectToNdsValue(
  349. PNDSOBJECT lpNdsObject,
  350. nptr *ppAttrVal,
  351. pnuint32 pluAttrValSize,
  352. pnuint32 pluSyntax
  353. )
  354. {
  355. HRESULT hr = S_OK;
  356. if (!lpNdsObject || !ppAttrVal || !pluAttrValSize || !pluSyntax) {
  357. RRETURN(E_ADS_BAD_PARAMETER);
  358. }
  359. *pluAttrValSize = 0;
  360. *ppAttrVal = NULL;
  361. *pluSyntax = lpNdsObject->NdsType;
  362. switch (lpNdsObject->NdsType) {
  363. case 1:
  364. *ppAttrVal = AllocADsStr( lpNdsObject->NdsValue.value_1.DNString );
  365. *pluAttrValSize = (wcslen( lpNdsObject->NdsValue.value_1.DNString ) + 1) * sizeof (WCHAR) ;
  366. break;
  367. case 2:
  368. *ppAttrVal = AllocADsStr( lpNdsObject->NdsValue.value_2.CaseExactString );
  369. *pluAttrValSize = (wcslen( lpNdsObject->NdsValue.value_2.CaseExactString ) + 1) * sizeof (WCHAR) ;
  370. break;
  371. case 3:
  372. *ppAttrVal = AllocADsStr( lpNdsObject->NdsValue.value_3.CaseIgnoreString );
  373. *pluAttrValSize = (wcslen( lpNdsObject->NdsValue.value_3.CaseIgnoreString ) + 1) * sizeof (WCHAR) ;
  374. break;
  375. case 4:
  376. *ppAttrVal = AllocADsStr( lpNdsObject->NdsValue.value_4.PrintableString );
  377. *pluAttrValSize = (wcslen( lpNdsObject->NdsValue.value_4.PrintableString ) + 1) * sizeof (WCHAR) ;
  378. break;
  379. case 5:
  380. *ppAttrVal = AllocADsStr( lpNdsObject->NdsValue.value_5.NumericString );
  381. *pluAttrValSize = (wcslen( lpNdsObject->NdsValue.value_5.NumericString ) + 1) * sizeof (WCHAR) ;
  382. break;
  383. case 6: {
  384. LPNDS_ASN1_TYPE_6 lpNdsTempASN1_6 = &(lpNdsObject->NdsValue.value_6);
  385. pCI_List_T pCaseIgnoreList = (pCI_List_T) AllocADsMem(sizeof(CI_List_T));
  386. if (!pCaseIgnoreList) {
  387. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  388. }
  389. *ppAttrVal = pCaseIgnoreList;
  390. *pluAttrValSize = sizeof(CI_List_T);
  391. pCaseIgnoreList->s = (pnchar8) AllocADsStr( lpNdsTempASN1_6->String );
  392. if (!pCaseIgnoreList->s) {
  393. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  394. }
  395. while ( lpNdsTempASN1_6->Next)
  396. {
  397. pCaseIgnoreList->next = (pCI_List_T) AllocADsMem(sizeof(CI_List_T));
  398. if (!pCaseIgnoreList->next) {
  399. // BUGBUG: need to clean up list
  400. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  401. }
  402. pCaseIgnoreList = pCaseIgnoreList->next;
  403. lpNdsTempASN1_6 = lpNdsTempASN1_6->Next;
  404. pCaseIgnoreList->s = (pnchar8) AllocADsStr( lpNdsTempASN1_6->String );
  405. if (!pCaseIgnoreList) {
  406. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  407. }
  408. }
  409. pCaseIgnoreList->next = NULL;
  410. break;
  411. }
  412. case 7: {
  413. Boolean_T *pBool = (Boolean_T *) AllocADsMem(sizeof(Boolean_T));
  414. if (!pBool) {
  415. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  416. }
  417. *pBool = *((Boolean_T *) &lpNdsObject->NdsValue.value_7.Boolean);
  418. *ppAttrVal = pBool;
  419. *pluAttrValSize = sizeof(Boolean_T);
  420. break;
  421. }
  422. case 8: {
  423. Integer_T *pInteger = (Integer_T *) AllocADsMem(sizeof(Integer_T));
  424. if (!pInteger) {
  425. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  426. }
  427. *pInteger = *((Integer_T *) &lpNdsObject->NdsValue.value_8.Integer);
  428. *ppAttrVal = pInteger;
  429. *pluAttrValSize = sizeof(Integer_T);
  430. break;
  431. }
  432. case 9: {
  433. pOctet_String_T lpOctetString = (pOctet_String_T)
  434. AllocADsMem(sizeof(Octet_String_T));
  435. if (!lpOctetString) {
  436. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  437. }
  438. if (lpNdsObject->NdsValue.value_9.Length) {
  439. lpOctetString->length = lpNdsObject->NdsValue.value_9.Length;
  440. lpOctetString->data = (LPBYTE) AllocADsMem (
  441. lpNdsObject->NdsValue.value_9.Length);
  442. if (!lpOctetString->data) {
  443. RRETURN(E_OUTOFMEMORY);
  444. }
  445. memcpy(
  446. lpOctetString->data,
  447. lpNdsObject->NdsValue.value_9.OctetString,
  448. lpNdsObject->NdsValue.value_9.Length
  449. );
  450. }
  451. else {
  452. lpOctetString->length = 0;
  453. lpOctetString->data = NULL;
  454. }
  455. *ppAttrVal = lpOctetString;
  456. *pluAttrValSize = sizeof(Octet_String_T);
  457. break;
  458. }
  459. case 10:
  460. *ppAttrVal = AllocADsStr( lpNdsObject->NdsValue.value_11.TelephoneNumber );
  461. *pluAttrValSize = (wcslen( lpNdsObject->NdsValue.value_11.TelephoneNumber ) + 1) * sizeof (WCHAR) ;
  462. break;
  463. case 11: {
  464. pFax_Number_T pFaxNumber = (pFax_Number_T) AllocADsMem(sizeof(Fax_Number_T));
  465. pFaxNumber->telephoneNumber =
  466. (pnchar8)AllocADsStr(
  467. lpNdsObject->NdsValue.value_11.TelephoneNumber
  468. );
  469. if (!pFaxNumber->telephoneNumber) {
  470. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  471. }
  472. pFaxNumber->parameters.numOfBits = lpNdsObject->NdsValue.value_11.NumberOfBits;
  473. pFaxNumber->parameters.data = (LPBYTE) AllocADsMem((pFaxNumber->parameters.numOfBits+7) / 8);
  474. memcpy(
  475. pFaxNumber->parameters.data,
  476. lpNdsObject->NdsValue.value_11.Parameters,
  477. (pFaxNumber->parameters.numOfBits+7) / 8
  478. );
  479. *ppAttrVal = pFaxNumber;
  480. *pluAttrValSize = sizeof(Fax_Number_T);
  481. break;
  482. }
  483. case 12: {
  484. pNet_Address_T pNetAddress = (pNet_Address_T) AllocADsMem(sizeof (Net_Address_T));
  485. LPBYTE pBuffer = NULL;
  486. pNetAddress->addressType = lpNdsObject->NdsValue.value_12.AddressType;
  487. pNetAddress->addressLength = lpNdsObject->NdsValue.value_12.AddressLength;
  488. pBuffer = (LPBYTE)AllocADsMem(pNetAddress->addressLength);
  489. if (!pBuffer) {
  490. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  491. }
  492. memcpy(
  493. pBuffer,
  494. lpNdsObject->NdsValue.value_12.Address,
  495. pNetAddress->addressLength
  496. );
  497. pNetAddress->address = pBuffer;
  498. *ppAttrVal = pNetAddress;
  499. *pluAttrValSize = sizeof(Net_Address_T);
  500. break;
  501. }
  502. case 13: {
  503. LPNDS_ASN1_TYPE_13 lpNdsTempASN1_13 = &(lpNdsObject->NdsValue.value_13);
  504. pOctet_List_T pOctetList = (pOctet_List_T) AllocADsMem(sizeof(Octet_List_T));
  505. if (!pOctetList) {
  506. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  507. }
  508. *ppAttrVal = pOctetList;
  509. *pluAttrValSize = sizeof(Octet_List_T);
  510. pOctetList->length = lpNdsTempASN1_13->Length;
  511. pOctetList->data =
  512. (LPBYTE)AllocADsMem(
  513. lpNdsTempASN1_13->Length
  514. );
  515. if (!pOctetList->data) {
  516. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  517. }
  518. memcpy(
  519. pOctetList->data,
  520. lpNdsTempASN1_13->Data,
  521. pOctetList->length
  522. );
  523. while ( lpNdsTempASN1_13->Next)
  524. {
  525. pOctetList->next = (pOctet_List_T) AllocADsMem(sizeof(Octet_List_T));
  526. if (!pOctetList->next) {
  527. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  528. }
  529. pOctetList = pOctetList->next;
  530. lpNdsTempASN1_13 = lpNdsTempASN1_13->Next;
  531. pOctetList->length = lpNdsTempASN1_13->Length;
  532. pOctetList->data = (LPBYTE) AllocADsMem( lpNdsTempASN1_13->Length );
  533. if (!pOctetList->data) {
  534. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  535. }
  536. memcpy(
  537. pOctetList->data,
  538. lpNdsTempASN1_13->Data,
  539. pOctetList->length
  540. );
  541. }
  542. pOctetList->next = NULL;
  543. break;
  544. }
  545. case 14: {
  546. pEMail_Address_T pEmailAddress = (pEMail_Address_T) AllocADsMem(sizeof (EMail_Address_T));
  547. if (!pEmailAddress) {
  548. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  549. }
  550. pEmailAddress->type = lpNdsObject->NdsValue.value_14.Type;
  551. pEmailAddress->address = (pnchar8) AllocADsStr( (LPWSTR) lpNdsObject->NdsValue.value_14.Address);
  552. *ppAttrVal = pEmailAddress;
  553. *pluAttrValSize = sizeof(EMail_Address_T);
  554. break;
  555. }
  556. case 15: {
  557. pPath_T pPath = (pPath_T) AllocADsMem(sizeof (Path_T));
  558. if (!pPath) {
  559. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  560. }
  561. pPath->nameSpaceType = lpNdsObject->NdsValue.value_15.Type;
  562. pPath->volumeName = (pnchar8) AllocADsStr( lpNdsObject->NdsValue.value_15.VolumeName);
  563. pPath->path = (pnchar8) AllocADsStr( (LPWSTR) lpNdsObject->NdsValue.value_15.Path);
  564. *ppAttrVal = pPath;
  565. *pluAttrValSize = sizeof(Path_T);
  566. break;
  567. }
  568. case 16: {
  569. LPNDS_ASN1_TYPE_12 pNdsASN1_12 = NULL;
  570. DWORD dwSize = sizeof (Replica_Pointer_T) +
  571. (lpNdsObject->NdsValue.value_16.Count-1) * sizeof (Net_Address_T);
  572. pReplica_Pointer_T pReplicaPointer =
  573. (pReplica_Pointer_T) AllocADsMem(dwSize);
  574. if (!pReplicaPointer) {
  575. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  576. }
  577. pReplicaPointer->serverName = (pnchar8) AllocADsStr( (LPWSTR) lpNdsObject->NdsValue.value_16.ServerName);
  578. pReplicaPointer->replicaType = lpNdsObject->NdsValue.value_16.ReplicaType;
  579. pReplicaPointer->replicaNumber = lpNdsObject->NdsValue.value_16.ReplicaNumber;
  580. pReplicaPointer->count = lpNdsObject->NdsValue.value_16.Count;
  581. pNdsASN1_12 = lpNdsObject->NdsValue.value_16.ReplicaAddressHints;
  582. for ( DWORD iter = 0; iter < pReplicaPointer->count; iter++ )
  583. {
  584. hr = CopyNDS12ToNDSNetAddress(
  585. pNdsASN1_12 + iter,
  586. pReplicaPointer->replicaAddressHint + iter
  587. );
  588. BAIL_ON_FAILURE(hr);
  589. }
  590. *ppAttrVal = pReplicaPointer;
  591. *pluAttrValSize = dwSize;
  592. break;
  593. }
  594. case 17: {
  595. pObject_ACL_T pObjectACL = (pObject_ACL_T) AllocADsMem(sizeof (Object_ACL_T));
  596. if (!pObjectACL) {
  597. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  598. }
  599. pObjectACL->protectedAttrName = (pnchar8) AllocADsStr( (LPWSTR) lpNdsObject->NdsValue.value_17.ProtectedAttrName);
  600. pObjectACL->subjectName = (pnchar8) AllocADsStr( lpNdsObject->NdsValue.value_17.SubjectName);
  601. pObjectACL->privileges = lpNdsObject->NdsValue.value_17.Privileges;
  602. *ppAttrVal = pObjectACL;
  603. *pluAttrValSize = sizeof(Object_ACL_T);
  604. break;
  605. }
  606. case 18: {
  607. LPWSTR *pPostalAddresses = (LPWSTR *) AllocADsMem(sizeof (LPWSTR) * 6);
  608. if (!pPostalAddresses) {
  609. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  610. }
  611. for (DWORD i=0; i < 6; i++) {
  612. pPostalAddresses[i] = AllocADsStr( (LPWSTR) lpNdsObject->NdsValue.value_18.PostalAddress[i]);
  613. }
  614. *ppAttrVal = pPostalAddresses;
  615. *pluAttrValSize = sizeof(LPWSTR) * 6;
  616. break;
  617. }
  618. case 19: {
  619. pNWDS_TimeStamp_T pTimeStamp = (pNWDS_TimeStamp_T) AllocADsMem(sizeof (NWDS_TimeStamp_T));
  620. if (!pTimeStamp) {
  621. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  622. }
  623. pTimeStamp->wholeSeconds = lpNdsObject->NdsValue.value_19.WholeSeconds;
  624. pTimeStamp->eventID = lpNdsObject->NdsValue.value_19.EventID;
  625. *ppAttrVal = pTimeStamp;
  626. *pluAttrValSize = sizeof(NWDS_TimeStamp_T);
  627. break;
  628. }
  629. case 20:
  630. *ppAttrVal = AllocADsStr( lpNdsObject->NdsValue.value_20.ClassName );
  631. *pluAttrValSize = (wcslen( lpNdsObject->NdsValue.value_20.ClassName ) + 1) * sizeof (WCHAR) ;
  632. break;
  633. case 21:{
  634. pStream_T pStream = (pStream_T) AllocADsMem(sizeof (NWDS_TimeStamp_T));
  635. if (!pStream) {
  636. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  637. }
  638. pStream->length = lpNdsObject->NdsValue.value_21.Length;
  639. pStream->data = NULL;
  640. *ppAttrVal = pStream;
  641. *pluAttrValSize = sizeof(Stream_T);
  642. break;
  643. }
  644. case 22: {
  645. Counter_T *pCounter = (Counter_T *) AllocADsMem(sizeof(Counter_T));
  646. if (!pCounter) {
  647. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  648. }
  649. *pCounter = *((Counter_T *) &lpNdsObject->NdsValue.value_22.Counter);
  650. *ppAttrVal = pCounter;
  651. *pluAttrValSize = sizeof(Counter_T);
  652. break;
  653. }
  654. case 23: {
  655. pBack_Link_T pBackLink = (pBack_Link_T) AllocADsMem(sizeof (Back_Link_T));
  656. if (!pBackLink) {
  657. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  658. }
  659. pBackLink->remoteID = lpNdsObject->NdsValue.value_23.RemoteID;
  660. pBackLink->objectName = (pnchar8) AllocADsStr( lpNdsObject->NdsValue.value_23.ObjectName);
  661. *ppAttrVal = pBackLink;
  662. *pluAttrValSize = sizeof(Back_Link_T);
  663. break;
  664. }
  665. case 24: {
  666. Integer_T *pInteger = (Integer_T *) AllocADsMem(sizeof(Integer_T));
  667. if (!pInteger) {
  668. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  669. }
  670. *pInteger = *((Integer_T *) &lpNdsObject->NdsValue.value_24.Time);
  671. *ppAttrVal = pInteger;
  672. *pluAttrValSize = sizeof(Integer_T);
  673. break;
  674. }
  675. case 25: {
  676. pTyped_Name_T pTypedName = (pTyped_Name_T) AllocADsMem(sizeof (Typed_Name_T));
  677. if (!pTypedName) {
  678. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  679. }
  680. pTypedName->objectName = (pnchar8) AllocADsStr( lpNdsObject->NdsValue.value_25.ObjectName);
  681. pTypedName->level = lpNdsObject->NdsValue.value_25.Level;
  682. pTypedName->interval = lpNdsObject->NdsValue.value_25.Interval;
  683. *ppAttrVal = pTypedName;
  684. *pluAttrValSize = sizeof(Typed_Name_T);
  685. break;
  686. }
  687. case 26: {
  688. pHold_T pHold = (pHold_T) AllocADsMem(sizeof (Hold_T));
  689. if (!pHold) {
  690. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  691. }
  692. pHold->objectName = (pnchar8) AllocADsStr( (LPWSTR) lpNdsObject->NdsValue.value_26.ObjectName);
  693. pHold->amount = lpNdsObject->NdsValue.value_26.Amount;
  694. *ppAttrVal = pHold;
  695. *pluAttrValSize = sizeof(Hold_T);
  696. break;
  697. }
  698. case 27: {
  699. nuint32 *pInterval = (nuint32 *) AllocADsMem(sizeof(nuint32));
  700. if (!pInterval) {
  701. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  702. }
  703. *pInterval = *((nuint32 *) &lpNdsObject->NdsValue.value_27.Interval);
  704. *ppAttrVal = pInterval;
  705. *pluAttrValSize = sizeof(nuint32);
  706. break;
  707. }
  708. default:
  709. //
  710. // BugBug. Get the proper value from NDS
  711. //
  712. RRETURN(E_ADS_CANT_CONVERT_DATATYPE);
  713. break;
  714. }
  715. RRETURN (hr);
  716. error:
  717. RRETURN(hr);
  718. }