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.

401 lines
7.0 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997
  5. //
  6. // File: cnamesp.cxx
  7. //
  8. // Contents: Namespace Object
  9. //
  10. // History: 01-30-95 krishnag Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "iis.hxx"
  14. #pragma hdrstop
  15. DEFINE_IDispatch_Implementation(CIISNamespace)
  16. DEFINE_IADs_Implementation(CIISNamespace)
  17. // Class CIISNamespace
  18. CIISNamespace::CIISNamespace()
  19. {
  20. VariantInit(&_vFilter);
  21. ENLIST_TRACKING(CIISNamespace);
  22. }
  23. HRESULT
  24. CIISNamespace::CreateNamespace(
  25. BSTR Parent,
  26. BSTR NamespaceName,
  27. CCredentials& Credentials,
  28. DWORD dwObjectState,
  29. REFIID riid,
  30. void **ppvObj
  31. )
  32. {
  33. CIISNamespace FAR * pNamespace = NULL;
  34. HRESULT hr = S_OK;
  35. hr = AllocateNamespaceObject(
  36. Credentials,
  37. &pNamespace
  38. );
  39. BAIL_ON_FAILURE(hr);
  40. hr = pNamespace->InitializeCoreObject(
  41. Parent,
  42. NamespaceName,
  43. L"Namespace",
  44. L"",
  45. CLSID_IISNamespace,
  46. dwObjectState
  47. );
  48. BAIL_ON_FAILURE(hr);
  49. hr = pNamespace->QueryInterface(riid, ppvObj);
  50. BAIL_ON_FAILURE(hr);
  51. pNamespace->Release();
  52. RRETURN(hr);
  53. error:
  54. delete pNamespace;
  55. RRETURN(hr);
  56. }
  57. CIISNamespace::~CIISNamespace( )
  58. {
  59. VariantClear(&_vFilter);
  60. delete _pDispMgr;
  61. }
  62. STDMETHODIMP
  63. CIISNamespace::QueryInterface(REFIID iid, LPVOID FAR* ppv)
  64. {
  65. if (IsEqualIID(iid, IID_IUnknown))
  66. {
  67. *ppv = (IADs FAR *)this;
  68. }else if (IsEqualIID(iid, IID_IDispatch))
  69. {
  70. *ppv = (IADs FAR *)this;
  71. }
  72. else if (IsEqualIID(iid, IID_IADsContainer))
  73. {
  74. *ppv = (IADsContainer FAR *) this;
  75. }
  76. else if (IsEqualIID(iid, IID_IADs))
  77. {
  78. *ppv = (IADs FAR *) this;
  79. }
  80. else if (IsEqualIID(iid, IID_IADsOpenDSObject))
  81. {
  82. *ppv = (IADsOpenDSObject FAR *) this;
  83. }
  84. else
  85. {
  86. *ppv = NULL;
  87. return E_NOINTERFACE;
  88. }
  89. AddRef();
  90. return NOERROR;
  91. }
  92. STDMETHODIMP
  93. CIISNamespace::SetInfo(THIS)
  94. {
  95. RRETURN(E_NOTIMPL);
  96. }
  97. STDMETHODIMP
  98. CIISNamespace::GetInfo(THIS)
  99. {
  100. RRETURN(E_NOTIMPL);
  101. }
  102. /* IADsContainer methods */
  103. STDMETHODIMP
  104. CIISNamespace::get_Count(long FAR* retval)
  105. {
  106. RRETURN(E_NOTIMPL);
  107. }
  108. STDMETHODIMP
  109. CIISNamespace::get_Filter(THIS_ VARIANT FAR* pVar)
  110. {
  111. RRETURN(E_NOTIMPL);
  112. }
  113. STDMETHODIMP
  114. CIISNamespace::put_Filter(THIS_ VARIANT Var)
  115. {
  116. RRETURN(E_NOTIMPL);
  117. }
  118. STDMETHODIMP
  119. CIISNamespace::put_Hints(THIS_ VARIANT Var)
  120. {
  121. RRETURN( E_NOTIMPL);
  122. }
  123. STDMETHODIMP
  124. CIISNamespace::get_Hints(THIS_ VARIANT FAR* pVar)
  125. {
  126. RRETURN(E_NOTIMPL);
  127. }
  128. STDMETHODIMP
  129. CIISNamespace::GetObject(
  130. THIS_ BSTR ClassName,
  131. BSTR RelativeName,
  132. IDispatch * FAR* ppObject
  133. )
  134. {
  135. HRESULT hr = S_OK;
  136. hr = ::RelativeGetObject(
  137. _ADsPath,
  138. ClassName,
  139. RelativeName,
  140. _Credentials,
  141. ppObject,
  142. TRUE
  143. );
  144. RRETURN(hr);
  145. }
  146. STDMETHODIMP
  147. CIISNamespace::get__NewEnum(THIS_ IUnknown * FAR* retval)
  148. {
  149. HRESULT hr;
  150. IUnknown FAR* punkEnum=NULL;
  151. IEnumVARIANT * penum = NULL;
  152. *retval = NULL;
  153. //
  154. // Create new enumerator for items currently
  155. // in collection and QI for IUnknown
  156. //
  157. hr = CIISNamespaceEnum::Create(
  158. (CIISNamespaceEnum **)&penum,
  159. _vFilter,
  160. _Credentials
  161. );
  162. if (FAILED(hr)){
  163. goto error;
  164. }
  165. hr = penum->QueryInterface(
  166. IID_IUnknown,
  167. (VOID FAR* FAR*)retval
  168. );
  169. if (FAILED(hr)){
  170. goto error;
  171. }
  172. if (penum) {
  173. penum->Release();
  174. }
  175. return NOERROR;
  176. error:
  177. if (penum) {
  178. delete penum;
  179. }
  180. return hr;
  181. }
  182. STDMETHODIMP
  183. CIISNamespace::Create(THIS_ BSTR ClassName, BSTR RelativeName, IDispatch * FAR* ppObject)
  184. {
  185. RRETURN(E_NOTIMPL);
  186. }
  187. STDMETHODIMP
  188. CIISNamespace::Delete(THIS_ BSTR SourceName, BSTR Type)
  189. {
  190. RRETURN(E_NOTIMPL);
  191. }
  192. STDMETHODIMP
  193. CIISNamespace::CopyHere(THIS_ BSTR SourceName, BSTR NewName, IDispatch * FAR* ppObject)
  194. {
  195. RRETURN(E_NOTIMPL);
  196. }
  197. STDMETHODIMP
  198. CIISNamespace::MoveHere(THIS_ BSTR SourceName, BSTR NewName, IDispatch * FAR* ppObject)
  199. {
  200. RRETURN(E_NOTIMPL);
  201. }
  202. HRESULT
  203. CIISNamespace::AllocateNamespaceObject(
  204. CCredentials& Credentials,
  205. CIISNamespace ** ppNamespace
  206. )
  207. {
  208. CIISNamespace FAR * pNamespace = NULL;
  209. CAggregatorDispMgr FAR * pDispMgr = NULL;
  210. HRESULT hr = S_OK;
  211. pNamespace = new CIISNamespace();
  212. if (pNamespace == NULL) {
  213. hr = E_OUTOFMEMORY;
  214. }
  215. BAIL_ON_FAILURE(hr);
  216. pDispMgr = new CAggregatorDispMgr;
  217. if (pDispMgr == NULL) {
  218. hr = E_OUTOFMEMORY;
  219. }
  220. BAIL_ON_FAILURE(hr);
  221. hr = pDispMgr->LoadTypeInfoEntry(
  222. LIBID_ADs,
  223. IID_IADs,
  224. (IADs *)pNamespace,
  225. DISPID_REGULAR
  226. );
  227. BAIL_ON_FAILURE(hr);
  228. hr = pDispMgr->LoadTypeInfoEntry(
  229. LIBID_ADs,
  230. IID_IADsOpenDSObject,
  231. (IADsOpenDSObject *)pNamespace,
  232. DISPID_REGULAR
  233. );
  234. BAIL_ON_FAILURE(hr);
  235. hr = pDispMgr->LoadTypeInfoEntry(
  236. LIBID_ADs,
  237. IID_IADsContainer,
  238. (IADsContainer *)pNamespace,
  239. DISPID_NEWENUM
  240. );
  241. BAIL_ON_FAILURE(hr);
  242. pNamespace->_Credentials = Credentials;
  243. pNamespace->_pDispMgr = pDispMgr;
  244. *ppNamespace = pNamespace;
  245. RRETURN(hr);
  246. error:
  247. delete pDispMgr;
  248. RRETURN(hr);
  249. }
  250. STDMETHODIMP
  251. CIISNamespace::Get(
  252. THIS_ BSTR bstrName,
  253. VARIANT FAR* pvProp
  254. )
  255. {
  256. //
  257. // retrieve dataobject from cache; if one exists
  258. //
  259. //
  260. //
  261. //
  262. RRETURN(E_NOTIMPL);
  263. }
  264. STDMETHODIMP
  265. CIISNamespace::Put(
  266. THIS_ BSTR bstrName,
  267. VARIANT vProp
  268. )
  269. {
  270. RRETURN(E_NOTIMPL);
  271. }
  272. STDMETHODIMP
  273. CIISNamespace::GetEx(
  274. THIS_ BSTR bstrName,
  275. VARIANT FAR* pvProp
  276. )
  277. {
  278. RRETURN(E_NOTIMPL);
  279. }
  280. STDMETHODIMP
  281. CIISNamespace::PutEx(
  282. THIS_ long lnControlCode,
  283. BSTR bstrName,
  284. VARIANT vProp
  285. )
  286. {
  287. RRETURN(E_NOTIMPL);
  288. }
  289. STDMETHODIMP
  290. CIISNamespace::OpenDSObject(
  291. BSTR lpszDNName,
  292. BSTR lpszUserName,
  293. BSTR lpszPassword,
  294. LONG lnReserved,
  295. IDispatch FAR * * ppADsObj
  296. )
  297. {
  298. HRESULT hr = S_OK;
  299. IUnknown * pObject = NULL;
  300. CCredentials Credentials;
  301. hr = ::GetObject(
  302. lpszDNName,
  303. Credentials,
  304. (LPVOID *)&pObject
  305. );
  306. BAIL_ON_FAILURE(hr);
  307. hr = pObject->QueryInterface(
  308. IID_IDispatch,
  309. (void **)ppADsObj
  310. );
  311. BAIL_ON_FAILURE(hr);
  312. error:
  313. if (pObject) {
  314. pObject->Release();
  315. }
  316. RRETURN(hr);
  317. }