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.

817 lines
20 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996
  5. //
  6. // File: cfpnwfsh.cxx
  7. //
  8. // Contents: Contains methods for the following objects
  9. // CFPNWFileShare, CFPNWFileShareGeneralInfo
  10. //
  11. //
  12. // History: 02/15/96 ramv (Ram Viswanathan) Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "winnt.hxx"
  16. #pragma hdrstop
  17. #define INITGUID
  18. #if DBG
  19. DECLARE_INFOLEVEL(FPNWFileShare );
  20. DECLARE_DEBUG( FPNWFileShare);
  21. #define FPNWFileShareDebugOut(x) FPNWFileShareInlineDebugOut x
  22. #endif
  23. DEFINE_IDispatch_ExtMgr_Implementation(CFPNWFileShare);
  24. DEFINE_IADsExtension_ExtMgr_Implementation(CFPNWFileShare);
  25. DEFINE_IADs_TempImplementation(CFPNWFileShare);
  26. DEFINE_IADs_PutGetImplementation(CFPNWFileShare,FPNWFileShareClass,gdwFPNWFileShareTableSize);
  27. DEFINE_IADsPropertyList_Implementation(CFPNWFileShare, FPNWFileShareClass,gdwFPNWFileShareTableSize);
  28. CFPNWFileShare::CFPNWFileShare()
  29. {
  30. _pDispMgr = NULL;
  31. _pExtMgr = NULL;
  32. ENLIST_TRACKING(CFPNWFileShare);
  33. _pszShareName = NULL;
  34. _pPropertyCache = NULL;
  35. return;
  36. }
  37. CFPNWFileShare::~CFPNWFileShare()
  38. {
  39. delete _pExtMgr; // created last, destroyed first
  40. delete _pDispMgr;
  41. if(_pszShareName){
  42. FreeADsStr(_pszShareName);
  43. }
  44. if(_pszServerName){
  45. FreeADsStr(_pszServerName);
  46. }
  47. delete _pPropertyCache;
  48. return;
  49. }
  50. //+---------------------------------------------------------------------------
  51. //
  52. // Function: CFPNWFileShare::Create
  53. //
  54. // Synopsis: Static function used to create a FileShare object. This
  55. // will be called by EnumFileShares::Next
  56. //
  57. // Arguments: [ppFPNWFileShare] -- Ptr to a ptr to a new FileShare object.
  58. //
  59. // Returns: HRESULT.
  60. //
  61. // Modifies:
  62. //
  63. // History: 12-11-95 RamV Created.
  64. //
  65. //----------------------------------------------------------------------------
  66. HRESULT
  67. CFPNWFileShare::Create(LPTSTR pszADsParent,
  68. LPTSTR pszServerName,
  69. LPTSTR pszServiceName,
  70. LPTSTR pszShareName,
  71. DWORD dwObject,
  72. REFIID riid,
  73. CWinNTCredentials& Credentials,
  74. LPVOID * ppvoid
  75. )
  76. {
  77. CFPNWFileShare FAR * pCFPNWFileShare = NULL;
  78. HRESULT hr;
  79. //
  80. // Create the FileShare Object
  81. //
  82. hr = AllocateFileShareObject(pszADsParent,
  83. pszServerName,
  84. pszServiceName,
  85. pszShareName,
  86. &pCFPNWFileShare );
  87. BAIL_ON_FAILURE(hr);
  88. ADsAssert(pCFPNWFileShare->_pDispMgr);
  89. hr = pCFPNWFileShare->InitializeCoreObject(pszADsParent,
  90. pszShareName,
  91. FILESHARE_CLASS_NAME,
  92. FPNW_FILESHARE_SCHEMA_NAME,
  93. CLSID_FPNWFileShare,
  94. dwObject);
  95. BAIL_ON_FAILURE(hr);
  96. pCFPNWFileShare->_Credentials = Credentials;
  97. hr = pCFPNWFileShare->_Credentials.RefServer(pszServerName);
  98. BAIL_ON_FAILURE(hr);
  99. //
  100. // Load ext mgr and extensions
  101. //
  102. hr = ADSILoadExtensionManager(
  103. FILESHARE_CLASS_NAME,
  104. (IADs *) pCFPNWFileShare,
  105. pCFPNWFileShare->_pDispMgr,
  106. Credentials,
  107. &pCFPNWFileShare->_pExtMgr
  108. );
  109. BAIL_ON_FAILURE(hr);
  110. ADsAssert(pCFPNWFileShare->_pExtMgr);
  111. // check if the call is from UMI
  112. if(Credentials.GetFlags() & ADS_AUTH_RESERVED) {
  113. //
  114. // we do not pass riid to InitUmiObject below. This is because UMI object
  115. // does not support IDispatch. There are several places in ADSI code where
  116. // riid passed into this function is defaulted to IID_IDispatch -
  117. // IADsContainer::Create for example. To handle these cases, we always
  118. // request IID_IUnknown from the UMI object. Subsequent code within UMI
  119. // will QI for the appropriate interface.
  120. //
  121. if(4 == pCFPNWFileShare->_dwNumComponents) {
  122. pCFPNWFileShare->_CompClasses[0] = L"Domain";
  123. pCFPNWFileShare->_CompClasses[1] = L"Computer";
  124. pCFPNWFileShare->_CompClasses[2] = L"FileService";
  125. pCFPNWFileShare->_CompClasses[3] = L"FileShare";
  126. }
  127. else if(3 == pCFPNWFileShare->_dwNumComponents) {
  128. pCFPNWFileShare->_CompClasses[0] = L"Computer";
  129. pCFPNWFileShare->_CompClasses[1] = L"FileService";
  130. pCFPNWFileShare->_CompClasses[2] = L"FileShare";
  131. }
  132. else
  133. BAIL_ON_FAILURE(hr = UMI_E_FAIL);
  134. hr = pCFPNWFileShare->InitUmiObject(
  135. pCFPNWFileShare->_Credentials,
  136. FPNWFileShareClass,
  137. gdwFPNWFileShareTableSize,
  138. pCFPNWFileShare->_pPropertyCache,
  139. (IUnknown *) (INonDelegatingUnknown *) pCFPNWFileShare,
  140. pCFPNWFileShare->_pExtMgr,
  141. IID_IUnknown,
  142. ppvoid
  143. );
  144. BAIL_ON_FAILURE(hr);
  145. //
  146. // UMI object was created and the interface was obtained successfully.
  147. // UMI object now has a reference to the inner unknown of IADs, since
  148. // the call to Release() below is not going to be made in this case.
  149. //
  150. RRETURN(hr);
  151. }
  152. hr = pCFPNWFileShare->QueryInterface(riid, (void **)ppvoid);
  153. BAIL_ON_FAILURE(hr);
  154. pCFPNWFileShare->Release();
  155. RRETURN(hr);
  156. error:
  157. delete pCFPNWFileShare;
  158. RRETURN_EXP_IF_ERR (hr);
  159. }
  160. HRESULT
  161. CFPNWFileShare::AllocateFileShareObject(LPTSTR pszADsParent,
  162. LPTSTR pszServerName,
  163. LPTSTR pszServiceName,
  164. LPTSTR pszShareName,
  165. CFPNWFileShare ** ppFileShare
  166. )
  167. {
  168. CFPNWFileShare * pCFPNWFileShare = NULL;
  169. HRESULT hr;
  170. //
  171. // Create the FileShare Object
  172. //
  173. pCFPNWFileShare = new CFPNWFileShare();
  174. if (pCFPNWFileShare == NULL) {
  175. hr = E_OUTOFMEMORY;
  176. goto error;
  177. }
  178. pCFPNWFileShare->_pDispMgr = new CAggregatorDispMgr;
  179. if(pCFPNWFileShare ->_pDispMgr == NULL){
  180. hr = E_OUTOFMEMORY;
  181. goto error;
  182. }
  183. hr = LoadTypeInfoEntry(pCFPNWFileShare->_pDispMgr,
  184. LIBID_ADs,
  185. IID_IADsFileShare,
  186. (IADsFileShare *)pCFPNWFileShare,
  187. DISPID_REGULAR );
  188. BAIL_ON_FAILURE(hr);
  189. hr = LoadTypeInfoEntry(pCFPNWFileShare->_pDispMgr,
  190. LIBID_ADs,
  191. IID_IADsPropertyList,
  192. (IADsPropertyList *)pCFPNWFileShare,
  193. DISPID_VALUE );
  194. BAIL_ON_FAILURE(hr);
  195. pCFPNWFileShare->_pszServerName =
  196. AllocADsStr(pszServerName);
  197. if(!(pCFPNWFileShare->_pszServerName)){
  198. hr = E_OUTOFMEMORY;
  199. goto error;
  200. }
  201. pCFPNWFileShare->_pszShareName =
  202. AllocADsStr(pszShareName);
  203. if(!(pCFPNWFileShare->_pszShareName)){
  204. hr = E_OUTOFMEMORY;
  205. goto error;
  206. }
  207. hr = CPropertyCache::createpropertycache(
  208. FPNWFileShareClass,
  209. gdwFPNWFileShareTableSize,
  210. (CCoreADsObject *)pCFPNWFileShare,
  211. &(pCFPNWFileShare ->_pPropertyCache)
  212. );
  213. pCFPNWFileShare->_pDispMgr->RegisterPropertyCache(
  214. pCFPNWFileShare->_pPropertyCache
  215. );
  216. *ppFileShare = pCFPNWFileShare;
  217. RRETURN(hr);
  218. error:
  219. //
  220. // direct memeber assignement assignement at pt of creation, so
  221. // do NOT delete _pPropertyCache or _pDisMgr here to avoid attempt
  222. // of deletion again in pPrintJob destructor and AV
  223. //
  224. delete pCFPNWFileShare;
  225. RRETURN_EXP_IF_ERR(hr);
  226. }
  227. /* IUnknown methods for FileShare object */
  228. //----------------------------------------------------------------------------
  229. // Function: QueryInterface
  230. //
  231. // Synopsis: If this object is aggregated within another object, then
  232. // all calls will delegate to the outer object. Otherwise, the
  233. // non-delegating QI is called
  234. //
  235. // Arguments:
  236. //
  237. // iid interface requested
  238. // ppInterface Returns pointer to interface requested. NULL if interface
  239. // is not supported.
  240. //
  241. // Returns: S_OK on success. Error code otherwise.
  242. //
  243. // Modifies: *ppInterface to return interface pointer
  244. //
  245. //----------------------------------------------------------------------------
  246. STDMETHODIMP CFPNWFileShare::QueryInterface(
  247. REFIID iid,
  248. LPVOID *ppInterface
  249. )
  250. {
  251. if(_pUnkOuter != NULL)
  252. RRETURN(_pUnkOuter->QueryInterface(
  253. iid,
  254. ppInterface
  255. ));
  256. RRETURN(NonDelegatingQueryInterface(
  257. iid,
  258. ppInterface
  259. ));
  260. }
  261. //----------------------------------------------------------------------------
  262. // Function: AddRef
  263. //
  264. // Synopsis: IUnknown::AddRef. If this object is aggregated within
  265. // another, all calls will delegate to the outer object.
  266. // Otherwise, the non-delegating AddRef is called
  267. //
  268. // Arguments:
  269. //
  270. // None
  271. //
  272. // Returns: New reference count
  273. //
  274. // Modifies: Nothing
  275. //
  276. //----------------------------------------------------------------------------
  277. STDMETHODIMP_(ULONG) CFPNWFileShare::AddRef(void)
  278. {
  279. if(_pUnkOuter != NULL)
  280. RRETURN(_pUnkOuter->AddRef());
  281. RRETURN(NonDelegatingAddRef());
  282. }
  283. //----------------------------------------------------------------------------
  284. // Function: Release
  285. //
  286. // Synopsis: IUnknown::Release. If this object is aggregated within
  287. // another, all calls will delegate to the outer object.
  288. // Otherwise, the non-delegating Release is called
  289. //
  290. // Arguments:
  291. //
  292. // None
  293. //
  294. // Returns: New reference count
  295. //
  296. // Modifies: Nothing
  297. //
  298. //----------------------------------------------------------------------------
  299. STDMETHODIMP_(ULONG) CFPNWFileShare::Release(void)
  300. {
  301. if(_pUnkOuter != NULL)
  302. RRETURN(_pUnkOuter->Release());
  303. RRETURN(NonDelegatingRelease());
  304. }
  305. //----------------------------------------------------------------------------
  306. STDMETHODIMP
  307. CFPNWFileShare::NonDelegatingQueryInterface(REFIID riid, LPVOID FAR* ppvObj)
  308. {
  309. HRESULT hr = S_OK;
  310. if(!ppvObj){
  311. RRETURN(E_POINTER);
  312. }
  313. if (IsEqualIID(riid, IID_IUnknown))
  314. {
  315. *ppvObj = (IADs *) this;
  316. }
  317. else if (IsEqualIID(riid, IID_IDispatch))
  318. {
  319. *ppvObj = (IADs *)this;
  320. }
  321. else if (IsEqualIID(riid, IID_ISupportErrorInfo))
  322. {
  323. *ppvObj = (ISupportErrorInfo FAR *) this;
  324. }
  325. else if (IsEqualIID(riid, IID_IADsPropertyList))
  326. {
  327. *ppvObj = (IADsPropertyList *)this;
  328. }
  329. else if (IsEqualIID(riid, IID_IADs))
  330. {
  331. *ppvObj = (IADs FAR *) this;
  332. }
  333. else if (IsEqualIID(riid, IID_IADsFileShare))
  334. {
  335. *ppvObj = (IADsFileShare FAR *) this;
  336. }
  337. else if( (_pDispatch != NULL) &&
  338. IsEqualIID(riid, IID_IADsExtension) )
  339. {
  340. *ppvObj = (IADsExtension *) this;
  341. }
  342. else if (_pExtMgr)
  343. {
  344. RRETURN( _pExtMgr->QueryInterface(riid, ppvObj));
  345. }
  346. else
  347. {
  348. *ppvObj = NULL;
  349. RRETURN(E_NOINTERFACE);
  350. }
  351. ((LPUNKNOWN)*ppvObj)->AddRef();
  352. RRETURN(S_OK);
  353. }
  354. /* ISupportErrorInfo method */
  355. STDMETHODIMP
  356. CFPNWFileShare::InterfaceSupportsErrorInfo(
  357. THIS_ REFIID riid
  358. )
  359. {
  360. if (IsEqualIID(riid, IID_IADs) ||
  361. IsEqualIID(riid, IID_IADsFileShare) ||
  362. IsEqualIID(riid, IID_IADsPropertyList)) {
  363. RRETURN(S_OK);
  364. } else {
  365. RRETURN(S_FALSE);
  366. }
  367. }
  368. //+-----------------------------------------------------------------
  369. //
  370. // Function: SetInfo
  371. //
  372. // Synopsis: SetInfo on actual Volume
  373. //
  374. // Arguments: void
  375. //
  376. // Returns: HRESULT.
  377. //
  378. // Modifies:
  379. //
  380. // History: 02/08/96 RamV Created
  381. //----------------------------------------------------------------------------
  382. STDMETHODIMP
  383. CFPNWFileShare::SetInfo(THIS)
  384. {
  385. PNWVOLUMEINFO pVolumeInfo = NULL;
  386. HRESULT hr = S_OK;
  387. DWORD dwErrorCode;
  388. if (GetObjectState() == ADS_OBJECT_UNBOUND) {
  389. hr = FPNWAddFileShare();
  390. BAIL_IF_ERROR(hr);
  391. SetObjectState(ADS_OBJECT_BOUND);
  392. }
  393. //
  394. // First get the information and modify only those fields which
  395. // have been changed by user
  396. //
  397. dwErrorCode = ADsNwVolumeGetInfo(_pszServerName,
  398. _pszShareName,
  399. 1,
  400. &pVolumeInfo);
  401. hr = HRESULT_FROM_WIN32(dwErrorCode);
  402. BAIL_IF_ERROR(hr);
  403. hr = MarshallAndSet(pVolumeInfo);
  404. BAIL_IF_ERROR(hr);
  405. if(SUCCEEDED(hr))
  406. _pPropertyCache->ClearModifiedFlags();
  407. cleanup:
  408. if(pVolumeInfo){
  409. ADsNwApiBufferFree(pVolumeInfo);
  410. }
  411. RRETURN_EXP_IF_ERR(hr);
  412. }
  413. STDMETHODIMP
  414. CFPNWFileShare::GetInfo(THIS_ DWORD dwApiLevel, BOOL fExplicit)
  415. {
  416. HRESULT hr = S_OK;
  417. DWORD dwErrorCode;
  418. PNWVOLUMEINFO pVolumeInfo = NULL;
  419. TCHAR szComputerPath[MAX_PATH];
  420. POBJECTINFO pObjectInfo = NULL;
  421. //
  422. // only level 1 is valid. This function is not exported so we
  423. // assert if not valid
  424. //
  425. ADsAssert(dwApiLevel == 1);
  426. dwErrorCode = ADsNwVolumeGetInfo(_pszServerName,
  427. _pszShareName,
  428. 1,
  429. &pVolumeInfo);
  430. hr = HRESULT_FROM_WIN32(dwErrorCode);
  431. BAIL_IF_ERROR(hr);
  432. //
  433. // unmarshall the information
  434. //
  435. hr = BuildObjectInfo(_Parent, &pObjectInfo);
  436. BAIL_IF_ERROR(hr);
  437. hr = BuildComputerFromObjectInfo(pObjectInfo,
  438. szComputerPath);
  439. BAIL_IF_ERROR(hr);
  440. hr = SetLPTSTRPropertyInCache(_pPropertyCache,
  441. TEXT("HostComputer"),
  442. szComputerPath,
  443. fExplicit
  444. );
  445. hr = SetLPTSTRPropertyInCache(_pPropertyCache,
  446. TEXT("Path"),
  447. pVolumeInfo->lpPath,
  448. fExplicit
  449. );
  450. hr = SetDWORDPropertyInCache(_pPropertyCache,
  451. TEXT("CurrentUserCount"),
  452. pVolumeInfo->dwCurrentUses,
  453. fExplicit
  454. );
  455. hr = SetDWORDPropertyInCache(_pPropertyCache,
  456. TEXT("MaxUserCount"),
  457. pVolumeInfo->dwMaxUses,
  458. fExplicit
  459. );
  460. hr = SetLPTSTRPropertyInCache(
  461. _pPropertyCache,
  462. TEXT("Name"),
  463. _Name,
  464. fExplicit
  465. );
  466. hr = S_OK;
  467. cleanup:
  468. if(pVolumeInfo){
  469. ADsNwApiBufferFree(pVolumeInfo);
  470. }
  471. FreeObjectInfo(pObjectInfo);
  472. RRETURN_EXP_IF_ERR(hr);
  473. }
  474. STDMETHODIMP
  475. CFPNWFileShare::GetInfo(THIS)
  476. {
  477. _pPropertyCache->flushpropcache();
  478. RRETURN(GetInfo(1,TRUE));
  479. }
  480. STDMETHODIMP
  481. CFPNWFileShare::ImplicitGetInfo(THIS)
  482. {
  483. RRETURN(GetInfo(1,FALSE));
  484. }
  485. HRESULT
  486. CFPNWFileShare::FPNWAddFileShare(void)
  487. {
  488. DWORD dwErrorCode;
  489. NWVOLUMEINFO VolumeInfo;
  490. DWORD dwMaxUserCount;
  491. LPTSTR pszPath = NULL;
  492. HRESULT hr;
  493. //
  494. // Fill the VolumeInfo structure
  495. //
  496. //
  497. // set the file share count to be a default value (no limit)
  498. //
  499. VolumeInfo.dwMaxUses = (DWORD)-1;
  500. VolumeInfo.lpVolumeName = _pszShareName;
  501. VolumeInfo.dwType = FPNWVOL_TYPE_DISKTREE;
  502. hr = GetLPTSTRPropertyFromCache(_pPropertyCache,
  503. TEXT("Path"),
  504. &pszPath);
  505. if(SUCCEEDED(hr)){
  506. VolumeInfo.lpPath = pszPath;
  507. }
  508. hr = GetDWORDPropertyFromCache(_pPropertyCache,
  509. TEXT("MaxUserCount"),
  510. &dwMaxUserCount);
  511. if(SUCCEEDED(hr)){
  512. VolumeInfo.dwMaxUses = dwMaxUserCount;
  513. }
  514. VolumeInfo.dwCurrentUses = 0;
  515. dwErrorCode = ADsNwVolumeAdd(_pszServerName,
  516. 1,
  517. &VolumeInfo);
  518. RRETURN_EXP_IF_ERR(HRESULT_FROM_WIN32(dwErrorCode));
  519. }
  520. STDMETHODIMP
  521. CFPNWFileShare::get_CurrentUserCount(THIS_ LONG FAR* retval)
  522. {
  523. GET_PROPERTY_LONG((IADsFileShare *)this, CurrentUserCount);
  524. }
  525. STDMETHODIMP
  526. CFPNWFileShare::get_Description(THIS_ BSTR FAR* retval)
  527. {
  528. RRETURN_EXP_IF_ERR(E_ADS_PROPERTY_NOT_SUPPORTED);
  529. }
  530. STDMETHODIMP
  531. CFPNWFileShare::put_Description(THIS_ BSTR bstrDescription)
  532. {
  533. RRETURN_EXP_IF_ERR(E_ADS_PROPERTY_NOT_SUPPORTED);
  534. }
  535. STDMETHODIMP
  536. CFPNWFileShare::get_HostComputer(THIS_ BSTR FAR* retval)
  537. {
  538. HRESULT hr;
  539. POBJECTINFO pObjectInfo = NULL;
  540. TCHAR szComputerName[MAX_PATH];
  541. hr = BuildObjectInfo(_Parent, &pObjectInfo);
  542. BAIL_ON_FAILURE(hr);
  543. hr = BuildComputerFromObjectInfo(pObjectInfo,
  544. szComputerName);
  545. BAIL_ON_FAILURE(hr);
  546. hr = ADsAllocString(szComputerName, retval);
  547. error:
  548. FreeObjectInfo(pObjectInfo);
  549. RRETURN_EXP_IF_ERR(hr);
  550. }
  551. STDMETHODIMP
  552. CFPNWFileShare::put_HostComputer(THIS_ BSTR bstrHostComputer)
  553. {
  554. RRETURN_EXP_IF_ERR(E_ADS_PROPERTY_NOT_SUPPORTED);
  555. }
  556. STDMETHODIMP
  557. CFPNWFileShare::get_Path(THIS_ BSTR FAR* retval)
  558. {
  559. GET_PROPERTY_BSTR((IADsFileShare *)this, Path);
  560. }
  561. STDMETHODIMP
  562. CFPNWFileShare::put_Path(THIS_ BSTR bstrPath)
  563. {
  564. //
  565. // note that path can be set only prior to creation
  566. // of the object. It cannot be changed later.
  567. //
  568. if(GetObjectState() == ADS_OBJECT_UNBOUND){
  569. PUT_PROPERTY_BSTR((IADsFileShare *)this, Path);
  570. } else {
  571. RRETURN_EXP_IF_ERR(E_ADS_PROPERTY_NOT_SUPPORTED);
  572. }
  573. }
  574. STDMETHODIMP
  575. CFPNWFileShare::get_MaxUserCount(THIS_ LONG FAR* retval)
  576. {
  577. GET_PROPERTY_LONG((IADsFileShare *)this, MaxUserCount);
  578. }
  579. STDMETHODIMP
  580. CFPNWFileShare::put_MaxUserCount(THIS_ LONG lMaxUserCount)
  581. {
  582. PUT_PROPERTY_LONG((IADsFileShare *)this, MaxUserCount);
  583. }
  584. //
  585. // Helper functions
  586. //
  587. HRESULT
  588. CFPNWFileShare::MarshallAndSet(PNWVOLUMEINFO pVolumeInfo)
  589. {
  590. HRESULT hr = S_OK;
  591. LPTSTR pszPath = NULL;
  592. DWORD dwValue;
  593. DWORD dwErrorCode;
  594. DWORD dwParmErr;
  595. pVolumeInfo->lpVolumeName = _pszShareName;
  596. hr = GetLPTSTRPropertyFromCache(
  597. _pPropertyCache,
  598. TEXT("Path"),
  599. &pszPath
  600. );
  601. if(SUCCEEDED(hr)){
  602. pVolumeInfo->lpPath = pszPath;
  603. }
  604. hr = GetDWORDPropertyFromCache(_pPropertyCache,
  605. TEXT("MaxUserCount"),
  606. &dwValue );
  607. if(SUCCEEDED(hr)){
  608. pVolumeInfo->dwMaxUses = dwValue;
  609. }
  610. //
  611. // you ignore earlier errors, why? because these errors were raised
  612. // due to internal cached values being invalid.
  613. //
  614. hr = S_OK;
  615. //
  616. // Do the SetInfo now that you have all info
  617. //
  618. dwErrorCode = ADsNwVolumeSetInfo(_pszServerName,
  619. _pszShareName,
  620. 1,
  621. pVolumeInfo);
  622. hr = HRESULT_FROM_WIN32(dwErrorCode);
  623. BAIL_IF_ERROR(hr);
  624. cleanup:
  625. if(pszPath)
  626. FreeADsStr(pszPath);
  627. RRETURN_EXP_IF_ERR(hr);
  628. }
  629. //
  630. // helper functions
  631. //
  632. HRESULT
  633. FPNWDeleteFileShare(POBJECTINFO pObjectInfo)
  634. {
  635. HRESULT hr = S_OK;
  636. NET_API_STATUS nasStatus;
  637. DWORD dwErrorCode;
  638. dwErrorCode = ADsNwVolumeDel(pObjectInfo->ComponentArray[1],
  639. pObjectInfo->ComponentArray[3]);
  640. RRETURN(HRESULT_FROM_WIN32(dwErrorCode));
  641. }