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.

404 lines
8.7 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996
  5. //
  6. // File: cubi.cxx
  7. //
  8. // Contents:
  9. //
  10. // History: 11-1-95 krishnag Created.
  11. //
  12. // PROPERTY_RW(Address, VARIANT, 1) NI
  13. // PROPERTY_RW(Country, BSTR, 2) NI
  14. // PROPERTY_RW(Department, BSTR, 3) NI
  15. // PROPERTY_RW(DepartmentNumber, BSTR, 4) NI
  16. // PROPERTY_RW(Division, BSTR, 5) NI
  17. // PROPERTY_RW(EmployeeID, BSTR, 6) NI
  18. // PROPERTY_RW(FirstName, BSTR, 8) Implemented
  19. // PROPERTY_RW(FullName, BSTR, 9) NI
  20. // PROPERTY_RW(LastName, BSTR, 11) NI
  21. // PROPERTY_RW(Manager, BSTR, 12) NI
  22. // PROPERTY_RW(OfficeLocations, BSTR, 14) NI
  23. // PROPERTY_RW(Picture, VARIANT, 15) NI
  24. // PROPERTY_RW(TelecomNumber, VARIANT, 17) NI
  25. // PROPERTY_RW(Title, BSTR, 19)
  26. //
  27. //----------------------------------------------------------------------------
  28. #include "ldap.hxx"
  29. #pragma hdrstop
  30. STDMETHODIMP
  31. CLDAPUser::get_Description(THIS_ BSTR FAR* pbstrDescription)
  32. {
  33. HRESULT hr = S_OK;
  34. VARIANT v;
  35. VariantInit(&v);
  36. hr = get_VARIANT_Property((IADs *)this, TEXT("Description"), &v );
  37. BAIL_IF_ERROR(hr);
  38. if ( V_ISARRAY(&v))
  39. {
  40. long i = 0;
  41. VARIANT vFirst;
  42. VariantInit(&vFirst);
  43. hr = SafeArrayGetElement( V_ARRAY(&v), &i, &vFirst );
  44. BAIL_IF_ERROR(hr);
  45. hr = ADsAllocString( V_BSTR(&vFirst), pbstrDescription );
  46. VariantClear(&vFirst);
  47. }
  48. else
  49. {
  50. hr = ADsAllocString( V_BSTR(&v), pbstrDescription );
  51. }
  52. cleanup:
  53. VariantClear(&v);
  54. RRETURN(hr);
  55. }
  56. STDMETHODIMP
  57. CLDAPUser::put_Description(THIS_ BSTR bstrDescription)
  58. {
  59. HRESULT hr = S_OK;
  60. VARIANT vDescription;
  61. VariantInit(&vDescription);
  62. vDescription.vt = VT_BSTR;
  63. V_BSTR(&vDescription) = bstrDescription;
  64. hr = put_VARIANT_Property( (IADs *)this,
  65. TEXT("Description"),
  66. vDescription );
  67. RRETURN(hr);
  68. }
  69. STDMETHODIMP
  70. CLDAPUser::get_Department(THIS_ BSTR FAR* retval)
  71. {
  72. GET_PROPERTY_BSTR((IADsUser *)this, Department);
  73. }
  74. STDMETHODIMP
  75. CLDAPUser::put_Department(THIS_ BSTR bstrDepartment)
  76. {
  77. PUT_PROPERTY_BSTR((IADsUser *)this, Department);
  78. }
  79. STDMETHODIMP
  80. CLDAPUser::get_Division(THIS_ BSTR FAR* retval)
  81. {
  82. GET_PROPERTY_BSTR((IADsUser *)this, Division);
  83. }
  84. STDMETHODIMP
  85. CLDAPUser::put_Division(THIS_ BSTR bstrDivision)
  86. {
  87. PUT_PROPERTY_BSTR((IADsUser *)this, Division);
  88. }
  89. STDMETHODIMP
  90. CLDAPUser::get_EmployeeID(THIS_ BSTR FAR* retval)
  91. {
  92. GET_PROPERTY_BSTR((IADsUser *)this, EmployeeID);
  93. }
  94. STDMETHODIMP
  95. CLDAPUser::put_EmployeeID(THIS_ BSTR bstrEmployeeID)
  96. {
  97. PUT_PROPERTY_BSTR((IADsUser *)this, EmployeeID);
  98. }
  99. STDMETHODIMP
  100. CLDAPUser::get_FirstName(THIS_ BSTR FAR* retval)
  101. {
  102. GET_PROPERTY_BSTR((IADsUser *)this, FirstName);
  103. }
  104. STDMETHODIMP
  105. CLDAPUser::put_FirstName(THIS_ BSTR bstrFirstName)
  106. {
  107. PUT_PROPERTY_BSTR((IADsUser *)this, FirstName);
  108. }
  109. STDMETHODIMP
  110. CLDAPUser::get_FullName(THIS_ BSTR FAR* retval)
  111. {
  112. GET_PROPERTY_BSTR((IADsUser *)this, FullName);
  113. }
  114. STDMETHODIMP
  115. CLDAPUser::put_FullName(THIS_ BSTR bstrFullName)
  116. {
  117. PUT_PROPERTY_BSTR((IADsUser *)this, FullName);
  118. }
  119. STDMETHODIMP
  120. CLDAPUser::get_LastName(THIS_ BSTR FAR* retval)
  121. {
  122. GET_PROPERTY_BSTR((IADsUser *)this, LastName);
  123. }
  124. STDMETHODIMP
  125. CLDAPUser::put_LastName(THIS_ BSTR bstrLastName)
  126. {
  127. PUT_PROPERTY_BSTR((IADsUser *)this, LastName);
  128. }
  129. STDMETHODIMP
  130. CLDAPUser::get_Manager(THIS_ BSTR FAR* retval)
  131. {
  132. GET_PROPERTY_BSTR((IADsUser *)this, Manager);
  133. }
  134. STDMETHODIMP
  135. CLDAPUser::put_Manager(THIS_ BSTR bstrManager)
  136. {
  137. PUT_PROPERTY_BSTR((IADsUser *)this, Manager);
  138. }
  139. STDMETHODIMP
  140. CLDAPUser::get_OfficeLocations(THIS_ VARIANT FAR* retval)
  141. {
  142. GET_PROPERTY_VARIANT((IADsUser *)this, OfficeLocations);
  143. }
  144. STDMETHODIMP
  145. CLDAPUser::put_OfficeLocations(THIS_ VARIANT vOfficeLocations)
  146. {
  147. PUT_PROPERTY_VARIANT((IADsUser *)this, OfficeLocations);
  148. }
  149. STDMETHODIMP
  150. CLDAPUser::get_Picture(THIS_ VARIANT FAR* retval)
  151. {
  152. GET_PROPERTY_VARIANT((IADsUser *)this, Picture);
  153. }
  154. STDMETHODIMP
  155. CLDAPUser::put_Picture(THIS_ VARIANT vPicture)
  156. {
  157. PUT_PROPERTY_VARIANT((IADsUser *)this, Picture);
  158. }
  159. STDMETHODIMP
  160. CLDAPUser::get_PostalAddresses(THIS_ VARIANT FAR* retval)
  161. {
  162. GET_PROPERTY_VARIANT((IADsUser *)this, PostalAddresses);
  163. }
  164. STDMETHODIMP
  165. CLDAPUser::put_PostalAddresses(THIS_ VARIANT vPostalAddresses)
  166. {
  167. PUT_PROPERTY_VARIANT((IADsUser *)this, PostalAddresses);
  168. }
  169. STDMETHODIMP
  170. CLDAPUser::get_PostalCodes(THIS_ VARIANT FAR* retval)
  171. {
  172. GET_PROPERTY_VARIANT((IADsUser *)this, PostalCodes);
  173. }
  174. STDMETHODIMP
  175. CLDAPUser::put_PostalCodes(THIS_ VARIANT vPostalCodes)
  176. {
  177. PUT_PROPERTY_VARIANT((IADsUser *)this, PostalCodes);
  178. }
  179. STDMETHODIMP
  180. CLDAPUser::get_TelephoneNumber(THIS_ VARIANT FAR* retval)
  181. {
  182. GET_PROPERTY_VARIANT((IADsUser *)this, TelephoneNumber);
  183. }
  184. STDMETHODIMP
  185. CLDAPUser::put_TelephoneNumber(THIS_ VARIANT vTelephoneNumber)
  186. {
  187. PUT_PROPERTY_VARIANT((IADsUser *)this, TelephoneNumber);
  188. }
  189. STDMETHODIMP
  190. CLDAPUser::get_TelephoneHome(THIS_ VARIANT FAR* retval)
  191. {
  192. GET_PROPERTY_VARIANT((IADsUser *)this, TelephoneHome);
  193. }
  194. STDMETHODIMP
  195. CLDAPUser::put_TelephoneHome(THIS_ VARIANT vTelephoneHome)
  196. {
  197. PUT_PROPERTY_VARIANT((IADsUser *)this, TelephoneHome);
  198. }
  199. STDMETHODIMP
  200. CLDAPUser::get_TelephoneMobile(THIS_ VARIANT FAR* retval)
  201. {
  202. GET_PROPERTY_VARIANT((IADsUser *)this, TelephoneMobile);
  203. }
  204. STDMETHODIMP
  205. CLDAPUser::put_TelephoneMobile(THIS_ VARIANT vTelephoneMobile)
  206. {
  207. PUT_PROPERTY_VARIANT((IADsUser *)this, TelephoneMobile);
  208. }
  209. STDMETHODIMP
  210. CLDAPUser::get_TelephonePager(THIS_ VARIANT FAR* retval)
  211. {
  212. GET_PROPERTY_VARIANT((IADsUser *)this, TelephonePager);
  213. }
  214. STDMETHODIMP
  215. CLDAPUser::put_TelephonePager(THIS_ VARIANT vTelephonePager)
  216. {
  217. PUT_PROPERTY_VARIANT((IADsUser *)this, TelephonePager);
  218. }
  219. STDMETHODIMP
  220. CLDAPUser::get_FaxNumber(THIS_ VARIANT FAR* retval)
  221. {
  222. GET_PROPERTY_VARIANT((IADsUser *)this, FaxNumber);
  223. }
  224. STDMETHODIMP
  225. CLDAPUser::put_FaxNumber(THIS_ VARIANT vFaxNumber)
  226. {
  227. PUT_PROPERTY_VARIANT((IADsUser *)this, FaxNumber);
  228. }
  229. STDMETHODIMP
  230. CLDAPUser::get_Title(THIS_ BSTR FAR* retval)
  231. {
  232. GET_PROPERTY_BSTR((IADsUser *)this, Title);
  233. }
  234. STDMETHODIMP
  235. CLDAPUser::put_Title(THIS_ BSTR bstrTitle)
  236. {
  237. PUT_PROPERTY_BSTR((IADsUser *)this, Title);
  238. }
  239. STDMETHODIMP
  240. CLDAPUser::get_HomePage(THIS_ BSTR FAR* retval)
  241. {
  242. GET_PROPERTY_BSTR((IADsUser *)this, HomePage);
  243. }
  244. STDMETHODIMP
  245. CLDAPUser::put_HomePage(THIS_ BSTR bstrHomePage)
  246. {
  247. PUT_PROPERTY_BSTR((IADsUser *)this, HomePage);
  248. }
  249. STDMETHODIMP
  250. CLDAPUser::get_SeeAlso(THIS_ VARIANT FAR* retval)
  251. {
  252. GET_PROPERTY_VARIANT((IADsUser *)this, SeeAlso );
  253. }
  254. STDMETHODIMP
  255. CLDAPUser::put_SeeAlso(THIS_ VARIANT vSeeAlso)
  256. {
  257. PUT_PROPERTY_VARIANT((IADsUser *)this, SeeAlso );
  258. }
  259. STDMETHODIMP
  260. CLDAPUser::get_NamePrefix(THIS_ BSTR FAR* retval)
  261. {
  262. GET_PROPERTY_BSTR((IADsUser *)this, NamePrefix );
  263. }
  264. STDMETHODIMP
  265. CLDAPUser::put_NamePrefix(THIS_ BSTR bstrNamePrefix)
  266. {
  267. PUT_PROPERTY_BSTR((IADsUser *)this, NamePrefix );
  268. }
  269. STDMETHODIMP
  270. CLDAPUser::get_NameSuffix(THIS_ BSTR FAR* retval)
  271. {
  272. GET_PROPERTY_BSTR((IADsUser *)this, NameSuffix );
  273. }
  274. STDMETHODIMP
  275. CLDAPUser::put_NameSuffix(THIS_ BSTR bstrNameSuffix)
  276. {
  277. PUT_PROPERTY_BSTR((IADsUser *)this, NameSuffix );
  278. }
  279. STDMETHODIMP
  280. CLDAPUser::get_OtherName(THIS_ BSTR FAR* retval)
  281. {
  282. GET_PROPERTY_BSTR((IADsUser *)this, OtherName );
  283. }
  284. STDMETHODIMP
  285. CLDAPUser::put_OtherName(THIS_ BSTR bstrOtherName)
  286. {
  287. PUT_PROPERTY_BSTR((IADsUser *)this, OtherName );
  288. }
  289. STDMETHODIMP
  290. CLDAPUser::Groups(THIS_ IADsMembers FAR* FAR * ppGroups)
  291. {
  292. VARIANT varProp;
  293. HRESULT hr = S_OK;
  294. BSTR bstrADsPath = NULL;
  295. VariantInit(&varProp);
  296. hr = _pADs->Get(L"memberOf", &varProp);
  297. if ( hr == E_ADS_PROPERTY_NOT_FOUND )
  298. {
  299. SAFEARRAY *aList = NULL;
  300. SAFEARRAYBOUND aBound;
  301. VariantInit(&varProp);
  302. hr = S_OK;
  303. aBound.lLbound = 0;
  304. aBound.cElements = 0;
  305. aList = SafeArrayCreate( VT_VARIANT, 1, &aBound );
  306. if ( aList == NULL )
  307. {
  308. hr = E_OUTOFMEMORY;
  309. BAIL_ON_FAILURE(hr);
  310. }
  311. V_VT(&varProp) = VT_ARRAY | VT_VARIANT;
  312. V_ARRAY(&varProp) = aList;
  313. }
  314. BAIL_ON_FAILURE(hr);
  315. hr = _pADs->get_ADsPath(&bstrADsPath);
  316. BAIL_ON_FAILURE(hr);
  317. hr = CLDAPUserCollection::CreateUserCollection(
  318. bstrADsPath,
  319. varProp,
  320. _Credentials,
  321. IID_IADsMembers,
  322. (void **)ppGroups
  323. );
  324. BAIL_ON_FAILURE(hr);
  325. error:
  326. if (bstrADsPath) {
  327. ADsFreeString(bstrADsPath);
  328. }
  329. VariantClear(&varProp);
  330. RRETURN(hr);
  331. }
  332.