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.

319 lines
7.0 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: cgroups.cxx
  7. //
  8. // Contents: Group object
  9. //
  10. // History: Mar-18-965 t-ptam (PatrickT) Migrated.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "NWCOMPAT.hxx"
  14. #pragma hdrstop
  15. //
  16. // Class CNWCOMPATUserCollection
  17. //
  18. DEFINE_IDispatch_Implementation(CNWCOMPATUserCollection)
  19. //----------------------------------------------------------------------------
  20. //
  21. // Function:
  22. //
  23. // Synopsis:
  24. //
  25. //----------------------------------------------------------------------------
  26. CNWCOMPATUserCollection::CNWCOMPATUserCollection():
  27. _ParentType(0),
  28. _ServerName(NULL),
  29. _pDispMgr(NULL)
  30. {
  31. VariantInit(&_vFilter);
  32. ENLIST_TRACKING(CNWCOMPATUserCollection);
  33. }
  34. //----------------------------------------------------------------------------
  35. //
  36. // Function:
  37. //
  38. // Synopsis:
  39. //
  40. //----------------------------------------------------------------------------
  41. CNWCOMPATUserCollection::~CNWCOMPATUserCollection( )
  42. {
  43. if (_ServerName)
  44. ADsFreeString(_ServerName);
  45. delete _pDispMgr;
  46. VariantClear(&_vFilter);
  47. }
  48. //----------------------------------------------------------------------------
  49. //
  50. // Function:
  51. //
  52. // Synopsis:
  53. //
  54. //----------------------------------------------------------------------------
  55. HRESULT
  56. CNWCOMPATUserCollection::CreateUserCollection(
  57. BSTR Parent,
  58. ULONG ParentType,
  59. BSTR ServerName,
  60. BSTR UserName,
  61. REFIID riid,
  62. void **ppvObj
  63. )
  64. {
  65. CNWCOMPATUserCollection FAR * pUser = NULL;
  66. HRESULT hr = S_OK;
  67. hr = AllocateUserCollectionObject(&pUser);
  68. BAIL_ON_FAILURE(hr);
  69. hr = pUser->InitializeCoreObject(
  70. Parent,
  71. UserName,
  72. L"users",
  73. NO_SCHEMA,
  74. CLSID_NWCOMPATUser,
  75. ADS_OBJECT_UNBOUND
  76. );
  77. BAIL_ON_FAILURE(hr);
  78. hr = ADsAllocString(ServerName, &pUser->_ServerName);
  79. BAIL_ON_FAILURE(hr);
  80. pUser->_ParentType = ParentType;
  81. hr = pUser->QueryInterface(riid, ppvObj);
  82. BAIL_ON_FAILURE(hr);
  83. pUser->Release();
  84. RRETURN(hr);
  85. error:
  86. delete pUser;
  87. RRETURN_EXP_IF_ERR(hr);
  88. }
  89. //----------------------------------------------------------------------------
  90. //
  91. // Function:
  92. //
  93. // Synopsis:
  94. //
  95. //----------------------------------------------------------------------------
  96. STDMETHODIMP
  97. CNWCOMPATUserCollection::QueryInterface(
  98. REFIID iid,
  99. LPVOID FAR* ppv
  100. )
  101. {
  102. if (ppv == NULL) {
  103. RRETURN(E_POINTER);
  104. }
  105. if (IsEqualIID(iid, IID_IUnknown))
  106. {
  107. *ppv = (IADsMembers FAR *) this;
  108. }
  109. else if (IsEqualIID(iid, IID_IADsMembers))
  110. {
  111. *ppv = (IADsMembers FAR *) this;
  112. }
  113. else if (IsEqualIID(iid, IID_IDispatch))
  114. {
  115. *ppv = (IADsMembers FAR *) this;
  116. }
  117. else if (IsEqualIID(iid, IID_ISupportErrorInfo))
  118. {
  119. *ppv = (ISupportErrorInfo FAR *) this;
  120. }
  121. else
  122. {
  123. *ppv = NULL;
  124. return E_NOINTERFACE;
  125. }
  126. AddRef();
  127. return NOERROR;
  128. }
  129. //----------------------------------------------------------------------------
  130. //
  131. // Function:CNWCOMPATUserCollection::InterfaceSupportsErrorInfo
  132. //
  133. // Synopsis:
  134. //
  135. //----------------------------------------------------------------------------
  136. STDMETHODIMP
  137. CNWCOMPATUserCollection::InterfaceSupportsErrorInfo(
  138. THIS_ REFIID riid
  139. )
  140. {
  141. if (IsEqualIID(riid, IID_IADsMembers)) {
  142. RRETURN(S_OK);
  143. } else {
  144. RRETURN(S_FALSE);
  145. }
  146. }
  147. //----------------------------------------------------------------------------
  148. //
  149. // Function:
  150. //
  151. // Synopsis:
  152. //
  153. //----------------------------------------------------------------------------
  154. STDMETHODIMP
  155. CNWCOMPATUserCollection::get_Count(
  156. long FAR* retval
  157. )
  158. {
  159. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  160. }
  161. //----------------------------------------------------------------------------
  162. //
  163. // Function:
  164. //
  165. // Synopsis:
  166. //
  167. //----------------------------------------------------------------------------
  168. STDMETHODIMP
  169. CNWCOMPATUserCollection::get_Filter(
  170. THIS_ VARIANT FAR* pVar
  171. )
  172. {
  173. HRESULT hr;
  174. VariantInit(pVar);
  175. hr = VariantCopy(pVar, &_vFilter);
  176. RRETURN_EXP_IF_ERR(hr);
  177. }
  178. //----------------------------------------------------------------------------
  179. //
  180. // Function:
  181. //
  182. // Synopsis:
  183. //
  184. //----------------------------------------------------------------------------
  185. STDMETHODIMP
  186. CNWCOMPATUserCollection::put_Filter(
  187. THIS_ VARIANT Var
  188. )
  189. {
  190. HRESULT hr;
  191. hr = VariantCopy(&_vFilter, &Var);
  192. RRETURN_EXP_IF_ERR(hr);
  193. }
  194. //----------------------------------------------------------------------------
  195. //
  196. // Function:
  197. //
  198. // Synopsis:
  199. //
  200. //----------------------------------------------------------------------------
  201. STDMETHODIMP
  202. CNWCOMPATUserCollection::get__NewEnum(
  203. THIS_ IUnknown * FAR* retval
  204. )
  205. {
  206. HRESULT hr;
  207. IUnknown FAR* punkEnum=NULL;
  208. IEnumVARIANT * penum = NULL;
  209. *retval = NULL;
  210. hr = CNWCOMPATUserCollectionEnum::Create(
  211. (CNWCOMPATUserCollectionEnum **)&penum,
  212. _Parent,
  213. _ParentType,
  214. _ADsPath,
  215. _ServerName,
  216. _Name,
  217. _vFilter
  218. );
  219. BAIL_ON_FAILURE(hr);
  220. hr = penum->QueryInterface(
  221. IID_IUnknown,
  222. (VOID FAR* FAR*)retval
  223. );
  224. BAIL_ON_FAILURE(hr);
  225. if (penum) {
  226. penum->Release();
  227. }
  228. RRETURN(NOERROR);
  229. error:
  230. if (penum) {
  231. delete penum;
  232. }
  233. RRETURN_EXP_IF_ERR(hr);
  234. }
  235. //----------------------------------------------------------------------------
  236. //
  237. // Function:
  238. //
  239. // Synopsis:
  240. //
  241. //----------------------------------------------------------------------------
  242. HRESULT
  243. CNWCOMPATUserCollection::AllocateUserCollectionObject(
  244. CNWCOMPATUserCollection ** ppUser
  245. )
  246. {
  247. CNWCOMPATUserCollection FAR * pUser = NULL;
  248. CAggregatorDispMgr FAR * pDispMgr = NULL;
  249. HRESULT hr = S_OK;
  250. pUser = new CNWCOMPATUserCollection();
  251. if (pUser == NULL) {
  252. hr = E_OUTOFMEMORY;
  253. }
  254. BAIL_ON_FAILURE(hr);
  255. pDispMgr = new CAggregatorDispMgr;
  256. if (pDispMgr == NULL) {
  257. hr = E_OUTOFMEMORY;
  258. }
  259. BAIL_ON_FAILURE(hr);
  260. hr = LoadTypeInfoEntry(
  261. pDispMgr,
  262. LIBID_ADs,
  263. IID_IADsMembers,
  264. (IADsMembers *)pUser,
  265. DISPID_NEWENUM
  266. );
  267. BAIL_ON_FAILURE(hr);
  268. pUser->_pDispMgr = pDispMgr;
  269. *ppUser = pUser;
  270. RRETURN(hr);
  271. error:
  272. if (pUser) {
  273. delete pUser;
  274. }
  275. if (pDispMgr) {
  276. delete pDispMgr;
  277. }
  278. RRETURN(hr);
  279. }