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.

414 lines
7.7 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. if (pDispMgr)
  248. {
  249. delete pDispMgr;
  250. }
  251. if (pNamespace)
  252. {
  253. delete pNamespace;
  254. }
  255. RRETURN(hr);
  256. }
  257. STDMETHODIMP
  258. CIISNamespace::Get(
  259. THIS_ BSTR bstrName,
  260. VARIANT FAR* pvProp
  261. )
  262. {
  263. //
  264. // retrieve dataobject from cache; if one exists
  265. //
  266. //
  267. //
  268. //
  269. RRETURN(E_NOTIMPL);
  270. }
  271. STDMETHODIMP
  272. CIISNamespace::Put(
  273. THIS_ BSTR bstrName,
  274. VARIANT vProp
  275. )
  276. {
  277. RRETURN(E_NOTIMPL);
  278. }
  279. STDMETHODIMP
  280. CIISNamespace::GetEx(
  281. THIS_ BSTR bstrName,
  282. VARIANT FAR* pvProp
  283. )
  284. {
  285. RRETURN(E_NOTIMPL);
  286. }
  287. STDMETHODIMP
  288. CIISNamespace::PutEx(
  289. THIS_ long lnControlCode,
  290. BSTR bstrName,
  291. VARIANT vProp
  292. )
  293. {
  294. RRETURN(E_NOTIMPL);
  295. }
  296. STDMETHODIMP
  297. CIISNamespace::OpenDSObject(
  298. BSTR lpszDNName,
  299. BSTR lpszUserName,
  300. BSTR lpszPassword,
  301. LONG lnReserved,
  302. IDispatch FAR * * ppADsObj
  303. )
  304. {
  305. HRESULT hr = S_OK;
  306. IUnknown * pObject = NULL;
  307. CCredentials Credentials;
  308. hr = Credentials.SetUserName(lpszUserName);
  309. BAIL_ON_FAILURE(hr);
  310. hr = Credentials.SetPassword(lpszPassword);
  311. BAIL_ON_FAILURE(hr);
  312. hr = ::GetObject(
  313. lpszDNName,
  314. Credentials,
  315. (LPVOID *)&pObject
  316. );
  317. BAIL_ON_FAILURE(hr);
  318. hr = pObject->QueryInterface(
  319. IID_IDispatch,
  320. (void **)ppADsObj
  321. );
  322. BAIL_ON_FAILURE(hr);
  323. error:
  324. if (pObject) {
  325. pObject->Release();
  326. }
  327. RRETURN(hr);
  328. }