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.

389 lines
7.6 KiB

  1. #include "winnt.hxx"
  2. #pragma hdrstop
  3. #define VALIDATE_PTR(pPtr) \
  4. if (!pPtr) { \
  5. hr = E_ADS_BAD_PARAMETER;\
  6. }\
  7. BAIL_ON_FAILURE(hr);
  8. HRESULT
  9. put_BSTR_Property(
  10. IADs * pADsObject,
  11. LPTSTR szPropertyName,
  12. BSTR pSrcStringProperty
  13. )
  14. {
  15. HRESULT hr = S_OK;
  16. VARIANT varInputData;
  17. BSTR bstrPropertyName = NULL;
  18. hr = PackStringinVariant(
  19. pSrcStringProperty,
  20. &varInputData
  21. );
  22. BAIL_ON_FAILURE(hr);
  23. hr = ADsAllocString(szPropertyName, &bstrPropertyName);
  24. BAIL_ON_FAILURE(hr);
  25. hr = pADsObject->Put(
  26. bstrPropertyName,
  27. varInputData
  28. );
  29. BAIL_ON_FAILURE(hr);
  30. error:
  31. if (bstrPropertyName)
  32. ADsFreeString(bstrPropertyName);
  33. VariantClear(&varInputData);
  34. RRETURN(hr);
  35. }
  36. HRESULT
  37. get_BSTR_Property(
  38. IADs * pADsObject,
  39. LPTSTR szPropertyName,
  40. BSTR *ppDestStringProperty
  41. )
  42. {
  43. HRESULT hr = S_OK;
  44. VARIANT varOutputData;
  45. BSTR bstrPropertyName = NULL;
  46. VariantInit( &varOutputData );
  47. if (NULL == ppDestStringProperty)
  48. BAIL_ON_FAILURE(hr = E_POINTER);
  49. hr = ADsAllocString(szPropertyName, &bstrPropertyName);
  50. BAIL_ON_FAILURE(hr);
  51. hr = pADsObject->Get(
  52. bstrPropertyName,
  53. &varOutputData
  54. );
  55. BAIL_ON_FAILURE(hr);
  56. hr = UnpackStringfromVariant(
  57. varOutputData,
  58. ppDestStringProperty
  59. );
  60. BAIL_ON_FAILURE(hr);
  61. error:
  62. if (bstrPropertyName)
  63. ADsFreeString(bstrPropertyName);
  64. VariantClear(&varOutputData);
  65. RRETURN(hr);
  66. }
  67. HRESULT
  68. put_LONG_Property(
  69. IADs * pADsObject,
  70. LPTSTR szPropertyName,
  71. LONG lSrcProperty
  72. )
  73. {
  74. HRESULT hr = S_OK;
  75. VARIANT varInputData;
  76. BSTR bstrPropertyName = NULL;
  77. hr = PackLONGinVariant(
  78. lSrcProperty,
  79. &varInputData
  80. );
  81. BAIL_ON_FAILURE(hr);
  82. hr = ADsAllocString(szPropertyName, &bstrPropertyName);
  83. BAIL_ON_FAILURE(hr);
  84. hr = pADsObject->Put(
  85. bstrPropertyName,
  86. varInputData
  87. );
  88. BAIL_ON_FAILURE(hr);
  89. error:
  90. if (bstrPropertyName)
  91. ADsFreeString(bstrPropertyName);
  92. VariantClear(&varInputData);
  93. RRETURN(hr);
  94. }
  95. HRESULT
  96. get_LONG_Property(
  97. IADs * pADsObject,
  98. LPTSTR szPropertyName,
  99. PLONG plDestProperty
  100. )
  101. {
  102. HRESULT hr = S_OK;
  103. VARIANT varOutputData;
  104. BSTR bstrPropertyName = NULL;
  105. VariantInit( &varOutputData );
  106. if (NULL == plDestProperty)
  107. BAIL_ON_FAILURE(hr = E_POINTER);
  108. hr = ADsAllocString(szPropertyName, &bstrPropertyName);
  109. BAIL_ON_FAILURE(hr);
  110. hr = pADsObject->Get(
  111. bstrPropertyName,
  112. &varOutputData
  113. );
  114. BAIL_ON_FAILURE(hr);
  115. hr = UnpackLONGfromVariant(
  116. varOutputData,
  117. plDestProperty
  118. );
  119. BAIL_ON_FAILURE(hr);
  120. error:
  121. if (bstrPropertyName)
  122. ADsFreeString(bstrPropertyName);
  123. VariantClear(&varOutputData);
  124. RRETURN(hr);
  125. }
  126. HRESULT
  127. put_DATE_Property(
  128. IADs * pADsObject,
  129. LPTSTR szPropertyName,
  130. DATE daSrcProperty
  131. )
  132. {
  133. HRESULT hr = S_OK;
  134. VARIANT varInputData;
  135. BSTR bstrPropertyName = NULL;
  136. hr = PackDATEinVariant(
  137. daSrcProperty,
  138. &varInputData
  139. );
  140. BAIL_ON_FAILURE(hr);
  141. hr = ADsAllocString(szPropertyName, &bstrPropertyName);
  142. BAIL_ON_FAILURE(hr);
  143. hr = pADsObject->Put(
  144. bstrPropertyName,
  145. varInputData
  146. );
  147. BAIL_ON_FAILURE(hr);
  148. error:
  149. if (bstrPropertyName)
  150. ADsFreeString(bstrPropertyName);
  151. VariantClear(&varInputData);
  152. RRETURN(hr);
  153. }
  154. HRESULT
  155. get_DATE_Property(
  156. IADs * pADsObject,
  157. LPTSTR szPropertyName,
  158. PDATE pdaDestProperty
  159. )
  160. {
  161. HRESULT hr = S_OK;
  162. VARIANT varOutputData;
  163. BSTR bstrPropertyName = NULL;
  164. VariantInit( &varOutputData );
  165. if (NULL == pdaDestProperty)
  166. BAIL_ON_FAILURE(hr = E_POINTER);
  167. hr = ADsAllocString(szPropertyName, &bstrPropertyName);
  168. BAIL_ON_FAILURE(hr);
  169. hr = pADsObject->Get(
  170. bstrPropertyName,
  171. &varOutputData
  172. );
  173. BAIL_ON_FAILURE(hr);
  174. hr = UnpackDATEfromVariant(
  175. varOutputData,
  176. pdaDestProperty
  177. );
  178. BAIL_ON_FAILURE(hr);
  179. error:
  180. if (bstrPropertyName)
  181. ADsFreeString(bstrPropertyName);
  182. VariantClear(&varOutputData);
  183. RRETURN(hr);
  184. }
  185. HRESULT
  186. put_VARIANT_BOOL_Property(
  187. IADs * pADsObject,
  188. LPTSTR szPropertyName,
  189. VARIANT_BOOL fSrcProperty
  190. )
  191. {
  192. HRESULT hr = S_OK;
  193. VARIANT varInputData;
  194. BSTR bstrPropertyName = NULL;
  195. hr = PackVARIANT_BOOLinVariant(
  196. fSrcProperty,
  197. &varInputData
  198. );
  199. BAIL_ON_FAILURE(hr);
  200. hr = ADsAllocString(szPropertyName, &bstrPropertyName);
  201. BAIL_ON_FAILURE(hr);
  202. hr = pADsObject->Put(
  203. bstrPropertyName,
  204. varInputData
  205. );
  206. BAIL_ON_FAILURE(hr);
  207. error:
  208. if (bstrPropertyName)
  209. ADsFreeString(bstrPropertyName);
  210. VariantClear(&varInputData);
  211. RRETURN(hr);
  212. }
  213. HRESULT
  214. get_VARIANT_BOOL_Property(
  215. IADs * pADsObject,
  216. LPTSTR szPropertyName,
  217. PVARIANT_BOOL pfDestProperty
  218. )
  219. {
  220. HRESULT hr = S_OK;
  221. VARIANT varOutputData;
  222. BSTR bstrPropertyName = NULL;
  223. VariantInit( &varOutputData );
  224. if (NULL == pfDestProperty)
  225. BAIL_ON_FAILURE(hr = E_POINTER);
  226. hr = ADsAllocString(szPropertyName, &bstrPropertyName);
  227. BAIL_ON_FAILURE(hr);
  228. hr = pADsObject->Get(
  229. bstrPropertyName,
  230. &varOutputData
  231. );
  232. BAIL_ON_FAILURE(hr);
  233. hr = UnpackVARIANT_BOOLfromVariant(
  234. varOutputData,
  235. pfDestProperty
  236. );
  237. BAIL_ON_FAILURE(hr);
  238. error:
  239. if (bstrPropertyName)
  240. ADsFreeString(bstrPropertyName);
  241. VariantClear(&varOutputData);
  242. RRETURN(hr);
  243. }
  244. HRESULT
  245. put_VARIANT_Property(
  246. IADs * pADsObject,
  247. LPTSTR szPropertyName,
  248. VARIANT vSrcProperty
  249. )
  250. {
  251. HRESULT hr = S_OK;
  252. VARIANT varInputData;
  253. BSTR bstrPropertyName = NULL;
  254. hr = PackVARIANTinVariant(
  255. vSrcProperty,
  256. &varInputData
  257. );
  258. BAIL_ON_FAILURE(hr);
  259. hr = ADsAllocString(szPropertyName, &bstrPropertyName);
  260. BAIL_ON_FAILURE(hr);
  261. hr = pADsObject->Put(
  262. bstrPropertyName,
  263. varInputData
  264. );
  265. BAIL_ON_FAILURE(hr);
  266. error:
  267. if (bstrPropertyName)
  268. ADsFreeString(bstrPropertyName);
  269. VariantClear(&varInputData);
  270. RRETURN(hr);
  271. }
  272. HRESULT
  273. get_VARIANT_Property(
  274. IADs * pADsObject,
  275. LPTSTR szPropertyName,
  276. PVARIANT pvDestProperty
  277. )
  278. {
  279. HRESULT hr = S_OK;
  280. VARIANT varOutputData;
  281. BSTR bstrPropertyName = NULL;
  282. VariantInit( &varOutputData );
  283. if (NULL == pvDestProperty)
  284. BAIL_ON_FAILURE(hr = E_POINTER);
  285. hr = ADsAllocString(szPropertyName, &bstrPropertyName);
  286. BAIL_ON_FAILURE(hr);
  287. hr = pADsObject->Get(
  288. bstrPropertyName,
  289. &varOutputData
  290. );
  291. BAIL_ON_FAILURE(hr);
  292. hr = UnpackVARIANTfromVariant(
  293. varOutputData,
  294. pvDestProperty
  295. );
  296. BAIL_ON_FAILURE(hr);
  297. error:
  298. if (bstrPropertyName)
  299. ADsFreeString(bstrPropertyName);
  300. VariantClear(&varOutputData);
  301. RRETURN(hr);
  302. }