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.

1021 lines
22 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997
  5. //
  6. // File: capp.cxx
  7. //
  8. // Contents: Contains methods for CIISApp object
  9. //
  10. // History: 20-1-98 SophiaC Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "iisext.hxx"
  14. #pragma hdrstop
  15. #define INITGUID
  16. // Class CIISApp
  17. DEFINE_IPrivateDispatch_Implementation(CIISApp)
  18. DEFINE_DELEGATING_IDispatch_Implementation(CIISApp)
  19. DEFINE_CONTAINED_IADs_Implementation(CIISApp)
  20. DEFINE_IADsExtension_Implementation(CIISApp)
  21. CIISApp::CIISApp():
  22. _pUnkOuter(NULL),
  23. _pADs(NULL),
  24. _pszServerName(NULL),
  25. _pszMetaBasePath(NULL),
  26. _pAdminBase(NULL),
  27. _pWamAdmin(NULL),
  28. _pWamAdmin2(NULL),
  29. _pAppAdmin(NULL),
  30. _pDispMgr(NULL),
  31. _fDispInitialized(FALSE)
  32. {
  33. ENLIST_TRACKING(CIISApp);
  34. }
  35. HRESULT
  36. CIISApp::CreateApp(
  37. IUnknown *pUnkOuter,
  38. REFIID riid,
  39. void **ppvObj
  40. )
  41. {
  42. CCredentials Credentials;
  43. CIISApp FAR * pApp = NULL;
  44. HRESULT hr = S_OK;
  45. BSTR bstrAdsPath = NULL;
  46. OBJECTINFO ObjectInfo;
  47. POBJECTINFO pObjectInfo = &ObjectInfo;
  48. CLexer * pLexer = NULL;
  49. LPWSTR pszIISPathName = NULL;
  50. memset(pObjectInfo, 0, sizeof(OBJECTINFO));
  51. hr = AllocateAppObject(pUnkOuter, Credentials, &pApp);
  52. BAIL_ON_FAILURE(hr);
  53. //
  54. // get ServerName and pszPath
  55. //
  56. hr = pApp->_pADs->get_ADsPath(&bstrAdsPath);
  57. BAIL_ON_FAILURE(hr);
  58. pLexer = new CLexer();
  59. hr = pLexer->Initialize(bstrAdsPath);
  60. BAIL_ON_FAILURE(hr);
  61. //
  62. // Parse the pathname
  63. //
  64. hr = ADsObject(pLexer, pObjectInfo);
  65. BAIL_ON_FAILURE(hr);
  66. pszIISPathName = AllocADsStr(bstrAdsPath);
  67. if (!pszIISPathName) {
  68. hr = E_OUTOFMEMORY;
  69. BAIL_ON_FAILURE(hr);
  70. }
  71. *pszIISPathName = L'\0';
  72. hr = BuildIISPathFromADsPath(
  73. pObjectInfo,
  74. pszIISPathName
  75. );
  76. BAIL_ON_FAILURE(hr);
  77. hr = pApp->InitializeAppObject(
  78. pObjectInfo->TreeName,
  79. pszIISPathName );
  80. BAIL_ON_FAILURE(hr);
  81. //
  82. // pass non-delegating IUnknown back to the aggregator
  83. //
  84. *ppvObj = (INonDelegatingUnknown FAR *) pApp;
  85. if (bstrAdsPath) {
  86. ADsFreeString(bstrAdsPath);
  87. }
  88. if (pLexer) {
  89. delete pLexer;
  90. }
  91. if (pszIISPathName ) {
  92. FreeADsStr( pszIISPathName );
  93. }
  94. FreeObjectInfo( &ObjectInfo );
  95. RRETURN(hr);
  96. error:
  97. if (bstrAdsPath) {
  98. ADsFreeString(bstrAdsPath);
  99. }
  100. if (pLexer) {
  101. delete pLexer;
  102. }
  103. if (pszIISPathName ) {
  104. FreeADsStr( pszIISPathName );
  105. }
  106. FreeObjectInfo( &ObjectInfo );
  107. *ppvObj = NULL;
  108. delete pApp;
  109. RRETURN(hr);
  110. }
  111. CIISApp::~CIISApp( )
  112. {
  113. if (_pWamAdmin) {
  114. _pWamAdmin->Release();
  115. }
  116. if (_pWamAdmin2) {
  117. _pWamAdmin2->Release();
  118. }
  119. if (_pAppAdmin) {
  120. _pAppAdmin->Release();
  121. }
  122. if (_pszServerName) {
  123. FreeADsStr(_pszServerName);
  124. }
  125. if (_pszMetaBasePath) {
  126. FreeADsStr(_pszMetaBasePath);
  127. }
  128. delete _pDispMgr;
  129. }
  130. STDMETHODIMP
  131. CIISApp::QueryInterface(
  132. REFIID iid,
  133. LPVOID FAR* ppv
  134. )
  135. {
  136. HRESULT hr = S_OK;
  137. hr = _pUnkOuter->QueryInterface(iid,ppv);
  138. RRETURN(hr);
  139. }
  140. HRESULT
  141. CIISApp::AllocateAppObject(
  142. IUnknown *pUnkOuter,
  143. CCredentials& Credentials,
  144. CIISApp ** ppApp
  145. )
  146. {
  147. CIISApp FAR * pApp = NULL;
  148. IADs FAR * pADs = NULL;
  149. CAggregateeDispMgr FAR * pDispMgr = NULL;
  150. HRESULT hr = S_OK;
  151. pApp = new CIISApp();
  152. if (pApp == NULL) {
  153. hr = E_OUTOFMEMORY;
  154. }
  155. BAIL_ON_FAILURE(hr);
  156. pDispMgr = new CAggregateeDispMgr;
  157. if (pDispMgr == NULL) {
  158. hr = E_OUTOFMEMORY;
  159. }
  160. BAIL_ON_FAILURE(hr);
  161. hr = pDispMgr->LoadTypeInfoEntry(
  162. LIBID_IISExt,
  163. IID_IISApp3,
  164. (IISApp3 *)pApp,
  165. DISPID_REGULAR
  166. );
  167. BAIL_ON_FAILURE(hr);
  168. //
  169. // Store the IADs Pointer, but again do NOT ref-count
  170. // this pointer - we keep the pointer around, but do
  171. // a release immediately.
  172. //
  173. hr = pUnkOuter->QueryInterface(IID_IADs, (void **)&pADs);
  174. pADs->Release();
  175. pApp->_pADs = pADs;
  176. //
  177. // Store the pointer to the pUnkOuter object
  178. // AND DO NOT add ref this pointer
  179. //
  180. pApp->_pUnkOuter = pUnkOuter;
  181. pApp->_Credentials = Credentials;
  182. pApp->_pDispMgr = pDispMgr;
  183. *ppApp = pApp;
  184. RRETURN(hr);
  185. error:
  186. delete pDispMgr;
  187. delete pApp;
  188. RRETURN(hr);
  189. }
  190. HRESULT
  191. CIISApp::InitializeAppObject(
  192. LPWSTR pszServerName,
  193. LPWSTR pszPath
  194. )
  195. {
  196. HRESULT hr = S_OK;
  197. DWORD dwState;
  198. if (pszServerName) {
  199. _pszServerName = AllocADsStr(pszServerName);
  200. if (!_pszServerName) {
  201. hr = E_OUTOFMEMORY;
  202. BAIL_ON_FAILURE(hr);
  203. }
  204. }
  205. if (pszPath) {
  206. _pszMetaBasePath = AllocADsStr(pszPath);
  207. if (!_pszMetaBasePath) {
  208. hr = E_OUTOFMEMORY;
  209. BAIL_ON_FAILURE(hr);
  210. }
  211. }
  212. hr = InitServerInfo(pszServerName, &_pAdminBase);
  213. BAIL_ON_FAILURE(hr);
  214. hr = InitWamAdm(pszServerName);
  215. BAIL_ON_FAILURE(hr);
  216. error:
  217. RRETURN(hr);
  218. }
  219. HRESULT
  220. CIISApp::InitWamAdm(
  221. LPWSTR pszServerName
  222. )
  223. {
  224. HRESULT hr = S_OK;
  225. COSERVERINFO csiName;
  226. COSERVERINFO *pcsiParam = &csiName;
  227. memset(pcsiParam, 0, sizeof(COSERVERINFO));
  228. //
  229. // special case to handle "localhost" to work-around ole32 bug
  230. //
  231. if (pszServerName == NULL || _wcsicmp(pszServerName,L"localhost") == 0) {
  232. pcsiParam->pwszName = NULL;
  233. }
  234. else {
  235. pcsiParam->pwszName = pszServerName;
  236. }
  237. csiName.pAuthInfo = NULL;
  238. MULTI_QI rgInterfaces[3];
  239. rgInterfaces[0].hr = NOERROR;
  240. rgInterfaces[0].pIID = &IID_IWamAdmin;
  241. rgInterfaces[0].pItf = NULL;
  242. rgInterfaces[1].hr = NOERROR;
  243. rgInterfaces[1].pIID = &IID_IIISApplicationAdmin;
  244. rgInterfaces[1].pItf = NULL;
  245. rgInterfaces[2].hr = NOERROR;
  246. rgInterfaces[2].pIID = &IID_IWamAdmin2;
  247. rgInterfaces[2].pItf = NULL;
  248. hr = CoCreateInstanceEx( CLSID_WamAdmin,
  249. NULL,
  250. CLSCTX_SERVER,
  251. pcsiParam,
  252. 3,
  253. rgInterfaces
  254. );
  255. if( SUCCEEDED(hr) )
  256. {
  257. if( SUCCEEDED(rgInterfaces[0].hr) )
  258. {
  259. _pWamAdmin = (IWamAdmin *)rgInterfaces[0].pItf;
  260. }
  261. if( SUCCEEDED(rgInterfaces[1].hr) )
  262. {
  263. _pAppAdmin = (IIISApplicationAdmin *)rgInterfaces[1].pItf;
  264. }
  265. if( SUCCEEDED(rgInterfaces[2].hr) )
  266. {
  267. _pWamAdmin2 = (IWamAdmin2 *)rgInterfaces[2].pItf;
  268. }
  269. }
  270. RRETURN(hr);
  271. }
  272. //+---------------------------------------------------------------------------
  273. //
  274. // Function: CIISApp::AppCreate
  275. //
  276. // Synopsis:
  277. //
  278. // Arguments:
  279. //
  280. // Returns: HRESULT.
  281. //
  282. // Modifies:
  283. //
  284. // History: 07/14/97 SophiaC Created
  285. //
  286. // Notes:
  287. //----------------------------------------------------------------------------
  288. STDMETHODIMP
  289. CIISApp::AppCreate(
  290. THIS_ VARIANT_BOOL bSetInProcFlag
  291. )
  292. {
  293. HRESULT hr = S_OK;
  294. BOOL boolCreatePool = FALSE;
  295. LPWSTR pszPoolName;
  296. if (_pAppAdmin) {
  297. pszPoolName = NULL;
  298. boolCreatePool = FALSE;
  299. hr = _pAppAdmin->CreateApplication((LPWSTR)_pszMetaBasePath,
  300. bSetInProcFlag ? 0 : 1,
  301. pszPoolName,
  302. boolCreatePool
  303. );
  304. }
  305. else if (_pWamAdmin) {
  306. hr = _pWamAdmin->AppCreate((LPWSTR)_pszMetaBasePath,
  307. bSetInProcFlag ? TRUE : FALSE);
  308. }
  309. else {
  310. hr = E_NOINTERFACE;
  311. }
  312. RRETURN(hr);
  313. }
  314. STDMETHODIMP
  315. CIISApp::AppCreate2(
  316. IN LONG lAppMode
  317. )
  318. {
  319. HRESULT hr = S_OK;
  320. BOOL boolCreatePool = FALSE;
  321. LPWSTR pszPoolName;
  322. if (_pAppAdmin) {
  323. pszPoolName = NULL;
  324. boolCreatePool = FALSE;
  325. hr = _pAppAdmin->CreateApplication((LPWSTR)_pszMetaBasePath,
  326. lAppMode,
  327. pszPoolName,
  328. boolCreatePool
  329. );
  330. }
  331. else if (_pWamAdmin2) {
  332. hr = _pWamAdmin2->AppCreate2( (LPWSTR)_pszMetaBasePath, lAppMode );
  333. }
  334. else {
  335. hr = E_NOINTERFACE;
  336. }
  337. RRETURN(hr);
  338. }
  339. STDMETHODIMP
  340. CIISApp::AppCreate3(
  341. IN LONG lAppMode,
  342. VARIANT bstrAppPoolId,
  343. VARIANT bCreatePool
  344. )
  345. {
  346. HRESULT hr = S_OK;
  347. BOOL boolCreatePool = FALSE;
  348. LPWSTR pszPoolName;
  349. if (_pAppAdmin) {
  350. if (bstrAppPoolId.vt == VT_BSTR) {
  351. pszPoolName = bstrAppPoolId.bstrVal;
  352. }
  353. else {
  354. pszPoolName = NULL;
  355. }
  356. if (bCreatePool.vt == VT_BOOL) {
  357. if (bCreatePool.boolVal == VARIANT_TRUE) {
  358. boolCreatePool = TRUE;
  359. }
  360. else {
  361. boolCreatePool = FALSE;
  362. }
  363. }
  364. hr = _pAppAdmin->CreateApplication((LPWSTR)_pszMetaBasePath,
  365. lAppMode,
  366. pszPoolName,
  367. boolCreatePool
  368. );
  369. }
  370. else if (_pWamAdmin2) {
  371. hr = _pWamAdmin2->AppCreate2( (LPWSTR)_pszMetaBasePath, lAppMode );
  372. }
  373. else {
  374. hr = E_NOINTERFACE;
  375. }
  376. RRETURN(hr);
  377. }
  378. //+---------------------------------------------------------------------------
  379. //
  380. // Function: CIISApp::AppDelete
  381. //
  382. // Synopsis:
  383. //
  384. // Arguments:
  385. //
  386. // Returns: HRESULT.
  387. //
  388. // Modifies:
  389. //
  390. // History: 07/14/96 SophiaC Created
  391. //
  392. //----------------------------------------------------------------------------
  393. STDMETHODIMP
  394. CIISApp::AppDelete(THIS)
  395. {
  396. HRESULT hr = S_OK;
  397. if (_pAppAdmin) {
  398. hr = _pAppAdmin->DeleteApplication((LPWSTR)_pszMetaBasePath, FALSE);
  399. }
  400. else if (_pWamAdmin) {
  401. hr = _pWamAdmin->AppDelete((LPWSTR)_pszMetaBasePath, FALSE);
  402. }
  403. else {
  404. hr = E_NOINTERFACE;
  405. }
  406. RRETURN(hr);
  407. }
  408. //+---------------------------------------------------------------------------
  409. //
  410. // Function: CIISApp::AppDeleteRecursive
  411. //
  412. // Synopsis:
  413. //
  414. // Arguments:
  415. //
  416. // Returns: HRESULT.
  417. //
  418. // Modifies:
  419. //
  420. // History: 07/14/96 SophiaC Created
  421. //
  422. //----------------------------------------------------------------------------
  423. STDMETHODIMP
  424. CIISApp::AppDeleteRecursive(THIS)
  425. {
  426. HRESULT hr = S_OK;
  427. if (_pAppAdmin) {
  428. hr = _pAppAdmin->DeleteApplication((LPWSTR)_pszMetaBasePath, TRUE);
  429. }
  430. else if (_pWamAdmin) {
  431. hr = _pWamAdmin->AppDelete((LPWSTR)_pszMetaBasePath, TRUE);
  432. }
  433. else {
  434. hr = E_NOINTERFACE;
  435. }
  436. RRETURN(hr);
  437. }
  438. //+---------------------------------------------------------------------------
  439. //
  440. // Function: CIISApp::AppUnLoad
  441. //
  442. // Synopsis:
  443. //
  444. // Arguments:
  445. //
  446. // Returns: HRESULT.
  447. //
  448. // Modifies:
  449. //
  450. // History: 07-14-96 SophiaC Created
  451. //
  452. //----------------------------------------------------------------------------
  453. STDMETHODIMP
  454. CIISApp::AppUnLoad(THIS)
  455. {
  456. HRESULT hr = S_OK;
  457. hr = _pWamAdmin->AppUnLoad((LPWSTR)_pszMetaBasePath, FALSE);
  458. RRETURN(hr);
  459. }
  460. //+---------------------------------------------------------------------------
  461. //
  462. // Function: CIISApp::AppUnLoadRecursive
  463. //
  464. // Synopsis:
  465. //
  466. // Arguments:
  467. //
  468. // Returns: HRESULT.
  469. //
  470. // Modifies:
  471. //
  472. // History: 07-14-96 SophiaC Created
  473. //
  474. //----------------------------------------------------------------------------
  475. STDMETHODIMP
  476. CIISApp::AppUnLoadRecursive(THIS)
  477. {
  478. HRESULT hr = S_OK;
  479. hr = _pWamAdmin->AppUnLoad((LPWSTR)_pszMetaBasePath, TRUE);
  480. RRETURN(hr);
  481. }
  482. //+---------------------------------------------------------------------------
  483. //
  484. // Function: CIISApp::AppDisable
  485. //
  486. // Synopsis:
  487. //
  488. // Arguments:
  489. //
  490. // Returns: HRESULT.
  491. //
  492. // Modifies:
  493. //
  494. // History: 07-14-96 SophiaC Created
  495. //
  496. //----------------------------------------------------------------------------
  497. STDMETHODIMP
  498. CIISApp::AppDisable(THIS)
  499. {
  500. HRESULT hr = S_OK;
  501. hr = _pWamAdmin->AppDeleteRecoverable((LPWSTR)_pszMetaBasePath, FALSE);
  502. RRETURN(hr);
  503. }
  504. //+---------------------------------------------------------------------------
  505. //
  506. // Function: CIISApp::AppDisableRecursive
  507. //
  508. // Synopsis:
  509. //
  510. // Arguments:
  511. //
  512. // Returns: HRESULT.
  513. //
  514. // Modifies:
  515. //
  516. // History: 07-14-96 SophiaC Created
  517. //
  518. //----------------------------------------------------------------------------
  519. STDMETHODIMP
  520. CIISApp::AppDisableRecursive(THIS)
  521. {
  522. HRESULT hr = S_OK;
  523. hr = _pWamAdmin->AppDeleteRecoverable((LPWSTR)_pszMetaBasePath, TRUE);
  524. RRETURN(hr);
  525. }
  526. //+---------------------------------------------------------------------------
  527. //
  528. // Function: CIISApp::AppGetStatus
  529. //
  530. // Synopsis:
  531. //
  532. // Arguments:
  533. //
  534. // Returns: HRESULT.
  535. //
  536. // Modifies:
  537. //
  538. // History: 07/14/96 SophiaC Created
  539. //
  540. //----------------------------------------------------------------------------
  541. STDMETHODIMP
  542. CIISApp::AppGetStatus(THIS_ DWORD * pdwStatus)
  543. {
  544. HRESULT hr = S_OK;
  545. hr = _pWamAdmin->AppGetStatus((LPWSTR)_pszMetaBasePath, pdwStatus);
  546. RRETURN(hr);
  547. }
  548. //+---------------------------------------------------------------------------
  549. //
  550. // Function: CIISApp::AppGetStatus2
  551. //
  552. // Synopsis: AppGetStatus is not automation compliant. This version
  553. // is.
  554. //
  555. // Arguments:
  556. //
  557. // Returns: HRESULT.
  558. //
  559. //----------------------------------------------------------------------------
  560. STDMETHODIMP
  561. CIISApp::AppGetStatus2( LONG * lpStatus )
  562. {
  563. HRESULT hr;
  564. hr = _pWamAdmin->AppGetStatus((LPWSTR)_pszMetaBasePath, (LPDWORD)lpStatus);
  565. RRETURN(hr);
  566. }
  567. //+---------------------------------------------------------------------------
  568. //
  569. // Function: CIISApp::AppEnable
  570. //
  571. // Synopsis:
  572. //
  573. // Arguments:
  574. //
  575. // Returns: HRESULT.
  576. //
  577. // Modifies:
  578. //
  579. // History: 07-14-96 SophiaC Created
  580. //
  581. //----------------------------------------------------------------------------
  582. STDMETHODIMP
  583. CIISApp::AppEnable(THIS)
  584. {
  585. HRESULT hr = S_OK;
  586. hr = _pWamAdmin->AppRecover((LPWSTR)_pszMetaBasePath, FALSE);
  587. RRETURN(hr);
  588. }
  589. //+---------------------------------------------------------------------------
  590. //
  591. // Function: CIISApp::AspAppRestart
  592. //
  593. // Synopsis:
  594. //
  595. // Arguments:
  596. //
  597. // Returns: HRESULT.
  598. //
  599. // Modifies:
  600. //
  601. // History: 07-14-96 SophiaC Created
  602. //
  603. //----------------------------------------------------------------------------
  604. STDMETHODIMP
  605. CIISApp::AspAppRestart(THIS)
  606. {
  607. HRESULT hr = S_OK;
  608. DWORD dwState = 0;
  609. METADATA_HANDLE hObjHandle = NULL;
  610. hr = IISCheckApp(METADATA_MASTER_ROOT_HANDLE);
  611. BAIL_ON_FAILURE(hr);
  612. hr = IISGetState(METADATA_MASTER_ROOT_HANDLE, &dwState);
  613. BAIL_ON_FAILURE(hr);
  614. //
  615. // Write the value to the metabase
  616. //
  617. hr = OpenAdminBaseKey(
  618. _pszServerName,
  619. _pszMetaBasePath,
  620. METADATA_PERMISSION_WRITE,
  621. &_pAdminBase,
  622. &hObjHandle
  623. );
  624. BAIL_ON_FAILURE(hr);
  625. dwState = dwState ? 0 : 1;
  626. hr = IISSetState(hObjHandle, dwState);
  627. BAIL_ON_FAILURE(hr);
  628. dwState = dwState ? 0 : 1;
  629. hr = IISSetState(hObjHandle, dwState);
  630. BAIL_ON_FAILURE(hr);
  631. CloseAdminBaseKey(_pAdminBase, hObjHandle);
  632. error:
  633. RRETURN(hr);
  634. }
  635. //+---------------------------------------------------------------------------
  636. //
  637. // Function: CIISApp::AppEnableRecursive
  638. //
  639. // Synopsis:
  640. //
  641. // Arguments:
  642. //
  643. // Returns: HRESULT.
  644. //
  645. // Modifies:
  646. //
  647. // History: 07-14-96 SophiaC Created
  648. //
  649. //----------------------------------------------------------------------------
  650. STDMETHODIMP
  651. CIISApp::AppEnableRecursive(THIS)
  652. {
  653. HRESULT hr = S_OK;
  654. hr = _pWamAdmin->AppRecover((LPWSTR)_pszMetaBasePath, TRUE);
  655. RRETURN(hr);
  656. }
  657. HRESULT
  658. CIISApp::IISSetState(
  659. METADATA_HANDLE hObjHandle,
  660. DWORD dwState
  661. )
  662. {
  663. HRESULT hr = S_OK;
  664. DWORD dwBufferSize = sizeof(DWORD);
  665. METADATA_RECORD mdrMDData;
  666. LPBYTE pBuffer = (LPBYTE)&dwState;
  667. MD_SET_DATA_RECORD(&mdrMDData,
  668. MD_ASP_ENABLEAPPLICATIONRESTART,
  669. METADATA_INHERIT,
  670. ASP_MD_UT_APP,
  671. DWORD_METADATA,
  672. dwBufferSize,
  673. pBuffer);
  674. hr = _pAdminBase->SetData(
  675. hObjHandle,
  676. L"",
  677. &mdrMDData
  678. );
  679. RRETURN(hr);
  680. }
  681. HRESULT
  682. CIISApp::IISCheckApp(
  683. METADATA_HANDLE hObjHandle
  684. )
  685. {
  686. HRESULT hr = S_OK;
  687. DWORD dwBufferSize;
  688. METADATA_RECORD mdrMDData;
  689. LPBYTE pBuffer;
  690. WCHAR DataBuf[MAX_PATH];
  691. DWORD dwState;
  692. pBuffer = (LPBYTE) DataBuf;
  693. dwBufferSize = MAX_PATH;
  694. MD_SET_DATA_RECORD(&mdrMDData,
  695. MD_APP_ROOT,
  696. METADATA_INHERIT|METADATA_ISINHERITED,
  697. IIS_MD_UT_FILE,
  698. STRING_METADATA,
  699. dwBufferSize,
  700. pBuffer);
  701. hr = _pAdminBase->GetData(
  702. hObjHandle,
  703. _pszMetaBasePath,
  704. &mdrMDData,
  705. &dwBufferSize
  706. );
  707. BAIL_ON_FAILURE(hr);
  708. if (mdrMDData.dwMDAttributes & METADATA_ISINHERITED) {
  709. hr = MD_ERROR_DATA_NOT_FOUND;
  710. BAIL_ON_FAILURE(hr);
  711. }
  712. pBuffer = (LPBYTE) &dwState;
  713. dwBufferSize = sizeof(DWORD);
  714. MD_SET_DATA_RECORD(&mdrMDData,
  715. MD_APP_ISOLATED,
  716. METADATA_INHERIT|METADATA_ISINHERITED,
  717. IIS_MD_UT_WAM,
  718. DWORD_METADATA,
  719. dwBufferSize,
  720. pBuffer);
  721. hr = _pAdminBase->GetData(
  722. hObjHandle,
  723. _pszMetaBasePath,
  724. &mdrMDData,
  725. &dwBufferSize
  726. );
  727. BAIL_ON_FAILURE(hr);
  728. if (mdrMDData.dwMDAttributes & METADATA_ISINHERITED) {
  729. hr = MD_ERROR_DATA_NOT_FOUND;
  730. BAIL_ON_FAILURE(hr);
  731. }
  732. error:
  733. RRETURN(hr);
  734. }
  735. HRESULT
  736. CIISApp::IISGetState(
  737. METADATA_HANDLE hObjHandle,
  738. PDWORD pdwState
  739. )
  740. {
  741. HRESULT hr = S_OK;
  742. DWORD dwBufferSize = sizeof(DWORD);
  743. METADATA_RECORD mdrMDData;
  744. LPBYTE pBuffer = (LPBYTE)pdwState;
  745. MD_SET_DATA_RECORD(&mdrMDData,
  746. MD_ASP_ENABLEAPPLICATIONRESTART,
  747. METADATA_INHERIT,
  748. ASP_MD_UT_APP,
  749. DWORD_METADATA,
  750. dwBufferSize,
  751. pBuffer);
  752. hr = _pAdminBase->GetData(
  753. hObjHandle,
  754. _pszMetaBasePath,
  755. &mdrMDData,
  756. &dwBufferSize
  757. );
  758. RRETURN(hr);
  759. }
  760. STDMETHODIMP
  761. CIISApp::ADSIInitializeDispatchManager(
  762. long dwExtensionId
  763. )
  764. {
  765. HRESULT hr = S_OK;
  766. if (_fDispInitialized) {
  767. RRETURN(E_FAIL);
  768. }
  769. hr = _pDispMgr->InitializeDispMgr(dwExtensionId);
  770. if (SUCCEEDED(hr)) {
  771. _fDispInitialized = TRUE;
  772. }
  773. RRETURN(hr);
  774. }
  775. STDMETHODIMP
  776. CIISApp::ADSIInitializeObject(
  777. THIS_ BSTR lpszUserName,
  778. BSTR lpszPassword,
  779. long lnReserved
  780. )
  781. {
  782. CCredentials NewCredentials(lpszUserName, lpszPassword, lnReserved);
  783. _Credentials = NewCredentials;
  784. RRETURN(S_OK);
  785. }
  786. STDMETHODIMP
  787. CIISApp::ADSIReleaseObject()
  788. {
  789. delete this;
  790. RRETURN(S_OK);
  791. }
  792. STDMETHODIMP
  793. CIISApp::NonDelegatingQueryInterface(
  794. REFIID iid,
  795. LPVOID FAR* ppv
  796. )
  797. {
  798. ASSERT(ppv);
  799. if (IsEqualIID(iid, IID_IISApp)) {
  800. *ppv = (IISApp3 FAR *) this;
  801. }
  802. else if (IsEqualIID(iid, IID_IISApp2)) {
  803. *ppv = (IISApp3 FAR *) this;
  804. }
  805. else if (IsEqualIID(iid, IID_IISApp3)) {
  806. *ppv = (IISApp3 FAR *) this;
  807. }
  808. else if (IsEqualIID(iid, IID_IADsExtension)) {
  809. *ppv = (IADsExtension FAR *) this;
  810. } else if (IsEqualIID(iid, IID_IUnknown)) {
  811. //
  812. // probably not needed since our 3rd party extension does not stand
  813. // alone and provider does not ask for this, but to be safe
  814. //
  815. *ppv = (INonDelegatingUnknown FAR *) this;
  816. } else {
  817. *ppv = NULL;
  818. return E_NOINTERFACE;
  819. }
  820. //
  821. // Delegating AddRef to aggregator for IADsExtesnion and IISApp.
  822. // AddRef on itself for IPrivateUnknown. (both tested.)
  823. //
  824. ((IUnknown *) (*ppv)) -> AddRef();
  825. return S_OK;
  826. }
  827. //
  828. // IADsExtension::Operate()
  829. //
  830. STDMETHODIMP
  831. CIISApp::Operate(
  832. THIS_ DWORD dwCode,
  833. VARIANT varUserName,
  834. VARIANT varPassword,
  835. VARIANT varFlags
  836. )
  837. {
  838. RRETURN(E_NOTIMPL);
  839. }