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.

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