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.

569 lines
13 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: cgroup.cxx
  7. //
  8. // Contents: OrganizationUnit object
  9. //
  10. // History: 11-1-95 krishnag Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "nds.hxx"
  14. #pragma hdrstop
  15. struct _propmap
  16. {
  17. LPTSTR pszADsProp;
  18. LPTSTR pszNDSProp;
  19. } aOrgUnitPropMapping[] =
  20. { { TEXT("Description"), TEXT("Description") },
  21. { TEXT("LocalityName"), TEXT("L") },
  22. { TEXT("PostalAddress"), TEXT("Postal Address") },
  23. { TEXT("TelephoneNumber"), TEXT("Telephone Number") },
  24. { TEXT("FaxNumber"), TEXT("Facsimile Telephone Number") },
  25. { TEXT("SeeAlso"), TEXT("See Also") }
  26. // { TEXT("BusinessCategory"), TEXT("businessCategory") } BUG BUG
  27. };
  28. // Class CNDSOrganizationUnit
  29. DEFINE_IDispatch_Implementation(CNDSOrganizationUnit)
  30. DEFINE_CONTAINED_IADs_Implementation(CNDSOrganizationUnit)
  31. DEFINE_CONTAINED_IDirectoryObject_Implementation(CNDSOrganizationUnit)
  32. DEFINE_CONTAINED_IDirectorySearch_Implementation(CNDSOrganizationUnit)
  33. DEFINE_CONTAINED_IDirectorySchemaMgmt_Implementation(CNDSOrganizationUnit)
  34. DEFINE_CONTAINED_IADsPropertyList_Implementation(CNDSOrganizationUnit)
  35. DEFINE_CONTAINED_IADsPutGet_Implementation(CNDSOrganizationUnit, aOrgUnitPropMapping)
  36. CNDSOrganizationUnit::CNDSOrganizationUnit():
  37. _pADs(NULL),
  38. _pDSObject(NULL),
  39. _pDSSearch(NULL),
  40. _pDSSchemaMgmt(NULL),
  41. _pADsContainer(NULL),
  42. _pADsPropList(NULL),
  43. _pDispMgr(NULL)
  44. {
  45. ENLIST_TRACKING(CNDSOrganizationUnit);
  46. }
  47. HRESULT
  48. CNDSOrganizationUnit::CreateOrganizationUnit(
  49. IADs * pADs,
  50. REFIID riid,
  51. void **ppvObj
  52. )
  53. {
  54. CNDSOrganizationUnit FAR * pOrganizationUnit = NULL;
  55. HRESULT hr = S_OK;
  56. hr = AllocateOrganizationUnitObject(pADs, &pOrganizationUnit);
  57. BAIL_ON_FAILURE(hr);
  58. hr = pOrganizationUnit->QueryInterface(riid, ppvObj);
  59. BAIL_ON_FAILURE(hr);
  60. pOrganizationUnit->Release();
  61. RRETURN(hr);
  62. error:
  63. delete pOrganizationUnit;
  64. RRETURN_EXP_IF_ERR(hr);
  65. }
  66. CNDSOrganizationUnit::~CNDSOrganizationUnit( )
  67. {
  68. if ( _pADs )
  69. _pADs->Release();
  70. if ( _pADsContainer )
  71. _pADsContainer->Release();
  72. if ( _pDSObject )
  73. _pDSObject->Release();
  74. if ( _pDSSearch )
  75. _pDSSearch->Release();
  76. if ( _pDSSchemaMgmt )
  77. _pDSSchemaMgmt->Release();
  78. if (_pADsPropList) {
  79. _pADsPropList->Release();
  80. }
  81. delete _pDispMgr;
  82. }
  83. STDMETHODIMP
  84. CNDSOrganizationUnit::QueryInterface(
  85. REFIID iid,
  86. LPVOID FAR* ppv
  87. )
  88. {
  89. if (ppv == NULL) {
  90. RRETURN(E_POINTER);
  91. }
  92. if (IsEqualIID(iid, IID_IUnknown))
  93. {
  94. *ppv = (IADsOU FAR *) this;
  95. }
  96. else if (IsEqualIID(iid, IID_IADsOU))
  97. {
  98. *ppv = (IADsOU FAR *) this;
  99. }
  100. else if (IsEqualIID(iid, IID_IADs))
  101. {
  102. *ppv = (IADsOU FAR *) this;
  103. }
  104. else if (IsEqualIID(iid, IID_IDispatch))
  105. {
  106. *ppv = (IADsOU FAR *) this;
  107. }
  108. else if (IsEqualIID(iid, IID_ISupportErrorInfo))
  109. {
  110. *ppv = (ISupportErrorInfo FAR *) this;
  111. }
  112. else if (IsEqualIID(iid, IID_IADsContainer) && _pADsContainer)
  113. {
  114. *ppv = (IADsContainer FAR *) this;
  115. }
  116. else if (IsEqualIID(iid, IID_IDirectoryObject))
  117. {
  118. *ppv = (IDirectoryObject FAR *) this;
  119. }
  120. else if (IsEqualIID(iid, IID_IDirectorySearch))
  121. {
  122. *ppv = (IDirectorySearch FAR *) this;
  123. }
  124. else if (IsEqualIID(iid, IID_IADsPropertyList ) && _pADsPropList)
  125. {
  126. *ppv = (IADsPropertyList FAR *) this;
  127. }
  128. else if (IsEqualIID(iid, IID_IDirectorySchemaMgmt))
  129. {
  130. *ppv = (IDirectorySchemaMgmt FAR *) this;
  131. }
  132. else
  133. {
  134. *ppv = NULL;
  135. return E_NOINTERFACE;
  136. }
  137. AddRef();
  138. return NOERROR;
  139. }
  140. HRESULT
  141. CNDSOrganizationUnit::AllocateOrganizationUnitObject(
  142. IADs *pADs,
  143. CNDSOrganizationUnit ** ppOrganizationUnit
  144. )
  145. {
  146. CNDSOrganizationUnit FAR * pOrganizationUnit = NULL;
  147. CDispatchMgr FAR * pDispMgr = NULL;
  148. HRESULT hr = S_OK;
  149. IADsContainer FAR * pADsContainer = NULL;
  150. IDirectoryObject * pDSObject = NULL;
  151. IDirectorySearch * pDSSearch = NULL;
  152. IDirectorySchemaMgmt * pDSSchemaMgmt = NULL;
  153. IADsPropertyList * pADsPropList = NULL;
  154. pOrganizationUnit = new CNDSOrganizationUnit();
  155. if (pOrganizationUnit == NULL) {
  156. hr = E_OUTOFMEMORY;
  157. }
  158. BAIL_ON_FAILURE(hr);
  159. pDispMgr = new CDispatchMgr;
  160. if (pDispMgr == NULL) {
  161. hr = E_OUTOFMEMORY;
  162. }
  163. BAIL_ON_FAILURE(hr);
  164. hr = LoadTypeInfoEntry(
  165. pDispMgr,
  166. LIBID_ADs,
  167. IID_IADsOU,
  168. (IADsOU *)pOrganizationUnit,
  169. DISPID_REGULAR
  170. );
  171. BAIL_ON_FAILURE(hr);
  172. hr = LoadTypeInfoEntry(
  173. pDispMgr,
  174. LIBID_ADs,
  175. IID_IADsContainer,
  176. (IADsContainer *)pOrganizationUnit,
  177. DISPID_NEWENUM
  178. );
  179. BAIL_ON_FAILURE(hr);
  180. hr = LoadTypeInfoEntry(
  181. pDispMgr,
  182. LIBID_ADs,
  183. IID_IADsPropertyList,
  184. (IADsPropertyList *)pOrganizationUnit,
  185. DISPID_VALUE
  186. );
  187. BAIL_ON_FAILURE(hr);
  188. hr = pADs->QueryInterface(
  189. IID_IDirectoryObject,
  190. (void **)&pDSObject
  191. );
  192. BAIL_ON_FAILURE(hr);
  193. pOrganizationUnit->_pDSObject = pDSObject;
  194. hr = pADs->QueryInterface(
  195. IID_IDirectorySearch,
  196. (void **)&pDSSearch
  197. );
  198. BAIL_ON_FAILURE(hr);
  199. pOrganizationUnit->_pDSSearch = pDSSearch;
  200. hr = pADs->QueryInterface(
  201. IID_IDirectorySchemaMgmt,
  202. (void **)&pDSSchemaMgmt
  203. );
  204. BAIL_ON_FAILURE(hr);
  205. pOrganizationUnit->_pDSSchemaMgmt = pDSSchemaMgmt;
  206. //
  207. // Store the pointer to the internal generic object
  208. // AND add ref this pointer
  209. //
  210. pOrganizationUnit->_pADs = pADs;
  211. pADs->AddRef();
  212. //
  213. // Store a pointer to the Container interface
  214. //
  215. hr = pADs->QueryInterface(
  216. IID_IADsContainer,
  217. (void **)&pADsContainer
  218. );
  219. BAIL_ON_FAILURE(hr);
  220. pOrganizationUnit->_pADsContainer = pADsContainer;
  221. hr = pADs->QueryInterface(
  222. IID_IADsPropertyList,
  223. (void **)&pADsPropList
  224. );
  225. BAIL_ON_FAILURE(hr);
  226. pOrganizationUnit->_pADsPropList = pADsPropList;
  227. pOrganizationUnit->_pDispMgr = pDispMgr;
  228. *ppOrganizationUnit = pOrganizationUnit;
  229. RRETURN(hr);
  230. error:
  231. delete pOrganizationUnit;
  232. delete pDispMgr;
  233. RRETURN(hr);
  234. }
  235. /* ISupportErrorInfo method */
  236. STDMETHODIMP
  237. CNDSOrganizationUnit::InterfaceSupportsErrorInfo(
  238. THIS_ REFIID riid
  239. )
  240. {
  241. if (IsEqualIID(riid, IID_IADs) ||
  242. #if 0
  243. IsEqualIID(riid, IID_IDirectoryObject) ||
  244. IsEqualIID(riid, IID_IDirectorySearch) ||
  245. IsEqualIID(riid, IID_IDirectorySchemaMgmt) ||
  246. #endif
  247. IsEqualIID(riid, IID_IADsOU) ||
  248. IsEqualIID(riid, IID_IADsContainer) ||
  249. IsEqualIID(riid, IID_IADsPropertyList)) {
  250. RRETURN(S_OK);
  251. } else {
  252. RRETURN(S_FALSE);
  253. }
  254. }
  255. STDMETHODIMP CNDSOrganizationUnit::get_Description(THIS_ BSTR FAR* retval)
  256. {
  257. GET_PROPERTY_BSTR((IADsOU *)this,Description);
  258. }
  259. STDMETHODIMP CNDSOrganizationUnit::put_Description(THIS_ BSTR bstrDescription)
  260. {
  261. PUT_PROPERTY_BSTR((IADsOU *)this,Description);
  262. }
  263. STDMETHODIMP CNDSOrganizationUnit::get_LocalityName(THIS_ BSTR FAR* retval)
  264. {
  265. GET_PROPERTY_BSTR((IADsOU *)this,LocalityName);
  266. }
  267. STDMETHODIMP CNDSOrganizationUnit::put_LocalityName(THIS_ BSTR bstrLocalityName)
  268. {
  269. PUT_PROPERTY_BSTR((IADsOU *)this,LocalityName);
  270. }
  271. STDMETHODIMP CNDSOrganizationUnit::get_PostalAddress(THIS_ BSTR FAR* retval)
  272. {
  273. GET_PROPERTY_BSTR((IADsOU *)this,PostalAddress);
  274. }
  275. STDMETHODIMP CNDSOrganizationUnit::put_PostalAddress(THIS_ BSTR bstrPostalAddress)
  276. {
  277. PUT_PROPERTY_BSTR((IADsOU *)this,PostalAddress);
  278. }
  279. STDMETHODIMP CNDSOrganizationUnit::get_TelephoneNumber(THIS_ BSTR FAR* retval)
  280. {
  281. GET_PROPERTY_BSTR((IADsOU *)this,TelephoneNumber);
  282. }
  283. STDMETHODIMP CNDSOrganizationUnit::put_TelephoneNumber(THIS_ BSTR bstrTelephoneNumber)
  284. {
  285. PUT_PROPERTY_BSTR((IADsOU *)this,TelephoneNumber);
  286. }
  287. STDMETHODIMP CNDSOrganizationUnit::get_FaxNumber(THIS_ BSTR FAR* retval)
  288. {
  289. GET_PROPERTY_BSTR((IADsOU *)this,FaxNumber);
  290. }
  291. STDMETHODIMP CNDSOrganizationUnit::put_FaxNumber(THIS_ BSTR bstrFaxNumber)
  292. {
  293. PUT_PROPERTY_BSTR((IADsOU *)this,FaxNumber);
  294. }
  295. STDMETHODIMP CNDSOrganizationUnit::get_SeeAlso(THIS_ VARIANT FAR* retval)
  296. {
  297. GET_PROPERTY_VARIANT((IADsOU *)this,SeeAlso);
  298. }
  299. STDMETHODIMP CNDSOrganizationUnit::put_SeeAlso(THIS_ VARIANT vSeeAlso)
  300. {
  301. PUT_PROPERTY_VARIANT((IADsOU *)this,SeeAlso);
  302. }
  303. STDMETHODIMP CNDSOrganizationUnit::get_BusinessCategory(THIS_ BSTR FAR* retval)
  304. {
  305. GET_PROPERTY_BSTR((IADsOU *)this,BusinessCategory);
  306. }
  307. STDMETHODIMP CNDSOrganizationUnit::put_BusinessCategory(THIS_ BSTR bstrBusinessCategory)
  308. {
  309. PUT_PROPERTY_BSTR((IADsOU *)this,BusinessCategory);
  310. }
  311. /* IADsContainer methods */
  312. STDMETHODIMP
  313. CNDSOrganizationUnit::get_Count(long FAR* retval)
  314. {
  315. HRESULT hr = E_NOTIMPL;
  316. if (_pADsContainer) {
  317. hr = _pADsContainer->get_Count(
  318. retval
  319. );
  320. }
  321. RRETURN_EXP_IF_ERR(hr);
  322. }
  323. STDMETHODIMP
  324. CNDSOrganizationUnit::get_Filter(THIS_ VARIANT FAR* pVar)
  325. {
  326. HRESULT hr = E_NOTIMPL;
  327. if (_pADsContainer) {
  328. hr = _pADsContainer->get_Filter(
  329. pVar
  330. );
  331. }
  332. RRETURN_EXP_IF_ERR(hr);
  333. }
  334. STDMETHODIMP
  335. CNDSOrganizationUnit::put_Filter(THIS_ VARIANT Var)
  336. {
  337. HRESULT hr = E_NOTIMPL;
  338. if (_pADsContainer) {
  339. hr = _pADsContainer->put_Filter(
  340. Var
  341. );
  342. }
  343. RRETURN_EXP_IF_ERR(hr);
  344. }
  345. STDMETHODIMP
  346. CNDSOrganizationUnit::put_Hints(THIS_ VARIANT Var)
  347. {
  348. HRESULT hr = E_NOTIMPL;
  349. if (_pADsContainer) {
  350. hr = _pADsContainer->put_Hints(
  351. Var
  352. );
  353. }
  354. RRETURN_EXP_IF_ERR(hr);
  355. }
  356. STDMETHODIMP
  357. CNDSOrganizationUnit::get_Hints(THIS_ VARIANT FAR* pVar)
  358. {
  359. HRESULT hr = E_NOTIMPL;
  360. if (_pADsContainer) {
  361. hr = _pADsContainer->get_Hints(
  362. pVar
  363. );
  364. }
  365. RRETURN_EXP_IF_ERR(hr);
  366. }
  367. STDMETHODIMP
  368. CNDSOrganizationUnit::GetObject(
  369. BSTR ClassName,
  370. BSTR RelativeName,
  371. IDispatch * FAR* ppObject
  372. )
  373. {
  374. HRESULT hr = E_NOTIMPL;
  375. if (_pADsContainer) {
  376. hr = _pADsContainer->GetObject(
  377. ClassName,
  378. RelativeName,
  379. ppObject
  380. );
  381. }
  382. RRETURN_EXP_IF_ERR(hr);
  383. }
  384. STDMETHODIMP
  385. CNDSOrganizationUnit::get__NewEnum(
  386. THIS_ IUnknown * FAR* retval
  387. )
  388. {
  389. HRESULT hr = E_NOTIMPL;
  390. if (_pADsContainer) {
  391. hr = _pADsContainer->get__NewEnum(
  392. retval
  393. );
  394. }
  395. RRETURN_EXP_IF_ERR(hr);
  396. }
  397. STDMETHODIMP
  398. CNDSOrganizationUnit::Create(
  399. THIS_ BSTR ClassName,
  400. BSTR RelativeName,
  401. IDispatch * FAR* ppObject
  402. )
  403. {
  404. HRESULT hr = E_NOTIMPL;
  405. if (_pADsContainer) {
  406. hr = _pADsContainer->Create(
  407. ClassName,
  408. RelativeName,
  409. ppObject
  410. );
  411. }
  412. RRETURN_EXP_IF_ERR(hr);
  413. }
  414. STDMETHODIMP
  415. CNDSOrganizationUnit::Delete(
  416. THIS_ BSTR bstrClassName,
  417. BSTR bstrRelativeName
  418. )
  419. {
  420. HRESULT hr = E_NOTIMPL;
  421. if (_pADsContainer) {
  422. hr = _pADsContainer->Delete(
  423. bstrClassName,
  424. bstrRelativeName
  425. );
  426. }
  427. RRETURN_EXP_IF_ERR(hr);
  428. }
  429. STDMETHODIMP
  430. CNDSOrganizationUnit::CopyHere(
  431. THIS_ BSTR SourceName,
  432. BSTR NewName,
  433. IDispatch * FAR* ppObject
  434. )
  435. {
  436. HRESULT hr = E_NOTIMPL;
  437. if (_pADsContainer) {
  438. hr = _pADsContainer->CopyHere(
  439. SourceName,
  440. NewName,
  441. ppObject
  442. );
  443. }
  444. RRETURN_EXP_IF_ERR(hr);
  445. }
  446. STDMETHODIMP
  447. CNDSOrganizationUnit::MoveHere(
  448. THIS_ BSTR SourceName,
  449. BSTR NewName,
  450. IDispatch * FAR* ppObject
  451. )
  452. {
  453. HRESULT hr = E_NOTIMPL;
  454. if (_pADsContainer) {
  455. hr = _pADsContainer->MoveHere(
  456. SourceName,
  457. NewName,
  458. ppObject
  459. );
  460. }
  461. RRETURN_EXP_IF_ERR(hr);
  462. }
  463.