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.

397 lines
6.7 KiB

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