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.

1528 lines
36 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995
  5. //
  6. // File: cfpnwsrv.cxx
  7. //
  8. // Contents: Contains methods for the following objects
  9. // CFPNWFileService and CFPNWFileServiceGeneralInfo.
  10. //
  11. //
  12. // History: 12/11/95 ramv (Ram Viswanathan) Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "winnt.hxx"
  16. #pragma hdrstop
  17. #define INITGUID
  18. //
  19. // class CFPNWFileService methods
  20. //
  21. DEFINE_IDispatch_ExtMgr_Implementation(CFPNWFileService);
  22. DEFINE_IADsExtension_ExtMgr_Implementation(CFPNWFileService);
  23. DEFINE_IADs_TempImplementation(CFPNWFileService);
  24. CFPNWFileService::CFPNWFileService()
  25. {
  26. _pDispMgr = NULL;
  27. _pExtMgr = NULL;
  28. _pService = NULL;
  29. _pCFileSharesEnumVar = NULL;
  30. _pszServerName = NULL;
  31. _pPropertyCache = NULL;
  32. ENLIST_TRACKING(CFPNWFileService);
  33. VariantInit(&_vFilter);
  34. return;
  35. }
  36. CFPNWFileService::~CFPNWFileService()
  37. {
  38. if(_pService){
  39. _pService->Release();
  40. }
  41. if (_pServiceOps) {
  42. _pServiceOps->Release();
  43. }
  44. delete _pExtMgr; // created last, destroyed first
  45. delete _pDispMgr;
  46. if(_pszServerName){
  47. FreeADsStr(_pszServerName);
  48. }
  49. VariantClear(&_vFilter);
  50. delete _pPropertyCache;
  51. return;
  52. }
  53. //+---------------------------------------------------------------------------
  54. //
  55. // Function: CFPNWFileService::CreateFileService
  56. //
  57. // Synopsis: Static function used to create a FileService object. This
  58. // will be called by BindToObject
  59. //
  60. // Arguments: [ppFPNWFileService] -- Ptr to a ptr to a new Service object.
  61. //
  62. // Returns: HRESULT.
  63. //
  64. // Modifies:
  65. //
  66. // History: 12-11-95 RamV Created.
  67. //
  68. //----------------------------------------------------------------------------
  69. HRESULT
  70. CFPNWFileService::CreateFileService(LPTSTR pszADsParent,
  71. DWORD dwParentId,
  72. LPTSTR pszDomainName,
  73. LPTSTR pszServerName,
  74. LPTSTR pszFileServiceName,
  75. DWORD dwObjectState,
  76. REFIID riid,
  77. CWinNTCredentials& Credentials,
  78. LPVOID * ppvoid
  79. )
  80. {
  81. CFPNWFileService FAR * pCFPNWFileService = NULL;
  82. HRESULT hr = S_OK;
  83. //
  84. // Create the FileService Object
  85. //
  86. hr = AllocateFileServiceObject(&pCFPNWFileService);
  87. BAIL_ON_FAILURE(hr);
  88. ADsAssert(pCFPNWFileService->_pDispMgr);
  89. hr = pCFPNWFileService->InitializeCoreObject(pszADsParent,
  90. pszFileServiceName,
  91. FILESERVICE_CLASS_NAME,
  92. FPNW_FILESERVICE_SCHEMA_NAME,
  93. CLSID_FPNWFileService,
  94. dwObjectState);
  95. //
  96. // note that no class fileservice is defined
  97. //
  98. BAIL_ON_FAILURE(hr);
  99. pCFPNWFileService->_Credentials = Credentials;
  100. hr = pCFPNWFileService->_Credentials.Ref(pszServerName,
  101. pszDomainName, dwParentId);
  102. BAIL_ON_FAILURE(hr);
  103. hr = CWinNTService::Create(pszADsParent,
  104. pszDomainName,
  105. pszServerName,
  106. pszFileServiceName,
  107. dwObjectState,
  108. IID_IADsService,
  109. pCFPNWFileService->_Credentials,
  110. (void **)(&(pCFPNWFileService->_pService)));
  111. BAIL_ON_FAILURE(hr);
  112. hr = (pCFPNWFileService->_pService)->QueryInterface(
  113. IID_IADsServiceOperations,
  114. (void **)&(pCFPNWFileService->_pServiceOps));
  115. BAIL_ON_FAILURE(hr);
  116. pCFPNWFileService->_pszServerName =
  117. AllocADsStr(pszServerName);
  118. if(!(pCFPNWFileService->_pszServerName)){
  119. hr = E_OUTOFMEMORY;
  120. goto error;
  121. }
  122. pCFPNWFileService->_Credentials = Credentials;
  123. hr = pCFPNWFileService->_Credentials.RefServer(pszServerName);
  124. BAIL_ON_FAILURE(hr);
  125. //
  126. // Load ext mgr and extensions
  127. //
  128. hr = ADSILoadExtensionManager(
  129. FILESERVICE_CLASS_NAME,
  130. (IADsFileService *) pCFPNWFileService,
  131. pCFPNWFileService->_pDispMgr,
  132. Credentials,
  133. &pCFPNWFileService->_pExtMgr
  134. );
  135. BAIL_ON_FAILURE(hr);
  136. ADsAssert(pCFPNWFileService->_pExtMgr);
  137. // check if the call is from UMI
  138. if(Credentials.GetFlags() & ADS_AUTH_RESERVED) {
  139. //
  140. // we do not pass riid to InitUmiObject below. This is because UMI object
  141. // does not support IDispatch. There are several places in ADSI code where
  142. // riid passed into this function is defaulted to IID_IDispatch -
  143. // IADsContainer::Create for example. To handle these cases, we always
  144. // request IID_IUnknown from the UMI object. Subsequent code within UMI
  145. // will QI for the appropriate interface.
  146. //
  147. if(3 == pCFPNWFileService->_dwNumComponents) {
  148. pCFPNWFileService->_CompClasses[0] = L"Domain";
  149. pCFPNWFileService->_CompClasses[1] = L"Computer";
  150. pCFPNWFileService->_CompClasses[2] = L"FileService";
  151. }
  152. else
  153. BAIL_ON_FAILURE(hr = UMI_E_FAIL);
  154. hr = pCFPNWFileService->InitUmiObject(
  155. pCFPNWFileService->_Credentials,
  156. FPNWFileServiceClass,
  157. gdwFPNWFileServiceTableSize,
  158. pCFPNWFileService->_pPropertyCache,
  159. (IUnknown *) (INonDelegatingUnknown *) pCFPNWFileService,
  160. pCFPNWFileService->_pExtMgr,
  161. IID_IUnknown,
  162. ppvoid
  163. );
  164. BAIL_ON_FAILURE(hr);
  165. //
  166. // UMI object was created and the interface was obtained successfully.
  167. // UMI object now has a reference to the inner unknown of IADs, since
  168. // the call to Release() below is not going to be made in this case.
  169. //
  170. RRETURN(hr);
  171. }
  172. hr = pCFPNWFileService->QueryInterface(riid, (void **)ppvoid);
  173. BAIL_ON_FAILURE(hr);
  174. pCFPNWFileService->Release();
  175. RRETURN(hr);
  176. error:
  177. delete pCFPNWFileService;
  178. RRETURN (hr);
  179. }
  180. HRESULT
  181. CFPNWFileService::AllocateFileServiceObject(
  182. CFPNWFileService ** ppFileService
  183. )
  184. {
  185. CFPNWFileService FAR * pFileService = NULL;
  186. HRESULT hr = S_OK;
  187. pFileService = new CFPNWFileService();
  188. if (pFileService == NULL) {
  189. hr = E_OUTOFMEMORY;
  190. }
  191. BAIL_ON_FAILURE(hr);
  192. pFileService->_pDispMgr = new CAggregatorDispMgr;
  193. if (pFileService->_pDispMgr == NULL) {
  194. hr = E_OUTOFMEMORY;
  195. }
  196. BAIL_ON_FAILURE(hr);
  197. hr = LoadTypeInfoEntry(pFileService->_pDispMgr,
  198. LIBID_ADs,
  199. IID_IADsFileService,
  200. (IADsFileService *)pFileService,
  201. DISPID_REGULAR);
  202. BAIL_ON_FAILURE(hr);
  203. hr = LoadTypeInfoEntry(pFileService->_pDispMgr,
  204. LIBID_ADs,
  205. IID_IADsContainer,
  206. (IADsContainer *)pFileService,
  207. DISPID_NEWENUM);
  208. BAIL_ON_FAILURE(hr);
  209. hr = LoadTypeInfoEntry(pFileService->_pDispMgr,
  210. LIBID_ADs,
  211. IID_IADsPropertyList,
  212. (IADsPropertyList *)pFileService,
  213. DISPID_VALUE);
  214. BAIL_ON_FAILURE(hr);
  215. hr = CPropertyCache::createpropertycache(
  216. FPNWFileServiceClass,
  217. gdwFPNWFileServiceTableSize,
  218. (CCoreADsObject *)pFileService,
  219. &(pFileService->_pPropertyCache)
  220. );
  221. BAIL_ON_FAILURE(hr);
  222. (pFileService->_pDispMgr)->RegisterPropertyCache(
  223. pFileService->_pPropertyCache
  224. );
  225. *ppFileService = pFileService;
  226. RRETURN(hr);
  227. error:
  228. //
  229. // direct memeber assignement assignement at pt of creation, so
  230. // do NOT delete _pPropertyCache or _pDisMgr here to avoid attempt
  231. // of deletion again in pPrintJob destructor and AV
  232. //
  233. delete pFileService;
  234. RRETURN_EXP_IF_ERR(hr);
  235. }
  236. /* IUnknown methods for file service object */
  237. //----------------------------------------------------------------------------
  238. // Function: QueryInterface
  239. //
  240. // Synopsis: If this object is aggregated within another object, then
  241. // all calls will delegate to the outer object. Otherwise, the
  242. // non-delegating QI is called
  243. //
  244. // Arguments:
  245. //
  246. // iid interface requested
  247. // ppInterface Returns pointer to interface requested. NULL if interface
  248. // is not supported.
  249. //
  250. // Returns: S_OK on success. Error code otherwise.
  251. //
  252. // Modifies: *ppInterface to return interface pointer
  253. //
  254. //----------------------------------------------------------------------------
  255. STDMETHODIMP CFPNWFileService::QueryInterface(
  256. REFIID iid,
  257. LPVOID *ppInterface
  258. )
  259. {
  260. if(_pUnkOuter != NULL)
  261. RRETURN(_pUnkOuter->QueryInterface(
  262. iid,
  263. ppInterface
  264. ));
  265. RRETURN(NonDelegatingQueryInterface(
  266. iid,
  267. ppInterface
  268. ));
  269. }
  270. //----------------------------------------------------------------------------
  271. // Function: AddRef
  272. //
  273. // Synopsis: IUnknown::AddRef. If this object is aggregated within
  274. // another, all calls will delegate to the outer object.
  275. // Otherwise, the non-delegating AddRef is called
  276. //
  277. // Arguments:
  278. //
  279. // None
  280. //
  281. // Returns: New reference count
  282. //
  283. // Modifies: Nothing
  284. //
  285. //----------------------------------------------------------------------------
  286. STDMETHODIMP_(ULONG) CFPNWFileService::AddRef(void)
  287. {
  288. if(_pUnkOuter != NULL)
  289. RRETURN(_pUnkOuter->AddRef());
  290. RRETURN(NonDelegatingAddRef());
  291. }
  292. //----------------------------------------------------------------------------
  293. // Function: Release
  294. //
  295. // Synopsis: IUnknown::Release. If this object is aggregated within
  296. // another, all calls will delegate to the outer object.
  297. // Otherwise, the non-delegating Release is called
  298. //
  299. // Arguments:
  300. //
  301. // None
  302. //
  303. // Returns: New reference count
  304. //
  305. // Modifies: Nothing
  306. //
  307. //----------------------------------------------------------------------------
  308. STDMETHODIMP_(ULONG) CFPNWFileService::Release(void)
  309. {
  310. if(_pUnkOuter != NULL)
  311. RRETURN(_pUnkOuter->Release());
  312. RRETURN(NonDelegatingRelease());
  313. }
  314. //----------------------------------------------------------------------------
  315. STDMETHODIMP
  316. CFPNWFileService::NonDelegatingQueryInterface(REFIID riid, LPVOID FAR* ppvObj)
  317. {
  318. HRESULT hr = S_OK;
  319. if(!ppvObj){
  320. RRETURN(E_POINTER);
  321. }
  322. if (IsEqualIID(riid, IID_IUnknown))
  323. {
  324. *ppvObj = (IADsFileService *)this;
  325. }
  326. else if (IsEqualIID(riid, IID_IDispatch))
  327. {
  328. *ppvObj = (IADsFileService *)this;
  329. }
  330. else if (IsEqualIID(riid, IID_ISupportErrorInfo))
  331. {
  332. *ppvObj = (ISupportErrorInfo FAR *) this;
  333. }
  334. else if (IsEqualIID(riid, IID_IADs))
  335. {
  336. *ppvObj = (IADsFileService FAR *) this;
  337. }
  338. else if (IsEqualIID(riid, IID_IADsFileService))
  339. {
  340. *ppvObj = (IADsFileService FAR *) this;
  341. }
  342. else if (IsEqualIID(riid, IID_IADsFileServiceOperations))
  343. {
  344. *ppvObj = (IADsFileServiceOperations FAR *) this;
  345. }
  346. else if (IsEqualIID(riid, IID_IADsService))
  347. {
  348. *ppvObj = (IADsService FAR *) this;
  349. }
  350. else if (IsEqualIID(riid, IID_IADsServiceOperations))
  351. {
  352. *ppvObj = (IADsServiceOperations FAR *) this;
  353. }
  354. else if (IsEqualIID(riid, IID_IADsContainer))
  355. {
  356. *ppvObj = (IADsContainer FAR *) this;
  357. }
  358. else if( (_pDispatch != NULL) &&
  359. IsEqualIID(riid, IID_IADsExtension) )
  360. {
  361. *ppvObj = (IADsExtension *) this;
  362. }
  363. else if (_pExtMgr)
  364. {
  365. RRETURN( _pExtMgr->QueryInterface(riid, ppvObj));
  366. }
  367. else
  368. {
  369. *ppvObj = NULL;
  370. RRETURN(E_NOINTERFACE);
  371. }
  372. ((LPUNKNOWN)*ppvObj)->AddRef();
  373. RRETURN(S_OK);
  374. }
  375. /* ISupportErrorInfo method */
  376. STDMETHODIMP
  377. CFPNWFileService::InterfaceSupportsErrorInfo(
  378. THIS_ REFIID riid
  379. )
  380. {
  381. if (IsEqualIID(riid, IID_IADs) ||
  382. IsEqualIID(riid, IID_IADsService) ||
  383. IsEqualIID(riid, IID_IADsFileService) ||
  384. IsEqualIID(riid, IID_IADsServiceOperations) ||
  385. IsEqualIID(riid, IID_IADsFileServiceOperations) ||
  386. IsEqualIID(riid, IID_IADsContainer)) {
  387. RRETURN(S_OK);
  388. } else {
  389. RRETURN(S_FALSE);
  390. }
  391. }
  392. //+---------------------------------------------------------------------------
  393. //
  394. // Function: SetInfo
  395. //
  396. // Synopsis:
  397. //
  398. // Arguments: void
  399. //
  400. // Returns: HRESULT.
  401. //
  402. // Modifies:
  403. //
  404. // History: RamV Created
  405. //----------------------------------------------------------------------------
  406. STDMETHODIMP
  407. CFPNWFileService::SetInfo(THIS)
  408. {
  409. HRESULT hr;
  410. IADsService * pADsService = NULL;
  411. ADsAssert(_pService);
  412. hr = _pService->SetInfo();
  413. BAIL_IF_ERROR(hr);
  414. hr = SetFPNWServerInfo();
  415. BAIL_IF_ERROR(hr);
  416. if(SUCCEEDED(hr))
  417. _pPropertyCache->ClearModifiedFlags();
  418. cleanup:
  419. RRETURN_EXP_IF_ERR(hr);
  420. }
  421. //+---------------------------------------------------------------------------
  422. //
  423. // Function: GetInfo
  424. //
  425. // Synopsis:
  426. //
  427. // Arguments: void
  428. //
  429. // Returns: HRESULT.
  430. //
  431. // Modifies:
  432. //
  433. // History: 12/11/95 RamV Created
  434. //
  435. //----------------------------------------------------------------------------
  436. STDMETHODIMP
  437. CFPNWFileService::GetInfo(THIS)
  438. {
  439. HRESULT hr =S_OK;
  440. _pPropertyCache->flushpropcache();
  441. hr = GetInfo(1, TRUE);
  442. if(FAILED(hr))
  443. RRETURN_EXP_IF_ERR(hr);
  444. hr = GetInfo(2,TRUE);
  445. RRETURN_EXP_IF_ERR(hr);
  446. }
  447. STDMETHODIMP
  448. CFPNWFileService::ImplicitGetInfo(THIS)
  449. {
  450. HRESULT hr =S_OK;
  451. hr = GetInfo(1, FALSE);
  452. if(FAILED(hr))
  453. RRETURN_EXP_IF_ERR(hr);
  454. hr = GetInfo(2,FALSE);
  455. RRETURN_EXP_IF_ERR(hr);
  456. }
  457. STDMETHODIMP
  458. CFPNWFileService::GetInfo(THIS_ DWORD dwApiLevel, BOOL fExplicit)
  459. {
  460. HRESULT hr =S_OK;
  461. DWORD dwErrCode;
  462. switch(dwApiLevel){
  463. case 1:
  464. ADsAssert(_pService);
  465. hr = _pService->GetInfo();
  466. BAIL_IF_ERROR(hr);
  467. break;
  468. case 2:
  469. hr = GetFPNWServerInfo(fExplicit);
  470. BAIL_IF_ERROR(hr);
  471. break;
  472. default:
  473. ADsAssert(FALSE);
  474. break;
  475. }
  476. cleanup:
  477. RRETURN (hr);
  478. }
  479. HRESULT
  480. CFPNWFileService::SetFPNWServerInfo(THIS)
  481. {
  482. PNWSERVERINFO pServerInfo = NULL;
  483. HRESULT hr = S_OK;
  484. DWORD dwErrorCode;
  485. LPTSTR pszDescription = NULL;
  486. //
  487. // Do a GetInfo to first get all the information in this server.
  488. //
  489. //
  490. // only level 1 is valid
  491. //
  492. dwErrorCode = ADsNwServerGetInfo(_pszServerName,
  493. 1,
  494. &pServerInfo);
  495. hr = HRESULT_FROM_WIN32(dwErrorCode);
  496. BAIL_IF_ERROR(hr);
  497. hr = GetLPTSTRPropertyFromCache(_pPropertyCache,
  498. TEXT("Description"),
  499. &pszDescription );
  500. if(SUCCEEDED(hr)){
  501. pServerInfo->lpDescription = pszDescription;
  502. }
  503. dwErrorCode = ADsNwServerSetInfo(_pszServerName,
  504. 1,
  505. pServerInfo);
  506. hr = HRESULT_FROM_WIN32(dwErrorCode);
  507. BAIL_IF_ERROR(hr);
  508. cleanup:
  509. if(pServerInfo){
  510. ADsNwApiBufferFree(pServerInfo);
  511. }
  512. if(pszDescription){
  513. FreeADsStr(pszDescription);
  514. }
  515. RRETURN_EXP_IF_ERR(hr);
  516. }
  517. HRESULT
  518. CFPNWFileService::GetFPNWServerInfo(THIS_ BOOL fExplicit)
  519. {
  520. //
  521. // here we do a NwServerGetInfo on level1 and then unmarshall the
  522. // comment field into description
  523. //
  524. DWORD dwErrorCode;
  525. PNWSERVERINFO pServerInfo =NULL;
  526. HRESULT hr;
  527. //
  528. // only level 1 is valid
  529. //
  530. dwErrorCode = ADsNwServerGetInfo(_pszServerName,
  531. 1,
  532. &pServerInfo);
  533. hr = HRESULT_FROM_WIN32(dwErrorCode);
  534. BAIL_IF_ERROR(hr);
  535. //
  536. // unmarshall the info into the Description field
  537. //
  538. ADsAssert(pServerInfo);
  539. hr = SetLPTSTRPropertyInCache(_pPropertyCache,
  540. TEXT("Description"),
  541. pServerInfo->lpDescription,
  542. fExplicit
  543. );
  544. hr = SetLPTSTRPropertyInCache(_pPropertyCache,
  545. TEXT("HostComputer"),
  546. _Parent,
  547. fExplicit
  548. );
  549. hr = SetDWORDPropertyInCache(_pPropertyCache,
  550. TEXT("MaxUserCount"),
  551. (DWORD)-1,
  552. fExplicit
  553. );
  554. hr = SetLPTSTRPropertyInCache(
  555. _pPropertyCache,
  556. TEXT("Name"),
  557. _Name,
  558. fExplicit
  559. );
  560. hr = S_OK;
  561. cleanup:
  562. if(pServerInfo){
  563. ADsNwApiBufferFree(pServerInfo);
  564. }
  565. RRETURN_EXP_IF_ERR(hr);
  566. }
  567. STDMETHODIMP
  568. CFPNWFileService::Get(
  569. THIS_ BSTR bstrName,
  570. VARIANT FAR* pvProp
  571. )
  572. {
  573. HRESULT hr = S_OK;
  574. hr = GenericGetPropertyManager(
  575. _pPropertyCache,
  576. bstrName,
  577. pvProp
  578. );
  579. if(FAILED(hr)){
  580. hr= _pService->Get(bstrName, pvProp );
  581. }
  582. RRETURN_EXP_IF_ERR(hr);
  583. }
  584. STDMETHODIMP
  585. CFPNWFileService::Put(
  586. THIS_ BSTR bstrName,
  587. VARIANT vProp
  588. )
  589. {
  590. HRESULT hr = S_OK;
  591. hr = GenericPutPropertyManager(
  592. _pPropertyCache,
  593. FPNWFileServiceClass,
  594. gdwFPNWFileServiceTableSize,
  595. bstrName,
  596. vProp
  597. );
  598. if(FAILED(hr)){
  599. hr= _pService->Put(bstrName, vProp );
  600. }
  601. RRETURN_EXP_IF_ERR(hr);
  602. }
  603. //
  604. // IADsService Methods
  605. //
  606. /* IADsContainer methods */
  607. STDMETHODIMP
  608. CFPNWFileService::get_Count(long * retval)
  609. {
  610. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  611. }
  612. STDMETHODIMP
  613. CFPNWFileService::get_Filter(THIS_ VARIANT * pVar)
  614. {
  615. HRESULT hr;
  616. VariantInit(pVar);
  617. hr = VariantCopy(pVar, &_vFilter);
  618. RRETURN_EXP_IF_ERR(hr);
  619. }
  620. STDMETHODIMP
  621. CFPNWFileService::put_Filter(THIS_ VARIANT Var)
  622. {
  623. HRESULT hr;
  624. hr = VariantCopy(&_vFilter, &Var);
  625. RRETURN_EXP_IF_ERR(hr);
  626. }
  627. STDMETHODIMP
  628. CFPNWFileService::put_Hints(THIS_ VARIANT Var)
  629. {
  630. RRETURN_EXP_IF_ERR( E_NOTIMPL);
  631. }
  632. STDMETHODIMP
  633. CFPNWFileService::get_Hints(THIS_ VARIANT FAR* pVar)
  634. {
  635. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  636. }
  637. STDMETHODIMP
  638. CFPNWFileService::GetObject(THIS_ BSTR ClassName,
  639. BSTR RelativeName,
  640. IDispatch * FAR* ppObject
  641. )
  642. {
  643. HRESULT hr;
  644. DWORD dwObjectType;
  645. POBJECTINFO pObjectInfo = NULL;
  646. hr = GetObjectType(gpFilters,
  647. gdwMaxFilters,
  648. ClassName,
  649. (PDWORD)&dwObjectType);
  650. BAIL_IF_ERROR(hr);
  651. if(dwObjectType != WINNT_FILESHARE_ID){
  652. //
  653. // trying to create an invalid object at this level
  654. //
  655. hr = E_FAIL;
  656. goto error;
  657. }
  658. hr = BuildObjectInfo(_ADsPath,
  659. RelativeName,
  660. &pObjectInfo);
  661. BAIL_ON_FAILURE(hr);
  662. hr = ValidateObject(dwObjectType,
  663. pObjectInfo,
  664. _Credentials);
  665. BAIL_ON_FAILURE(hr);
  666. //
  667. // The only object that has a file service as a container is
  668. // a file share object
  669. //
  670. hr = CFPNWFileShare::Create(_ADsPath,
  671. pObjectInfo->ComponentArray[1],
  672. pObjectInfo->ComponentArray[2],
  673. RelativeName,
  674. ADS_OBJECT_UNBOUND,
  675. IID_IDispatch,
  676. _Credentials,
  677. (void**)ppObject);
  678. BAIL_ON_FAILURE(hr);
  679. error:
  680. cleanup:
  681. FreeObjectInfo(pObjectInfo);
  682. RRETURN_EXP_IF_ERR(hr);
  683. }
  684. STDMETHODIMP
  685. CFPNWFileService::get__NewEnum(THIS_ IUnknown * FAR* retval)
  686. {
  687. HRESULT hr = S_OK;
  688. CFPNWFileSharesEnumVar *pCFileSharesEnumVar = NULL;
  689. if(!retval){
  690. RRETURN_EXP_IF_ERR(E_POINTER);
  691. }
  692. *retval = NULL;
  693. hr = CFPNWFileSharesEnumVar::Create(_pszServerName,
  694. _ADsPath,
  695. &pCFileSharesEnumVar,
  696. _vFilter,
  697. _Credentials);
  698. BAIL_ON_FAILURE(hr);
  699. ADsAssert(pCFileSharesEnumVar);
  700. _pCFileSharesEnumVar = pCFileSharesEnumVar;
  701. hr = _pCFileSharesEnumVar->QueryInterface(IID_IUnknown,
  702. (void **)retval);
  703. _pCFileSharesEnumVar->Release();
  704. _pCFileSharesEnumVar = NULL;
  705. BAIL_ON_FAILURE(hr);
  706. RRETURN(hr);
  707. error:
  708. delete pCFileSharesEnumVar;
  709. _pCFileSharesEnumVar = NULL;
  710. RRETURN_EXP_IF_ERR(hr);
  711. }
  712. STDMETHODIMP
  713. CFPNWFileService::Create(
  714. THIS_ BSTR ClassName,
  715. BSTR RelativeName,
  716. IDispatch * FAR* ppObject
  717. )
  718. {
  719. DWORD dwObjectType = 0;
  720. HRESULT hr = S_OK;
  721. POBJECTINFO pObjectInfo = NULL;
  722. hr = GetObjectType(gpFilters,
  723. gdwMaxFilters,
  724. ClassName,
  725. (PDWORD)&dwObjectType);
  726. BAIL_IF_ERROR(hr);
  727. if(!(dwObjectType == WINNT_FILESHARE_ID ||
  728. dwObjectType == WINNT_FPNW_FILESHARE_ID)){
  729. //
  730. // trying to create an invalid object at this level
  731. //
  732. hr = E_FAIL;
  733. goto error;
  734. }
  735. hr = BuildObjectInfo(_ADsPath,
  736. RelativeName,
  737. &pObjectInfo);
  738. BAIL_ON_FAILURE(hr);
  739. hr = ValidateObject(dwObjectType,
  740. pObjectInfo,
  741. _Credentials);
  742. if(SUCCEEDED(hr)){
  743. hr = E_ADS_OBJECT_EXISTS;
  744. goto error;
  745. }
  746. //
  747. // The only object that has a file service as a container is
  748. // a file share object
  749. hr = CFPNWFileShare::Create(_ADsPath,
  750. pObjectInfo->ComponentArray[1],
  751. pObjectInfo->ComponentArray[2],
  752. RelativeName,
  753. ADS_OBJECT_UNBOUND,
  754. IID_IDispatch,
  755. _Credentials,
  756. (void**)ppObject);
  757. BAIL_ON_FAILURE(hr);
  758. error:
  759. cleanup:
  760. FreeObjectInfo(pObjectInfo);
  761. RRETURN_EXP_IF_ERR(hr);
  762. }
  763. STDMETHODIMP
  764. CFPNWFileService::Delete(THIS_ BSTR Type,
  765. BSTR SourceName
  766. )
  767. {
  768. HRESULT hr;
  769. DWORD dwObjectType = 0;
  770. POBJECTINFO pObjectInfo = NULL;
  771. // Check to make sure the input parameters are valid
  772. if (Type == NULL || SourceName == NULL) {
  773. RRETURN_EXP_IF_ERR(E_ADS_BAD_PARAMETER);
  774. }
  775. hr = GetObjectType(gpFilters,
  776. gdwMaxFilters,
  777. Type,
  778. (PDWORD)&dwObjectType);
  779. BAIL_IF_ERROR(hr);
  780. if(dwObjectType != WINNT_FILESHARE_ID){
  781. //
  782. // trying to delete an invalid object at this level
  783. //
  784. hr = E_FAIL;
  785. goto cleanup;
  786. }
  787. hr = BuildObjectInfo(_ADsPath,
  788. SourceName,
  789. &pObjectInfo);
  790. BAIL_IF_ERROR(hr);
  791. hr = FPNWDeleteFileShare(pObjectInfo);
  792. cleanup:
  793. FreeObjectInfo(pObjectInfo);
  794. RRETURN_EXP_IF_ERR(hr);
  795. }
  796. STDMETHODIMP
  797. CFPNWFileService::CopyHere(THIS_ BSTR SourceName,
  798. BSTR NewName,
  799. IDispatch * FAR* ppObject
  800. )
  801. {
  802. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  803. }
  804. STDMETHODIMP
  805. CFPNWFileService::MoveHere(THIS_ BSTR SourceName,
  806. BSTR NewName,
  807. IDispatch * FAR* ppObject
  808. )
  809. {
  810. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  811. }
  812. /* IADsFSFileServiceGeneralInfo methods */
  813. STDMETHODIMP
  814. CFPNWFileService::get_Description(THIS_ BSTR FAR* retval)
  815. {
  816. GET_PROPERTY_BSTR((IADsFileService *)this, Description);
  817. }
  818. STDMETHODIMP
  819. CFPNWFileService::put_Description(THIS_ BSTR bstrDescription)
  820. {
  821. PUT_PROPERTY_BSTR((IADsFileService *)this, Description);
  822. }
  823. STDMETHODIMP
  824. CFPNWFileService::get_MaxUserCount(THIS_ long FAR* retval)
  825. {
  826. //
  827. // here -1 signifies no limit
  828. //
  829. if(!retval){
  830. RRETURN_EXP_IF_ERR(E_POINTER);
  831. }
  832. *retval = -1;
  833. RRETURN(S_OK);
  834. }
  835. STDMETHODIMP CFPNWFileService::put_MaxUserCount(THIS_ long lMaxUserCount)
  836. {
  837. RRETURN_EXP_IF_ERR(E_ADS_PROPERTY_NOT_SUPPORTED);
  838. }
  839. STDMETHODIMP
  840. CFPNWFileService::Sessions(THIS_ IADsCollection ** ppSessions)
  841. {
  842. //
  843. // The session collection object is created and it is passed the server
  844. // name. It uses this to create the session object
  845. //
  846. HRESULT hr = S_OK;
  847. CFPNWSessionsCollection * pSessionsCollection = NULL;
  848. if(!ppSessions){
  849. RRETURN_EXP_IF_ERR(E_POINTER);
  850. }
  851. hr = CFPNWSessionsCollection::Create(_ADsPath,
  852. _Credentials,
  853. &pSessionsCollection);
  854. BAIL_IF_ERROR(hr);
  855. hr = pSessionsCollection->QueryInterface(IID_IADsCollection,
  856. (void **) ppSessions);
  857. BAIL_IF_ERROR(hr);
  858. pSessionsCollection->Release();
  859. cleanup:
  860. if(FAILED(hr)){
  861. delete pSessionsCollection;
  862. }
  863. RRETURN_EXP_IF_ERR(hr);
  864. }
  865. STDMETHODIMP
  866. CFPNWFileService::Resources(THIS_ IADsCollection FAR* FAR* ppResources)
  867. {
  868. //
  869. // The resource collection object is created and it is passed the server
  870. // name. It uses this to create the resource object
  871. //
  872. HRESULT hr = S_OK;
  873. CFPNWResourcesCollection * pResourcesCollection = NULL;
  874. if(!ppResources){
  875. RRETURN_EXP_IF_ERR(E_POINTER);
  876. }
  877. hr = CFPNWResourcesCollection::Create(_ADsPath,
  878. NULL,
  879. _Credentials,
  880. &pResourcesCollection);
  881. BAIL_IF_ERROR(hr);
  882. hr = pResourcesCollection->QueryInterface(IID_IADsCollection,
  883. (void **) ppResources);
  884. BAIL_IF_ERROR(hr);
  885. pResourcesCollection->Release();
  886. cleanup:
  887. if(FAILED(hr)){
  888. delete pResourcesCollection;
  889. }
  890. RRETURN_EXP_IF_ERR(hr);
  891. }
  892. STDMETHODIMP
  893. CFPNWFileService::get_HostComputer(THIS_ BSTR FAR* retval)
  894. {
  895. HRESULT hr;
  896. hr = _pService->get_HostComputer(retval);
  897. RRETURN_EXP_IF_ERR(hr);
  898. }
  899. STDMETHODIMP
  900. CFPNWFileService::put_HostComputer(THIS_ BSTR bstrHostComputer)
  901. {
  902. HRESULT hr;
  903. hr = _pService->put_HostComputer(bstrHostComputer);
  904. RRETURN_EXP_IF_ERR(hr);
  905. }
  906. STDMETHODIMP
  907. CFPNWFileService::get_DisplayName(THIS_ BSTR FAR* retval)
  908. {
  909. HRESULT hr;
  910. hr = _pService->get_DisplayName(retval);
  911. RRETURN_EXP_IF_ERR(hr);
  912. }
  913. STDMETHODIMP
  914. CFPNWFileService::put_DisplayName(THIS_ BSTR bstrDisplayName)
  915. {
  916. HRESULT hr;
  917. hr = _pService->put_DisplayName(bstrDisplayName);
  918. RRETURN_EXP_IF_ERR(hr);
  919. }
  920. STDMETHODIMP
  921. CFPNWFileService::get_Version(THIS_ BSTR FAR* retval)
  922. {
  923. HRESULT hr;
  924. hr = _pService->get_Version(retval);
  925. RRETURN_EXP_IF_ERR(hr);
  926. }
  927. STDMETHODIMP
  928. CFPNWFileService::put_Version(THIS_ BSTR bstrVersion)
  929. {
  930. HRESULT hr;
  931. hr = _pService->put_Version(bstrVersion);
  932. RRETURN_EXP_IF_ERR(hr);
  933. }
  934. STDMETHODIMP
  935. CFPNWFileService::get_ServiceType(THIS_ long FAR* retval)
  936. {
  937. HRESULT hr;
  938. hr = _pService->get_ServiceType(retval);
  939. RRETURN_EXP_IF_ERR(hr);
  940. }
  941. STDMETHODIMP
  942. CFPNWFileService::put_ServiceType(THIS_ long lServiceType)
  943. {
  944. HRESULT hr;
  945. hr = _pService->put_ServiceType(lServiceType);
  946. RRETURN_EXP_IF_ERR(hr);
  947. }
  948. STDMETHODIMP
  949. CFPNWFileService::get_StartType(THIS_ LONG FAR* retval)
  950. {
  951. HRESULT hr;
  952. hr = _pService->get_StartType(retval);
  953. RRETURN_EXP_IF_ERR(hr);
  954. }
  955. STDMETHODIMP
  956. CFPNWFileService::put_StartType(THIS_ LONG lStartType)
  957. {
  958. HRESULT hr;
  959. hr = _pService->put_StartType(lStartType);
  960. RRETURN_EXP_IF_ERR(hr);
  961. }
  962. STDMETHODIMP
  963. CFPNWFileService::get_Path(THIS_ BSTR FAR* retval)
  964. {
  965. HRESULT hr;
  966. hr = _pService->get_Path(retval);
  967. RRETURN_EXP_IF_ERR(hr);
  968. }
  969. STDMETHODIMP
  970. CFPNWFileService::put_Path(THIS_ BSTR bstrPath)
  971. {
  972. HRESULT hr;
  973. hr = _pService->put_Path(bstrPath);
  974. RRETURN_EXP_IF_ERR(hr);
  975. }
  976. STDMETHODIMP
  977. CFPNWFileService::get_StartupParameters(THIS_ BSTR FAR* retval)
  978. {
  979. HRESULT hr;
  980. hr = _pService->get_StartupParameters(retval);
  981. RRETURN_EXP_IF_ERR(hr);
  982. }
  983. STDMETHODIMP
  984. CFPNWFileService::put_StartupParameters(THIS_ BSTR bstrStartupParameters)
  985. {
  986. HRESULT hr;
  987. hr = _pService->put_StartupParameters(bstrStartupParameters);
  988. RRETURN_EXP_IF_ERR(hr);
  989. }
  990. STDMETHODIMP
  991. CFPNWFileService::get_ErrorControl(THIS_ LONG FAR* retval)
  992. {
  993. HRESULT hr;
  994. hr = _pService->get_ErrorControl(retval);
  995. RRETURN_EXP_IF_ERR(hr);
  996. }
  997. STDMETHODIMP
  998. CFPNWFileService::put_ErrorControl(THIS_ LONG lErrorControl)
  999. {
  1000. HRESULT hr;
  1001. hr = _pService->put_ErrorControl(lErrorControl);
  1002. RRETURN_EXP_IF_ERR(hr);
  1003. }
  1004. STDMETHODIMP
  1005. CFPNWFileService::get_LoadOrderGroup(THIS_ BSTR FAR* retval)
  1006. {
  1007. HRESULT hr;
  1008. hr = _pService->get_LoadOrderGroup(retval);
  1009. RRETURN_EXP_IF_ERR(hr);
  1010. }
  1011. STDMETHODIMP
  1012. CFPNWFileService::put_LoadOrderGroup(THIS_ BSTR bstrLoadOrderGroup)
  1013. {
  1014. HRESULT hr;
  1015. hr = _pService->put_LoadOrderGroup(bstrLoadOrderGroup);
  1016. RRETURN_EXP_IF_ERR(hr);
  1017. }
  1018. STDMETHODIMP
  1019. CFPNWFileService::get_ServiceAccountName(THIS_ BSTR FAR* retval)
  1020. {
  1021. HRESULT hr;
  1022. hr = _pService->get_ServiceAccountName(retval);
  1023. RRETURN_EXP_IF_ERR(hr);
  1024. }
  1025. STDMETHODIMP
  1026. CFPNWFileService::put_ServiceAccountName(THIS_ BSTR bstrServiceAccountName)
  1027. {
  1028. HRESULT hr;
  1029. hr = _pService->put_ServiceAccountName(bstrServiceAccountName);
  1030. RRETURN_EXP_IF_ERR(hr);
  1031. }
  1032. STDMETHODIMP
  1033. CFPNWFileService::get_ServiceAccountPath(THIS_ BSTR FAR* retval)
  1034. {
  1035. HRESULT hr;
  1036. hr = _pService->get_ServiceAccountPath(retval);
  1037. RRETURN_EXP_IF_ERR(hr);
  1038. }
  1039. STDMETHODIMP
  1040. CFPNWFileService::put_ServiceAccountPath(THIS_ BSTR bstrServiceAccountName)
  1041. {
  1042. HRESULT hr;
  1043. hr = _pService->put_ServiceAccountPath(bstrServiceAccountName);
  1044. RRETURN_EXP_IF_ERR(hr);
  1045. }
  1046. STDMETHODIMP
  1047. CFPNWFileService::get_Dependencies(THIS_ VARIANT FAR* retval)
  1048. {
  1049. HRESULT hr;
  1050. hr = _pService->get_Dependencies(retval);
  1051. RRETURN_EXP_IF_ERR(hr);
  1052. }
  1053. STDMETHODIMP
  1054. CFPNWFileService::put_Dependencies(THIS_ VARIANT vDependencies)
  1055. {
  1056. HRESULT hr;
  1057. hr = _pService->put_Dependencies(vDependencies);
  1058. RRETURN_EXP_IF_ERR(hr);
  1059. }
  1060. STDMETHODIMP
  1061. CFPNWFileService::SetPassword(THIS_ BSTR bstrNewPassword)
  1062. {
  1063. HRESULT hr;
  1064. hr = _pServiceOps->SetPassword(bstrNewPassword);
  1065. RRETURN_EXP_IF_ERR(hr);
  1066. }
  1067. //+---------------------------------------------------------------------------
  1068. //
  1069. // Function: CFPNWFileService::Start
  1070. //
  1071. // Synopsis: Attempts to start the service specified in _bstrServiceName on
  1072. // the server named in _bstrPath.
  1073. //
  1074. // Arguments:
  1075. //
  1076. // Returns: HRESULT.
  1077. //
  1078. // Modifies:
  1079. //
  1080. // History: 01/04/96 RamV Created
  1081. //
  1082. // Notes:
  1083. //----------------------------------------------------------------------------
  1084. STDMETHODIMP
  1085. CFPNWFileService::Start(THIS)
  1086. {
  1087. HRESULT hr;
  1088. hr = _pServiceOps->Start();
  1089. RRETURN_EXP_IF_ERR(hr);
  1090. }
  1091. //+---------------------------------------------------------------------------
  1092. //
  1093. // Function: CFPNWFileService::Stop
  1094. //
  1095. // Synopsis: Attempts to stop the service specified in _bstrServiceName on
  1096. // the server named in _bstrPath.
  1097. //
  1098. // Arguments:
  1099. //
  1100. // Returns: HRESULT.
  1101. //
  1102. // Modifies:
  1103. //
  1104. // History: 01/04/96 RamV Created
  1105. //
  1106. //----------------------------------------------------------------------------
  1107. STDMETHODIMP
  1108. CFPNWFileService::Stop(THIS)
  1109. {
  1110. HRESULT hr;
  1111. hr = _pServiceOps->Stop();
  1112. RRETURN_EXP_IF_ERR(hr);
  1113. }
  1114. //+---------------------------------------------------------------------------
  1115. //
  1116. // Function: CFPNWFileService::Pause
  1117. //
  1118. // Synopsis: Attempts to pause the service named _bstrServiceName on the
  1119. // server named in _bstrPath.
  1120. //
  1121. // Arguments:
  1122. //
  1123. // Returns: HRESULT.
  1124. //
  1125. // Modifies:
  1126. //
  1127. // History: 01-04-96 RamV Created
  1128. //
  1129. //----------------------------------------------------------------------------
  1130. STDMETHODIMP
  1131. CFPNWFileService::Pause(THIS)
  1132. {
  1133. HRESULT hr;
  1134. hr = _pServiceOps->Pause();
  1135. RRETURN_EXP_IF_ERR(hr);
  1136. }
  1137. //+---------------------------------------------------------------------------
  1138. //
  1139. // Function: CFPNWFileService::Continue
  1140. //
  1141. // Synopsis: Attempts to "unpause" the service specified in _bstrServiceName
  1142. // on the server named in _bstrPath.
  1143. //
  1144. // Arguments:
  1145. //
  1146. // Returns: HRESULT.
  1147. //
  1148. // Modifies:
  1149. //
  1150. // History: 01/04/96 RamV Created
  1151. //
  1152. //----------------------------------------------------------------------------
  1153. STDMETHODIMP
  1154. CFPNWFileService::Continue(THIS)
  1155. {
  1156. HRESULT hr;
  1157. hr = _pServiceOps->Continue();
  1158. RRETURN_EXP_IF_ERR(hr);
  1159. }
  1160. STDMETHODIMP
  1161. CFPNWFileService::get_Status(THIS_ long FAR* plStatusCode)
  1162. {
  1163. HRESULT hr;
  1164. hr = _pServiceOps->get_Status(plStatusCode);
  1165. RRETURN_EXP_IF_ERR(hr);
  1166. }
  1167. STDMETHODIMP
  1168. CFPNWFileService::GetEx(
  1169. THIS_ BSTR bstrName,
  1170. VARIANT FAR* pvProp
  1171. )
  1172. {
  1173. HRESULT hr = S_OK;
  1174. hr = GenericGetExPropertyManager(
  1175. ADS_OBJECT_BOUND,
  1176. _pPropertyCache,
  1177. bstrName,
  1178. pvProp
  1179. );
  1180. if(FAILED(hr)){
  1181. hr= _pService->GetEx(bstrName, pvProp );
  1182. }
  1183. RRETURN_EXP_IF_ERR(hr);
  1184. }
  1185. STDMETHODIMP
  1186. CFPNWFileService::PutEx(
  1187. THIS_ long lnControlCode,
  1188. BSTR bstrName,
  1189. VARIANT vProp
  1190. )
  1191. {
  1192. HRESULT hr = S_OK;
  1193. hr = GenericPutExPropertyManager(
  1194. _pPropertyCache,
  1195. FPNWFileServiceClass,
  1196. gdwFPNWFileServiceTableSize,
  1197. bstrName,
  1198. vProp
  1199. );
  1200. if(FAILED(hr)){
  1201. hr= _pService->PutEx(lnControlCode, bstrName, vProp );
  1202. }
  1203. RRETURN_EXP_IF_ERR(hr);
  1204. }