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.

2546 lines
58 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. mdkeys.h
  5. Abstract:
  6. Metabase key wrapper classes
  7. Wam admin interface wrapper class
  8. App admin interface wrapper class
  9. Author:
  10. Ronald Meijer (ronaldm)
  11. Sergei Antonov (sergeia)
  12. Project:
  13. Internet Services Manager
  14. Revision History:
  15. --*/
  16. #ifndef _MDKEYS_H_
  17. #define _MDKEYS_H_
  18. #include <iadmw.h>
  19. #include <iwamreg.h>
  20. #include <iiscnfgp.h>
  21. #include <winsvc.h>
  22. #include <iisrsta.h>
  23. #include "strpass.h"
  24. //
  25. // Forward definitions
  26. //
  27. class CBlob;
  28. //
  29. // Use this instance number to denote the master
  30. //
  31. #define MASTER_INSTANCE (0)
  32. #define IS_MASTER_INSTANCE(i) (i == MASTER_INSTANCE)
  33. #define ASSURE_PROPER_INTERFACE()\
  34. if (!HasInterface()) { ASSERT_MSG("No interface"); return MD_ERROR_NOT_INITIALIZED; }
  35. //
  36. // Metabase node constants, used for static initialization of const
  37. // strings further down. Defined here with #defines for easier
  38. // concatenation later.
  39. //
  40. #define SZ_MBN_MACHINE _T("LM")
  41. #define SZ_MBN_FILTERS _T("Filters")
  42. #define SZ_MBN_MIMEMAP _T("MimeMap")
  43. #define SZ_MBN_TEMPLATES _T("Templates")
  44. #define SZ_MBN_INFO _T("Info")
  45. #define SZ_MBN_ROOT _T("Root")
  46. #define SZ_MBN_COMPRESSION _T("Compression")
  47. #define SZ_MBN_PARAMETERS _T("Parameters")
  48. #define SZ_MBN_SEP_CHAR _T('/')
  49. #define SZ_MBN_SEP_STR _T("/")
  50. #define SZ_MBN_WEB _T("W3SVC")
  51. #define SZ_MBN_FTP _T("MSFTPSVC")
  52. #define SZ_MBN_SMTP _T("SMTPSVC")
  53. #define SZ_MBN_NNTP _T("NNTPSVC")
  54. #define SZ_MBN_APP_POOLS _T("AppPools")
  55. class CIISInterface;
  56. class COMDLL CComAuthInfo
  57. /*++
  58. Class Description:
  59. Server/authentication information. Contains optional
  60. impersonation parameters. Typically used in the construction in
  61. CIISInterface.
  62. Public Interface:
  63. CComAuthInfo : Constructor. Impersonation optional
  64. operator= : Assignment operators
  65. CreateServerInfoStruct : Helper function for use in COM
  66. FreeServerInfoStruct : As above.
  67. Notes:
  68. Because there's an operator for a pointer to itself and because
  69. CIISInterface copies the information at construction time, a
  70. CComAuthInfo can safely be constructed on the stack as a parameter
  71. to CIISInterface derived classes.
  72. --*/
  73. {
  74. //
  75. // Constructor/Destructor
  76. //
  77. public:
  78. //
  79. // Standard Constructor. NULL for servername indicates
  80. // local computer.
  81. //
  82. CComAuthInfo(
  83. IN LPCOLESTR lpszServerName = NULL,
  84. IN LPCOLESTR lpszUserName = NULL,
  85. IN LPCOLESTR lpszPassword = NULL
  86. );
  87. //
  88. // Copy Constructors
  89. //
  90. CComAuthInfo(
  91. IN CComAuthInfo & auth
  92. );
  93. CComAuthInfo(
  94. IN CComAuthInfo * pAuthInfo OPTIONAL
  95. );
  96. //
  97. // Assignment operators
  98. //
  99. public:
  100. CComAuthInfo & operator =(CComAuthInfo & auth);
  101. CComAuthInfo & operator =(CComAuthInfo * pAuthInfo);
  102. CComAuthInfo & operator =(LPCTSTR lpszServerName);
  103. //
  104. // Access
  105. //
  106. public:
  107. COSERVERINFO * CreateServerInfoStruct() const;
  108. COSERVERINFO * CreateServerInfoStruct(DWORD dwAuthnLevel) const;
  109. void FreeServerInfoStruct(COSERVERINFO * pServerInfo) const;
  110. LPOLESTR QueryServerName() const { return m_bstrServerName; }
  111. LPOLESTR QueryUserName() const { return m_bstrUserName; }
  112. LPOLESTR QueryPassword() const { return m_bstrPassword; }
  113. BOOL IsLocal() const { return m_fLocal; }
  114. BOOL UsesImpersonation() const { return m_bstrUserName.Length() > 0; }
  115. void SetImpersonation(LPCOLESTR lpszUser, LPCOLESTR lpszPassword);
  116. void RemoveImpersonation();
  117. void StorePassword(LPCOLESTR lpszPassword);
  118. public:
  119. HRESULT ApplyProxyBlanket(IUnknown * pInterface);
  120. HRESULT ApplyProxyBlanket(IUnknown * pInterface,DWORD dwAuthnLevel);
  121. //
  122. // Conversion Operators
  123. //
  124. public:
  125. operator LPOLESTR() { return QueryServerName(); }
  126. operator CComAuthInfo *() { return this; }
  127. //
  128. // Static Helpers
  129. //
  130. public:
  131. //
  132. // Given domain\username, split into user name and domain
  133. //
  134. static BOOL SplitUserNameAndDomain(
  135. IN OUT CString & strUserName,
  136. IN CString & strDomainName
  137. );
  138. //
  139. // Verify username and password are correct
  140. //
  141. static DWORD VerifyUserPassword(
  142. IN LPCTSTR lpstrUserName,
  143. IN LPCTSTR lpstrPassword
  144. );
  145. protected:
  146. //
  147. // Store the computer name (NULL for local computer)
  148. //
  149. void SetComputerName(
  150. IN LPCOLESTR lpszServerName OPTIONAL
  151. );
  152. private:
  153. CComBSTR m_bstrServerName;
  154. CComBSTR m_bstrUserName;
  155. CComBSTR m_bstrPassword;
  156. BOOL m_fLocal;
  157. };
  158. class COMDLL CMetabasePath
  159. /*++
  160. Class Description:
  161. Metabase path class. This is a helper class to build complete
  162. metabase paths out of various components.
  163. Example: CMetaKey(CComAuthInfo("ronaldm3"), CMetabasePath(SZ_WEBSVC, dwInstance, _T("root")));
  164. --*/
  165. {
  166. //
  167. // Metabase components in order
  168. //
  169. enum
  170. {
  171. iBlank, // Sep 0
  172. iMachine, // LM
  173. iService, // e.g. lm/w3svc
  174. iInstance, // e.g. lm/w3svc/1
  175. iRootDirectory, // e.g. lm/w3svc/1/root
  176. iSubDirectory, // e.g. lm/w3vsc/1/root/foobar
  177. };
  178. //
  179. // Metabase helper functions.
  180. //
  181. public:
  182. //
  183. // Clean metabase path
  184. //
  185. static LPCTSTR CleanMetaPath(
  186. IN OUT CString & strMetaRoot
  187. );
  188. //
  189. // Find out the instance number from the given metabase path
  190. //
  191. static DWORD GetInstanceNumber(LPCTSTR lpszMDPath);
  192. //
  193. // Get the last nodename in the given metabase path
  194. //
  195. static LPCTSTR GetLastNodeName(
  196. IN LPCTSTR lpszMDPath,
  197. OUT CString & strNodeName
  198. );
  199. //
  200. // Truncate the path at a given sub path
  201. //
  202. static LPCTSTR TruncatePath(
  203. IN int nLevel,
  204. IN LPCTSTR lpszMDPath,
  205. OUT CString & strNewPath,
  206. OUT CString * pstrRemainder = NULL
  207. );
  208. static LPCTSTR GetMachinePath(
  209. IN LPCTSTR lpszMDPath,
  210. OUT CString & strNewPath,
  211. OUT CString * pstrRemainder = NULL
  212. );
  213. static LPCTSTR GetServicePath(
  214. IN LPCTSTR lpszMDPath,
  215. OUT CString & strNewPath,
  216. OUT CString * pstrRemainder = NULL
  217. );
  218. static LPCTSTR GetInstancePath(
  219. IN LPCTSTR lpszMDPath,
  220. OUT CString & strNewPath,
  221. OUT CString * pstrRemainder = NULL
  222. );
  223. static LPCTSTR GetRootPath(
  224. IN LPCTSTR lpszMDPath,
  225. OUT CString & strNewPath,
  226. OUT CString * pstrRemainder = NULL
  227. );
  228. //
  229. // Determine the path to the info node that's relevant
  230. // to this metabase path.
  231. //
  232. static LPCTSTR GetServiceInfoPath(
  233. IN LPCTSTR lpszMDPath,
  234. OUT CString & strInfoPath,
  235. IN LPCTSTR lpszDefService = SZ_MBN_WEB
  236. );
  237. //
  238. // Change path to parent node
  239. //
  240. static LPCTSTR ConvertToParentPath(
  241. OUT IN CString & strMetaPath
  242. );
  243. //
  244. // Determine if the path describes a home directory path
  245. //
  246. static BOOL IsHomeDirectoryPath(
  247. IN LPCTSTR lpszMDPath
  248. );
  249. //
  250. // Determine if the path describes the 'master' instance (site)
  251. //
  252. static BOOL IsMasterInstance(
  253. IN LPCTSTR lpszMDPath
  254. );
  255. //
  256. // Split the metapath at the instance border
  257. //
  258. static void SplitMetaPathAtInstance(
  259. IN LPCTSTR lpszMDPath,
  260. OUT CString & strParent,
  261. OUT CString & strAlias
  262. );
  263. //
  264. // Constructor/Destructor
  265. //
  266. public:
  267. CMetabasePath(
  268. IN BOOL fAddBasePath,
  269. IN LPCTSTR lpszMDPath,
  270. IN LPCTSTR lpszMDPath2 = NULL,
  271. IN LPCTSTR lpszMDPath3 = NULL,
  272. IN LPCTSTR lpszMDPath4 = NULL
  273. );
  274. //
  275. // Construct with path components
  276. //
  277. CMetabasePath(
  278. IN LPCTSTR lpszSvc = NULL,
  279. IN DWORD dwInstance = MASTER_INSTANCE,
  280. IN LPCTSTR lpszParentPath = NULL,
  281. IN LPCTSTR lpszAlias = NULL
  282. );
  283. //
  284. // Access
  285. //
  286. public:
  287. BOOL IsHomeDirectoryPath() const { return IsHomeDirectoryPath(m_strMetaPath); }
  288. LPCTSTR QueryMetaPath() const { return m_strMetaPath; }
  289. //
  290. // Conversion Operators
  291. //
  292. public:
  293. operator LPCTSTR() const { return QueryMetaPath(); }
  294. //
  295. // Helpers
  296. //
  297. protected:
  298. void BuildMetaPath(
  299. IN LPCTSTR lpszSvc,
  300. IN LPCTSTR szInstance,
  301. IN LPCTSTR lpszParentPath,
  302. IN LPCTSTR lpszAlias
  303. );
  304. void BuildMetaPath(
  305. IN LPCTSTR lpszSvc,
  306. IN DWORD dwInstance,
  307. IN LPCTSTR lpszParentPath,
  308. IN LPCTSTR lpszAlias
  309. );
  310. void AppendPath(LPCTSTR lpszPath);
  311. void AppendPath(DWORD dwInstance);
  312. protected:
  313. //
  314. // Metabase path components
  315. //
  316. static const LPCTSTR _cszMachine;
  317. static const LPCTSTR _cszRoot;
  318. static const LPCTSTR _cszSep;
  319. static const TCHAR _chSep;
  320. private:
  321. CString m_strMetaPath;
  322. };
  323. class COMDLL CIISInterface
  324. /*++
  325. Class Description:
  326. Base interface class for IIS interfaces. Most client COM-wrappers
  327. should derive from this class so that they can easily pick up
  328. share authentication and proxy blanket information methods.
  329. Virtual Interface:
  330. Succeeded : Return TRUE if item constructed successfully
  331. QueryResult : Return construction error code
  332. Public Interface:
  333. operator BOOL : Cast to TRUE/FALSE depending on success
  334. operator HRESULT : Cast to the HRESULT status
  335. QueryServerName : Get the server name
  336. IsLocal : Determine if the interface is on the local machine
  337. --*/
  338. {
  339. //
  340. // Constructor/Destructor
  341. //
  342. public:
  343. CIISInterface(
  344. IN CComAuthInfo * pAuthInfo,
  345. IN HRESULT hrInterface = S_OK
  346. );
  347. //
  348. // Interface:
  349. //
  350. public:
  351. CComAuthInfo * QueryAuthInfo() { return &m_auth; }
  352. LPCOLESTR QueryServerName() const { return m_auth.QueryServerName(); }
  353. BOOL IsLocal() const { return m_auth.IsLocal(); }
  354. //
  355. // Virtual Interface:
  356. //
  357. public:
  358. virtual BOOL Succeeded() const { return SUCCEEDED(m_hrInterface); }
  359. virtual HRESULT QueryResult() const { return m_hrInterface; }
  360. virtual HRESULT ChangeProxyBlanket(
  361. IN LPCOLESTR lpszUserName,
  362. IN LPCOLESTR lpszPassword
  363. );
  364. //
  365. // Conversion Operators
  366. //
  367. public:
  368. operator BOOL() const { return Succeeded(); }
  369. operator HRESULT() const { return m_hrInterface; }
  370. protected:
  371. virtual HRESULT ApplyProxyBlanket() = 0;
  372. HRESULT Create(
  373. IN int cInterfaces,
  374. IN const IID rgIID[],
  375. IN const GUID rgCLSID[],
  376. OUT int * pnInterface, OPTIONAL
  377. OUT IUnknown ** ppInterface
  378. );
  379. protected:
  380. CComAuthInfo m_auth;
  381. HRESULT m_hrInterface;
  382. };
  383. class COMDLL CMetaInterface : public CIISInterface
  384. /*++
  385. Class description:
  386. Metabase interface class.
  387. Virtual Interface:
  388. Succeeded : Return TRUE if item constructed successfully
  389. QueryResult : Return construction error code
  390. Public Interface:
  391. Regenerate : Recreate the interface
  392. --*/
  393. {
  394. public:
  395. //
  396. // Destructor destroys the interface
  397. //
  398. virtual ~CMetaInterface();
  399. //
  400. // Constructor/Destructor
  401. //
  402. protected:
  403. //
  404. // Fully defined constructor that creates the interface.
  405. // Use NULL to indicate the local computer name
  406. //
  407. CMetaInterface(
  408. IN CComAuthInfo * pServer
  409. );
  410. //
  411. // Construct from existing interface
  412. //
  413. CMetaInterface(
  414. IN CMetaInterface * pInterface
  415. );
  416. public:
  417. //
  418. // Rebuild the interface
  419. //
  420. HRESULT Regenerate();
  421. // check if there are metabases changes
  422. HRESULT GetSystemChangeNumber(OUT DWORD * pdwChangeNumber);
  423. //
  424. // Flush matabase to disk
  425. //
  426. HRESULT SaveData();
  427. //
  428. IMSAdminBase * GetInterface() { return m_pInterface; }
  429. HRESULT GetAdminInterface2(IMSAdminBase2 ** pp);
  430. HRESULT GetAdminInterface3(IMSAdminBase3 ** pp);
  431. HRESULT CreateSite(
  432. LPCTSTR service,
  433. LPCTSTR comment,
  434. LPCTSTR binding,
  435. LPCTSTR home_path,
  436. DWORD * pinst,
  437. DWORD * pRequestedSiteInst = NULL
  438. );
  439. protected:
  440. virtual HRESULT ApplyProxyBlanket();
  441. //
  442. // Create a metadata object in this server. This function initializes the
  443. // metadata object with DCOM.
  444. //
  445. HRESULT Create();
  446. //
  447. // Make sure the interface has been created
  448. //
  449. BOOL HasInterface() const { return m_pInterface != NULL; }
  450. //
  451. // IADMW Interface -- all methods defines as inline at the end of this file.
  452. //
  453. protected:
  454. HRESULT OpenKey(
  455. IN METADATA_HANDLE hkBase,
  456. IN LPCTSTR lpszMDPath,
  457. IN DWORD dwFlags,
  458. OUT METADATA_HANDLE * phMDNewHandle
  459. );
  460. HRESULT CloseKey(
  461. IN METADATA_HANDLE hKey
  462. );
  463. HRESULT SetLastChangeTime(
  464. IN METADATA_HANDLE hMDHandle,
  465. IN LPCTSTR pszMDPath,
  466. IN FILETIME * pftMDLastChangeTime,
  467. IN BOOL bLocalTime
  468. );
  469. HRESULT GetLastChangeTime(
  470. IN METADATA_HANDLE hMDHandle,
  471. IN LPCTSTR lpszMDPath,
  472. OUT FILETIME * pftMDLastChangeTime,
  473. IN BOOL bLocalTime
  474. );
  475. HRESULT AddKey(
  476. IN METADATA_HANDLE hKey,
  477. IN LPCTSTR lpszMDPath
  478. );
  479. HRESULT DeleteKey(
  480. IN METADATA_HANDLE hKey,
  481. IN LPCTSTR lpszMDPath
  482. );
  483. HRESULT DeleteChildKeys(
  484. IN METADATA_HANDLE hKey,
  485. IN LPCTSTR lpszMDPath
  486. );
  487. HRESULT EnumKeys(
  488. IN METADATA_HANDLE hKey,
  489. IN LPCTSTR lpszMDPath,
  490. OUT LPTSTR lpszMDName,
  491. IN DWORD dwIndex
  492. );
  493. HRESULT CopyKey(
  494. IN METADATA_HANDLE hSourceKey,
  495. IN LPCTSTR lpszMDSourcePath,
  496. IN METADATA_HANDLE hDestKey,
  497. IN LPCTSTR lpszMDDestPath,
  498. IN BOOL fOverwrite,
  499. IN BOOL fCopy
  500. );
  501. HRESULT RenameKey(
  502. IN METADATA_HANDLE hKey,
  503. IN LPCTSTR lpszMDPath,
  504. IN LPCTSTR lpszNewName
  505. );
  506. HRESULT GetData(
  507. IN METADATA_HANDLE hKey,
  508. IN LPCTSTR lpszMDPath,
  509. OUT METADATA_RECORD * pmdRecord,
  510. OUT DWORD * pdwRequiredDataLen
  511. );
  512. HRESULT SetData(
  513. IN METADATA_HANDLE hKey,
  514. IN LPCTSTR lpszMDPath,
  515. IN METADATA_RECORD * pmdRecord
  516. );
  517. HRESULT DeleteData(
  518. IN METADATA_HANDLE hKey,
  519. IN LPCTSTR lpszMDPath,
  520. IN DWORD dwMDIdentifier,
  521. IN DWORD dwMDDataType
  522. );
  523. HRESULT EnumData(
  524. IN METADATA_HANDLE hKey,
  525. IN LPCTSTR lpszMDPath,
  526. OUT METADATA_RECORD * pmdRecord,
  527. IN DWORD dwIndex,
  528. OUT DWORD * pdwRequiredDataLen
  529. );
  530. HRESULT GetAllData(
  531. IN METADATA_HANDLE hKey,
  532. IN LPCTSTR lpszMDPath,
  533. IN DWORD dwMDAttributes,
  534. IN DWORD dwMDUserType,
  535. IN DWORD dwMDDataType,
  536. OUT DWORD * pdwMDNumDataEntries,
  537. OUT DWORD * pdwMDDataSetNumber,
  538. IN DWORD dwMDBufferSize,
  539. OUT LPBYTE pbMDBuffer,
  540. OUT DWORD * pdwRequiredBufferSize
  541. );
  542. HRESULT DeleteAllData(
  543. IN METADATA_HANDLE hKey,
  544. IN LPCTSTR lpszMDPath,
  545. IN DWORD dwMDUserType,
  546. IN DWORD dwMDDataType
  547. );
  548. HRESULT CopyData(
  549. IN METADATA_HANDLE hMDSourceKey,
  550. IN LPCTSTR lpszMDSourcePath,
  551. IN METADATA_HANDLE hMDDestKey,
  552. IN LPCTSTR lpszMDDestPath,
  553. IN DWORD dwMDAttributes,
  554. IN DWORD dwMDUserType,
  555. IN DWORD dwMDDataType,
  556. IN BOOL fCopy
  557. );
  558. HRESULT GetDataPaths(
  559. IN METADATA_HANDLE hKey,
  560. IN LPCTSTR lpszMDPath,
  561. IN DWORD dwMDIdentifier,
  562. IN DWORD dwMDDataType,
  563. IN DWORD dwMDBufferSize,
  564. OUT LPTSTR lpszBuffer,
  565. OUT DWORD * pdwMDRequiredBufferSize
  566. );
  567. HRESULT CMetaInterface::GetChildPaths(
  568. METADATA_HANDLE hKey,
  569. LPCTSTR path,
  570. DWORD buf_size,
  571. WCHAR * pbuf,
  572. DWORD * preq_size
  573. );
  574. HRESULT Backup(
  575. IN LPCTSTR lpszBackupLocation,
  576. IN DWORD dwMDVersion,
  577. IN DWORD dwMDFlags
  578. );
  579. HRESULT BackupWithPassword(
  580. IN LPCTSTR lpszBackupLocation,
  581. IN DWORD dwMDVersion,
  582. IN DWORD dwMDFlags,
  583. IN LPCTSTR lpszPassword
  584. );
  585. HRESULT Restore(
  586. IN LPCTSTR lpszBackupLocation,
  587. IN DWORD dwMDVersion,
  588. IN DWORD dwMDFlags
  589. );
  590. HRESULT RestoreWithPassword(
  591. IN LPCTSTR lpszBackupLocation,
  592. IN DWORD dwMDVersion,
  593. IN DWORD dwMDFlags,
  594. IN LPCTSTR lpszPassword
  595. );
  596. HRESULT EnumBackups(
  597. OUT LPTSTR lpszBackupLocation,
  598. OUT DWORD * pdwMDVersion,
  599. OUT FILETIME * pftMDBackupTime,
  600. IN DWORD dwIndex
  601. );
  602. HRESULT DeleteBackup(
  603. IN LPCTSTR lpszBackupLocation,
  604. IN DWORD dwMDVersion
  605. );
  606. HRESULT EnumHistory(
  607. OUT LPTSTR pszMDHistoryLocation,
  608. OUT DWORD * pdwMDMajorVersion,
  609. OUT DWORD * pdwMDMinorVersion,
  610. OUT FILETIME * pftMDHistoryTime,
  611. IN DWORD dwIndex
  612. );
  613. HRESULT RestoreHistory(
  614. IN LPCTSTR pszMDHistoryLocation,
  615. IN DWORD dwMDMajorVersion,
  616. IN DWORD dwMDMinorVersion,
  617. IN DWORD dwMDFlags
  618. );
  619. protected:
  620. IMSAdminBase * m_pInterface;
  621. private:
  622. int m_iTimeOutValue;
  623. };
  624. class COMDLL CMetaKey : public CMetaInterface
  625. /*++
  626. Class Description:
  627. Metabase key wrapper class
  628. Public Interface:
  629. CMetaKey : Constructor
  630. ~CMetaKey : Destructor
  631. Succeeded : TRUE if key opened successfully.
  632. QueryResult : Get the HRESULT status
  633. QueryValue : Various overloaded methods to get values
  634. SetValue : Various overloaded methods to set values
  635. DeleteValue : Delete a value
  636. Open : Open key
  637. ReOpen : Re key that was opened before
  638. Close : Close key
  639. ConvertToParentPath : Change path to parent path
  640. operator METADATA_HANDLE : Cast to a metadata handle
  641. operator LPCTSTR : Cast to the metabase path
  642. operator BOOL : Cast to TRUE if the key is open, FALSE if not
  643. GetHandle : Obtain metadata handle
  644. IsOpen : TRUE if a key is open
  645. QueryMetaPath : Get the relative metabase path
  646. QueryFlags : Get the open permissions
  647. --*/
  648. {
  649. //
  650. // Constructor/Destructor
  651. //
  652. public:
  653. //
  654. // Null constructor that only creates the interface.
  655. // A key constructed this way may read from META_ROOT_HANDLE.
  656. // This is not true of other constructors.
  657. //
  658. CMetaKey(
  659. IN CComAuthInfo * pServer
  660. );
  661. //
  662. // As above, using an existing interface
  663. //
  664. CMetaKey(
  665. IN CMetaInterface * pInterface
  666. );
  667. //
  668. // Fully defined constructor that opens a key
  669. //
  670. CMetaKey(
  671. IN CComAuthInfo * pServer,
  672. IN LPCTSTR lpszMDPath,
  673. IN DWORD dwFlags = METADATA_PERMISSION_READ,
  674. IN METADATA_HANDLE hkBase = METADATA_MASTER_ROOT_HANDLE
  675. );
  676. //
  677. // As above, using an existing interface
  678. //
  679. CMetaKey(
  680. IN CMetaInterface * pInterface,
  681. IN LPCTSTR lpszMDPath,
  682. IN DWORD dwFlags = METADATA_PERMISSION_READ,
  683. IN METADATA_HANDLE hkBase = METADATA_MASTER_ROOT_HANDLE
  684. );
  685. //
  686. // Copy constructor, might or might not own the key
  687. //
  688. CMetaKey(
  689. IN BOOL fOwnKey,
  690. IN CMetaKey * pKey
  691. );
  692. //
  693. // Destructor -- closes key.
  694. //
  695. virtual ~CMetaKey();
  696. //
  697. // Interface
  698. //
  699. public:
  700. //
  701. // Fetch a DWORD
  702. //
  703. HRESULT QueryValue(
  704. IN DWORD dwID,
  705. OUT DWORD & dwValue,
  706. IN BOOL * pfInheritanceOverride = NULL,
  707. IN LPCTSTR lpszMDPath = NULL,
  708. OUT DWORD * pdwAttributes = NULL
  709. );
  710. //
  711. // Fetch a boolean
  712. //
  713. HRESULT QueryValue(
  714. IN DWORD dwID,
  715. OUT BOOL & fValue,
  716. IN BOOL * pfInheritanceOverride = NULL,
  717. IN LPCTSTR lpszMDPath = NULL,
  718. OUT DWORD * pdwAttributes = NULL
  719. );
  720. //
  721. // Fetch a string
  722. //
  723. HRESULT QueryValue(
  724. IN DWORD dwID,
  725. OUT CString & strValue,
  726. IN BOOL * pfInheritanceOverride = NULL,
  727. IN LPCTSTR lpszMDPath = NULL,
  728. OUT DWORD * pdwAttributes = NULL
  729. );
  730. //
  731. // Fetch a CStrPassword
  732. //
  733. HRESULT QueryValue(
  734. IN DWORD dwID,
  735. OUT CStrPassword & strValue,
  736. IN BOOL * pfInheritanceOverride = NULL,
  737. IN LPCTSTR lpszMDPath = NULL,
  738. OUT DWORD * pdwAttributes = NULL
  739. );
  740. //
  741. // Fetch a BSTR
  742. //
  743. HRESULT QueryValue(
  744. IN DWORD dwID,
  745. OUT CComBSTR & strValue,
  746. IN BOOL * pfInheritanceOverride = NULL,
  747. IN LPCTSTR lpszMDPath = NULL,
  748. OUT DWORD * pdwAttributes = NULL
  749. );
  750. //
  751. // Fetch a string list
  752. //
  753. HRESULT QueryValue(
  754. IN DWORD dwID,
  755. OUT CStringListEx & strlValue,
  756. IN BOOL * pfInheritanceOverride = NULL,
  757. IN LPCTSTR lpszMDPath = NULL,
  758. OUT DWORD * pdwAttributes = NULL
  759. );
  760. //
  761. // Fetch binary blob
  762. //
  763. HRESULT QueryValue(
  764. IN DWORD dwID,
  765. OUT CBlob & blValue,
  766. IN BOOL * pfInheritanceOverride = NULL,
  767. IN LPCTSTR lpszMDPath = NULL,
  768. OUT DWORD * pdwAttributes = NULL
  769. );
  770. //
  771. // Store a DWORD
  772. //
  773. HRESULT SetValue(
  774. IN DWORD dwID,
  775. IN DWORD dwValue,
  776. IN BOOL * pfInheritanceOverride = NULL,
  777. IN LPCTSTR lpszMDPath = NULL
  778. );
  779. //
  780. // Store a BOOL
  781. //
  782. HRESULT SetValue(
  783. IN DWORD dwID,
  784. IN BOOL fValue,
  785. IN BOOL * pfInheritanceOverride = NULL,
  786. IN LPCTSTR lpszMDPath = NULL
  787. );
  788. //
  789. // Store a string
  790. //
  791. HRESULT SetValue(
  792. IN DWORD dwID,
  793. IN CString & strValue,
  794. IN BOOL * pfInheritanceOverride = NULL,
  795. IN LPCTSTR lpszMDPath = NULL
  796. );
  797. //
  798. // Store a StrPassword
  799. //
  800. HRESULT SetValue(
  801. IN DWORD dwID,
  802. IN CStrPassword & strValue,
  803. IN BOOL * pfInheritanceOverride = NULL,
  804. IN LPCTSTR lpszMDPath = NULL
  805. );
  806. //
  807. // Store a BSTR
  808. //
  809. HRESULT SetValue(
  810. IN DWORD dwID,
  811. IN CComBSTR & strValue,
  812. IN BOOL * pfInheritanceOverride = NULL,
  813. IN LPCTSTR lpszMDPath = NULL
  814. );
  815. //
  816. // Store a stringlist
  817. //
  818. HRESULT SetValue(
  819. IN DWORD dwID,
  820. IN CStringListEx & strlValue,
  821. IN BOOL * pfInheritanceOverride = NULL,
  822. IN LPCTSTR lpszMDPath = NULL
  823. );
  824. //
  825. // Store a binary blob
  826. //
  827. HRESULT SetValue(
  828. IN DWORD dwID,
  829. IN CBlob & blValue,
  830. IN BOOL * pfInheritanceOverride = NULL,
  831. IN LPCTSTR lpszMDPath = NULL
  832. );
  833. //
  834. // Delete Value:
  835. //
  836. HRESULT DeleteValue(
  837. IN DWORD dwID,
  838. IN LPCTSTR lpszMDPath = NULL
  839. );
  840. //
  841. // Check for path existance
  842. //
  843. HRESULT DoesPathExist(
  844. IN LPCTSTR lpszMDPath
  845. );
  846. //
  847. // Create current path (which we attempted to open, and got
  848. // a path not found error on).
  849. //
  850. HRESULT CreatePathFromFailedOpen();
  851. //
  852. // Check for descendant overrides
  853. //
  854. HRESULT CheckDescendants(
  855. IN DWORD dwID,
  856. IN CComAuthInfo * pServer,
  857. IN LPCTSTR lpszMDPath = NULL
  858. );
  859. //
  860. // Open key
  861. //
  862. HRESULT Open(
  863. IN DWORD dwFlags,
  864. IN LPCTSTR lpszMDPath = NULL,
  865. IN METADATA_HANDLE hkBase = METADATA_MASTER_ROOT_HANDLE
  866. );
  867. //
  868. // Re-open previously opened key
  869. //
  870. HRESULT ReOpen(
  871. IN DWORD dwFlags
  872. );
  873. //
  874. // As above using the same permissions as before
  875. //
  876. HRESULT ReOpen();
  877. //
  878. // Open the parent object
  879. //
  880. HRESULT ConvertToParentPath(
  881. IN BOOL fImmediate
  882. );
  883. //
  884. // Close key, set it to NULL, but doesn't destroy the interface
  885. //
  886. HRESULT Close();
  887. //
  888. // Add key
  889. //
  890. HRESULT AddKey(
  891. IN LPCTSTR lpszMDPath
  892. );
  893. //
  894. // Delete key off currently open key
  895. //
  896. HRESULT DeleteKey(
  897. IN LPCTSTR lpszMDPath
  898. );
  899. //
  900. // Rename key off currently open key
  901. //
  902. HRESULT RenameKey(
  903. IN LPCTSTR lpszMDPath,
  904. IN LPCTSTR lpszNewName
  905. );
  906. //
  907. // Get list of descendant nodes that override
  908. // a specific value
  909. //
  910. HRESULT GetDataPaths(
  911. OUT CStringListEx & strlNodes,
  912. IN DWORD dwMDIdentifier,
  913. IN DWORD dwMDDataType,
  914. IN LPCTSTR lpszMDPath = NULL
  915. );
  916. HRESULT GetChildPaths(
  917. CStringListEx & strlValue,
  918. LPCTSTR lpszMDPath = NULL
  919. );
  920. //
  921. // Access
  922. //
  923. public:
  924. METADATA_HANDLE GetHandle() const { return m_hKey; }
  925. METADATA_HANDLE GetBase() const { return m_hBase; }
  926. LPCTSTR QueryMetaPath() const { return m_strMetaPath; }
  927. DWORD QueryFlags() const { return m_dwFlags; }
  928. BOOL IsOpen() const { return m_hKey != NULL; }
  929. BOOL IsHomeDirectoryPath() const ;
  930. //
  931. // Conversion operators
  932. //
  933. public:
  934. operator METADATA_HANDLE() const { return GetHandle(); }
  935. operator LPCTSTR() const { return QueryMetaPath(); }
  936. operator BOOL() const { return IsOpen(); }
  937. //
  938. // Virtual Interface:
  939. //
  940. public:
  941. virtual BOOL Succeeded() const;
  942. virtual HRESULT QueryResult() const;
  943. //
  944. // Protected members
  945. //
  946. protected:
  947. //
  948. // Get data
  949. //
  950. HRESULT GetPropertyValue(
  951. IN DWORD dwID,
  952. OUT IN DWORD & dwSize,
  953. OUT IN void *& pvData,
  954. OUT IN DWORD * pdwDataType = NULL,
  955. IN BOOL * pfInheritanceOverride = NULL,
  956. IN LPCTSTR lpszMDPath = NULL,
  957. OUT DWORD * pdwAttributes = NULL
  958. );
  959. //
  960. // Store data
  961. //
  962. HRESULT SetPropertyValue(
  963. IN DWORD dwID,
  964. IN DWORD dwSize,
  965. IN void * pvData,
  966. IN BOOL * pfInheritanceOverride = NULL,
  967. IN LPCTSTR lpszMDPath = NULL
  968. );
  969. //
  970. // Get All Data off the open key
  971. //
  972. HRESULT GetAllData(
  973. IN DWORD dwMDAttributes,
  974. IN DWORD dwMDUserType,
  975. IN DWORD dwMDDataType,
  976. OUT DWORD * pdwMDNumEntries,
  977. OUT DWORD * pdwMDDataLen,
  978. OUT PBYTE * ppbMDData,
  979. IN LPCTSTR lpszMDPath = NULL
  980. );
  981. //
  982. // Property Table Methods
  983. //
  984. public:
  985. //
  986. // Metabase table entry definition
  987. //
  988. typedef struct tagMDFIELDDEF
  989. {
  990. DWORD dwMDIdentifier;
  991. DWORD dwMDAttributes;
  992. DWORD dwMDUserType;
  993. DWORD dwMDDataType;
  994. UINT uStringID;
  995. } MDFIELDDEF;
  996. protected:
  997. static const MDFIELDDEF s_rgMetaTable[];
  998. static const int s_MetaTableSize;
  999. //
  1000. // CODEWORK: Ideally, these should be protected, but are used
  1001. // by idlg.
  1002. //
  1003. public:
  1004. static BOOL GetMDFieldDef(
  1005. DWORD dwID,
  1006. DWORD & dwMDIdentifier,
  1007. DWORD & dwMDAttributes,
  1008. DWORD & dwMDUserType,
  1009. DWORD & dwMDDataType
  1010. );
  1011. //
  1012. // Map metabase ID value to table index
  1013. //
  1014. static int MapMDIDToTableIndex(DWORD dwID);
  1015. static const CMetaKey::MDFIELDDEF * CMetaKey::GetMetaProp(DWORD id);
  1016. //
  1017. // Allow limited access to the table
  1018. //
  1019. public:
  1020. static BOOL IsPropertyInheritable(DWORD dwID);
  1021. static BOOL GetPropertyDescription(DWORD dwID, CString & strName);
  1022. protected:
  1023. BOOL m_fAllowRootOperations;
  1024. BOOL m_fOwnKey;
  1025. DWORD m_cbInitialBufferSize;
  1026. DWORD m_dwFlags;
  1027. HRESULT m_hrKey;
  1028. CString m_strMetaPath;
  1029. METADATA_HANDLE m_hKey;
  1030. METADATA_HANDLE m_hBase;
  1031. };
  1032. class COMDLL CWamInterface : public CIISInterface
  1033. /*++
  1034. Class description:
  1035. WAM interface class
  1036. Virtual Interface:
  1037. Succeeded : Return TRUE if item constructed successfully
  1038. QueryResult : Return construction error code
  1039. Public Interface:
  1040. SupportsPooledProc : Check to see if pooled out of proc is supported.
  1041. --*/
  1042. {
  1043. //
  1044. // App Protection States:
  1045. //
  1046. public:
  1047. enum
  1048. {
  1049. //
  1050. // Note: order must match MD_APP_ISOLATED values
  1051. //
  1052. APP_INPROC,
  1053. APP_OUTOFPROC,
  1054. APP_POOLEDPROC,
  1055. };
  1056. //
  1057. // Constructor/Destructor
  1058. //
  1059. public:
  1060. //
  1061. // Destructor destroys the interface
  1062. //
  1063. virtual ~CWamInterface();
  1064. protected:
  1065. //
  1066. // Fully defined constructor that creates the interface.
  1067. // Use NULL to create the interface on the local computer
  1068. //
  1069. CWamInterface(
  1070. IN CComAuthInfo * pServer
  1071. );
  1072. //
  1073. // Construct from existing interface.
  1074. //
  1075. CWamInterface(
  1076. IN CWamInterface * pInterface
  1077. );
  1078. //
  1079. // Access
  1080. //
  1081. public:
  1082. BOOL SupportsPooledProc() const { return m_fSupportsPooledProc; }
  1083. HRESULT GetAppAdminInterface(IIISApplicationAdmin ** pp);
  1084. protected:
  1085. virtual HRESULT ApplyProxyBlanket();
  1086. //
  1087. // Create a wam object in this server. This function initializes the
  1088. // object with DCOM.
  1089. //
  1090. HRESULT Create();
  1091. //
  1092. // Make sure the interface has been created
  1093. //
  1094. BOOL HasInterface() const { return m_pInterface != NULL; }
  1095. //
  1096. // IWAM Interface
  1097. //
  1098. protected:
  1099. HRESULT AppCreate(
  1100. IN LPCTSTR szMDPath,
  1101. IN DWORD dwAppProtection
  1102. );
  1103. HRESULT AppDelete(
  1104. IN LPCTSTR szMDPath,
  1105. IN BOOL fRecursive
  1106. );
  1107. HRESULT AppUnLoad(
  1108. IN LPCTSTR szMDPath,
  1109. IN BOOL fRecursive
  1110. );
  1111. HRESULT AppGetStatus(
  1112. IN LPCTSTR szMDPath,
  1113. OUT DWORD * pdwAppStatus
  1114. );
  1115. HRESULT AppDeleteRecoverable(
  1116. IN LPCTSTR szMDPath,
  1117. IN BOOL fRecursive
  1118. );
  1119. HRESULT AppRecover(
  1120. IN LPCTSTR szMDPath,
  1121. IN BOOL fRecursive
  1122. );
  1123. //
  1124. // IIISApplicationAdmin interface
  1125. //
  1126. HRESULT CreateApplication(
  1127. LPCWSTR szMDPath,
  1128. DWORD dwAppMode,
  1129. LPCWSTR szAppPoolId,
  1130. BOOL fCreatePool
  1131. );
  1132. HRESULT DeleteApplication(
  1133. LPCWSTR szMDPath,
  1134. BOOL fRecursive
  1135. );
  1136. HRESULT CreateApplicationPool(
  1137. LPCWSTR szMDPath
  1138. );
  1139. HRESULT DeleteApplicationPool(
  1140. LPCWSTR szMDPath
  1141. );
  1142. HRESULT RecycleApplicationPool(
  1143. LPCWSTR szMDPath
  1144. );
  1145. HRESULT EnumerateApplicationsInPool(
  1146. LPCWSTR szMDPath,
  1147. BSTR *pbstr
  1148. );
  1149. HRESULT GetProcessMode(
  1150. DWORD * pdwMode
  1151. );
  1152. protected:
  1153. IWamAdmin * m_pInterface;
  1154. private:
  1155. BOOL m_fSupportsPooledProc;
  1156. };
  1157. class COMDLL CMetaBack : public CMetaInterface, public CWamInterface
  1158. /*++
  1159. Class Description:
  1160. Metabase backup/restore class
  1161. Virtual Interface:
  1162. Succeeded : Return TRUE if item constructed successfully
  1163. QueryResult : Return construction error code
  1164. Public Interface:
  1165. Reset : Enum first existing backup
  1166. Next : Enum next existing backup
  1167. NextHistory : Enum next existing history backup
  1168. Backup : Create new backup
  1169. Delete : Delete existing backup
  1170. Restore : Restore from existing backup
  1171. RestoreHistoryBackup: Restore from existing history
  1172. --*/
  1173. {
  1174. public:
  1175. //
  1176. // Construct and create the interfaces. Use NULL to create
  1177. // on the local computer.
  1178. //
  1179. CMetaBack(
  1180. IN CComAuthInfo * pServer
  1181. );
  1182. //
  1183. // Virtual Interface
  1184. //
  1185. public:
  1186. virtual BOOL Succeeded() const;
  1187. virtual HRESULT QueryResult() const;
  1188. //
  1189. // Interface
  1190. //
  1191. public:
  1192. //
  1193. // Reset counter
  1194. //
  1195. void Reset() { m_dwIndex = 0L; }
  1196. HRESULT Next(
  1197. OUT DWORD * pdwVersion,
  1198. OUT LPTSTR lpszLocation,
  1199. OUT FILETIME * pftBackupTime
  1200. );
  1201. HRESULT NextHistory(
  1202. OUT DWORD * pdwMDMajorVersion,
  1203. OUT DWORD * pdwMDMinorVersion,
  1204. OUT LPTSTR lpszLocation,
  1205. OUT FILETIME * pftBackupTime
  1206. );
  1207. HRESULT Backup(
  1208. IN LPCTSTR lpszLocation
  1209. );
  1210. HRESULT BackupWithPassword(
  1211. IN LPCTSTR lpszLocation,
  1212. IN LPCTSTR lpszPassword
  1213. );
  1214. HRESULT Delete(
  1215. IN LPCTSTR lpszLocation,
  1216. IN DWORD dwVersion
  1217. );
  1218. HRESULT Restore(
  1219. IN LPCTSTR lpszLocation,
  1220. IN DWORD dwVersion
  1221. );
  1222. HRESULT RestoreWithPassword(
  1223. IN LPCTSTR lpszLocation,
  1224. IN DWORD dwVersion,
  1225. IN LPCTSTR lpszPassword
  1226. );
  1227. HRESULT RestoreHistoryBackup(
  1228. IN LPCTSTR pszMDHistoryLocation,
  1229. IN DWORD dwMDMajorVersion,
  1230. IN DWORD dwMDMinorVersion,
  1231. IN DWORD dwMDFlags
  1232. );
  1233. protected:
  1234. virtual HRESULT ApplyProxyBlanket();
  1235. protected:
  1236. static const LPCTSTR s_szMasterAppRoot;
  1237. private:
  1238. DWORD m_dwIndex;
  1239. };
  1240. class COMDLL CMetaEnumerator : public CMetaKey
  1241. /*++
  1242. Class Description:
  1243. Metabase key enumerator
  1244. Public Interface:
  1245. CMetaEnumerator : Constructor
  1246. Reset : Reset the enumerator
  1247. Next : Get next key
  1248. --*/
  1249. {
  1250. public:
  1251. //
  1252. // Constructor creates a new interface and opens a key
  1253. //
  1254. CMetaEnumerator(
  1255. IN CComAuthInfo * pServer,
  1256. IN LPCTSTR lpszMDPath = NULL,
  1257. IN METADATA_HANDLE hkBase = METADATA_MASTER_ROOT_HANDLE
  1258. );
  1259. //
  1260. // Constructor which uses an existing interface and opens
  1261. // a new key
  1262. //
  1263. CMetaEnumerator(
  1264. IN CMetaInterface * pInterface,
  1265. IN LPCTSTR lpszMDPath = NULL,
  1266. IN METADATA_HANDLE hkBase = METADATA_MASTER_ROOT_HANDLE
  1267. );
  1268. //
  1269. // Constructor which uses an open key
  1270. //
  1271. CMetaEnumerator(
  1272. IN BOOL fOwnKey,
  1273. IN CMetaKey * pKey
  1274. );
  1275. //
  1276. // Interface:
  1277. //
  1278. public:
  1279. //
  1280. // Reset counter
  1281. //
  1282. void Reset() { m_dwIndex = 0L; }
  1283. //
  1284. // Get next key as string.
  1285. //
  1286. HRESULT Next(
  1287. OUT CString & strKey,
  1288. IN LPCTSTR lpszMDPath = NULL
  1289. );
  1290. //
  1291. // Get next key as a DWORD (numeric keys only)
  1292. //
  1293. HRESULT Next(
  1294. OUT DWORD & dwKey,
  1295. OUT CString & strKey,
  1296. IN LPCTSTR lpszMDPath = NULL
  1297. );
  1298. private:
  1299. DWORD m_dwIndex;
  1300. };
  1301. class COMDLL CIISApplication : public CWamInterface, public CMetaKey
  1302. /*++
  1303. Class Description:
  1304. IIS Application class
  1305. Virtual Interface:
  1306. Succeeded : Return TRUE if item constructed successfully
  1307. QueryResult : Return construction error code
  1308. Public Interface:
  1309. RefreshState : Refresh application state
  1310. QueryAppState : Return current application state
  1311. IsEnabledApplication: Return TRUE if appplication is enabled.
  1312. Create : Create app
  1313. Delete : Delete app
  1314. Unload : Unload app
  1315. DeleteRecoverable : Delete w. recovery allowed
  1316. Recover : Recover
  1317. WriteFriendlyName : Write friendly name to metabase
  1318. --*/
  1319. {
  1320. //
  1321. // Constructor/Destructor
  1322. //
  1323. public:
  1324. CIISApplication(
  1325. IN CComAuthInfo * pServer,
  1326. IN LPCTSTR lpszMetapath
  1327. );
  1328. //
  1329. // Virtual Interface:
  1330. //
  1331. public:
  1332. virtual BOOL Succeeded() const;
  1333. virtual HRESULT QueryResult() const;
  1334. //
  1335. // Interface
  1336. //
  1337. public:
  1338. DWORD QueryAppState() const { return m_dwAppState; }
  1339. LPCTSTR QueryWamPath() const { return m_strWamPath; }
  1340. BOOL IsEnabledApplication() const;
  1341. HRESULT RefreshAppState();
  1342. HRESULT Create(LPCTSTR lpszName, DWORD dwAppProtection);
  1343. HRESULT CreatePooled(LPCTSTR lpszName, DWORD dwAppMode,
  1344. LPCTSTR pool_id, BOOL fCreatePool = FALSE);
  1345. HRESULT Delete(BOOL fRecursive = FALSE);
  1346. HRESULT Unload(BOOL fRecursive = FALSE);
  1347. HRESULT DeleteRecoverable(BOOL fRecursive = FALSE);
  1348. HRESULT Recover(BOOL fRecursive = FALSE);
  1349. HRESULT WriteFriendlyName(LPCTSTR lpszName);
  1350. HRESULT WritePoolId(LPCTSTR id);
  1351. public:
  1352. BOOL IsInproc() const { return m_dwProcessProtection == APP_INPROC; }
  1353. BOOL IsOutOfProc() const { return m_dwProcessProtection == APP_OUTOFPROC; }
  1354. BOOL IsPooledProc() const { return m_dwProcessProtection == APP_POOLEDPROC; }
  1355. public:
  1356. DWORD m_dwProcessProtection;
  1357. CString m_strAppPoolId;
  1358. CString m_strFriendlyName;
  1359. CString m_strAppRoot;
  1360. protected:
  1361. void CommonConstruct();
  1362. private:
  1363. DWORD m_dwAppState;
  1364. CString m_strWamPath;
  1365. HRESULT m_hrApp;
  1366. };
  1367. class COMDLL CIISAppPool : public CWamInterface, public CMetaKey
  1368. {
  1369. public:
  1370. CIISAppPool(
  1371. IN CComAuthInfo * pServer,
  1372. IN LPCTSTR lpszMetapath = NULL
  1373. );
  1374. //
  1375. // Virtual Interface:
  1376. //
  1377. public:
  1378. virtual BOOL Succeeded() const;
  1379. virtual HRESULT QueryResult() const;
  1380. //
  1381. // Interface
  1382. //
  1383. public:
  1384. HRESULT RefreshState();
  1385. DWORD QueryPoolState() const { return m_dwPoolState; }
  1386. LPCTSTR QueryWamPath() const { return m_strWamPath; }
  1387. HRESULT Create(LPCTSTR lpszName = NULL);
  1388. HRESULT Delete(LPCTSTR id);
  1389. HRESULT Recycle(LPCTSTR id);
  1390. HRESULT GetProcessMode(DWORD * pdwMode);
  1391. HRESULT WriteFriendlyName(LPCTSTR lpszName);
  1392. HRESULT EnumerateApplications(CStringListEx& list);
  1393. public:
  1394. CString m_strAppPoolId;
  1395. private:
  1396. DWORD m_dwPoolState;
  1397. CString m_strWamPath;
  1398. HRESULT m_hrPool;
  1399. };
  1400. class COMDLL CIISSvcControl : public CIISInterface
  1401. /*++
  1402. Class description:
  1403. IIS Service control
  1404. Virtual Interface:
  1405. Succeeded : Return TRUE if item constructed successfully
  1406. QueryResult : Return construction error code
  1407. --*/
  1408. {
  1409. //
  1410. // Constructor/Destructor
  1411. //
  1412. public:
  1413. //
  1414. // Fully defined constructor that creates the interface.
  1415. // Use NULL to create the interface on the local computer
  1416. //
  1417. CIISSvcControl(
  1418. IN CComAuthInfo * pServer
  1419. );
  1420. //
  1421. // Construct from existing interface.
  1422. //
  1423. CIISSvcControl(
  1424. IN CIISSvcControl * pInterface
  1425. );
  1426. //
  1427. // Destructor destroys the interface
  1428. //
  1429. virtual ~CIISSvcControl();
  1430. protected:
  1431. //
  1432. // Create an object in this server. This function initializes the
  1433. // object with DCOM.
  1434. //
  1435. HRESULT Create();
  1436. //
  1437. // Make sure the interface has been created
  1438. //
  1439. BOOL HasInterface() const { return m_pInterface != NULL; }
  1440. //
  1441. // Interface
  1442. //
  1443. public:
  1444. //
  1445. // Stop services
  1446. //
  1447. HRESULT Stop(
  1448. IN DWORD dwTimeoutMsecs,
  1449. IN BOOL fForce
  1450. );
  1451. //
  1452. // Start services
  1453. //
  1454. HRESULT Start(
  1455. IN DWORD dwTimeoutMsecs
  1456. );
  1457. //
  1458. // Reboot
  1459. //
  1460. HRESULT Reboot(
  1461. IN DWORD dwTimeouMsecs,
  1462. IN BOOL fForceAppsClosed
  1463. );
  1464. //
  1465. // Status
  1466. //
  1467. HRESULT Status(
  1468. IN DWORD dwBufferSize,
  1469. OUT LPBYTE pbBuffer,
  1470. OUT DWORD * MDRequiredBufferSize,
  1471. OUT DWORD * pdwNumServices
  1472. );
  1473. //
  1474. // Kill
  1475. //
  1476. HRESULT Kill();
  1477. protected:
  1478. virtual HRESULT ApplyProxyBlanket();
  1479. protected:
  1480. IIisServiceControl * m_pInterface;
  1481. };
  1482. //
  1483. // Inline Expansion
  1484. //
  1485. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1486. inline void CComAuthInfo::StorePassword(LPCOLESTR lpszPassword)
  1487. {
  1488. m_bstrPassword = lpszPassword;
  1489. }
  1490. inline /* virtual */ HRESULT CIISInterface::ChangeProxyBlanket(
  1491. IN LPCOLESTR lpszUserName,
  1492. IN LPCOLESTR lpszPassword
  1493. )
  1494. {
  1495. m_auth.SetImpersonation(lpszUserName, lpszPassword);
  1496. return ApplyProxyBlanket();
  1497. }
  1498. inline /*static */ LPCTSTR CMetabasePath::GetMachinePath(
  1499. IN LPCTSTR lpszMDPath,
  1500. OUT CString & strNewPath,
  1501. OUT CString * pstrRemainder
  1502. )
  1503. {
  1504. return TruncatePath(iMachine, lpszMDPath, strNewPath, pstrRemainder);
  1505. }
  1506. inline /* static */ LPCTSTR CMetabasePath::GetServicePath(
  1507. IN LPCTSTR lpszMDPath,
  1508. OUT CString & strNewPath,
  1509. OUT CString * pstrRemainder
  1510. )
  1511. {
  1512. return TruncatePath(iService, lpszMDPath, strNewPath, pstrRemainder);
  1513. }
  1514. inline /* static */ LPCTSTR CMetabasePath::GetInstancePath(
  1515. IN LPCTSTR lpszMDPath,
  1516. OUT CString & strNewPath,
  1517. OUT CString * pstrRemainder
  1518. )
  1519. {
  1520. return TruncatePath(iInstance, lpszMDPath, strNewPath, pstrRemainder);
  1521. }
  1522. inline /* static */ LPCTSTR CMetabasePath::GetRootPath(
  1523. IN LPCTSTR lpszMDPath,
  1524. OUT CString & strNewPath,
  1525. OUT CString * pstrRemainder
  1526. )
  1527. {
  1528. return TruncatePath(iRootDirectory, lpszMDPath, strNewPath, pstrRemainder);
  1529. }
  1530. inline HRESULT CMetaInterface::Create()
  1531. {
  1532. return CIISInterface::Create(
  1533. 1,
  1534. &IID_IMSAdminBase,
  1535. &CLSID_MSAdminBase,
  1536. NULL,
  1537. (IUnknown **)&m_pInterface
  1538. );
  1539. }
  1540. inline /* virtual */ HRESULT CMetaInterface::ApplyProxyBlanket()
  1541. {
  1542. return m_auth.ApplyProxyBlanket(m_pInterface);
  1543. }
  1544. inline HRESULT CMetaInterface::OpenKey(
  1545. IN METADATA_HANDLE hkBase,
  1546. IN LPCTSTR lpszMDPath,
  1547. IN DWORD dwFlags,
  1548. OUT METADATA_HANDLE * phMDNewHandle
  1549. )
  1550. {
  1551. ASSERT_PTR(m_pInterface);
  1552. ASSURE_PROPER_INTERFACE();
  1553. return m_pInterface->OpenKey(
  1554. hkBase,
  1555. lpszMDPath,
  1556. dwFlags,
  1557. m_iTimeOutValue,
  1558. phMDNewHandle
  1559. );
  1560. }
  1561. inline HRESULT CMetaInterface::CloseKey(
  1562. IN METADATA_HANDLE hKey
  1563. )
  1564. {
  1565. ASSERT_PTR(m_pInterface);
  1566. ASSURE_PROPER_INTERFACE();
  1567. return m_pInterface->CloseKey(hKey);
  1568. }
  1569. inline HRESULT CMetaInterface::SetLastChangeTime(
  1570. IN METADATA_HANDLE hMDHandle,
  1571. IN LPCTSTR pszMDPath,
  1572. IN FILETIME * pftMDLastChangeTime,
  1573. IN BOOL bLocalTime
  1574. )
  1575. {
  1576. ASSERT_PTR(m_pInterface);
  1577. ASSURE_PROPER_INTERFACE();
  1578. return m_pInterface->SetLastChangeTime(
  1579. hMDHandle,
  1580. pszMDPath,
  1581. pftMDLastChangeTime,
  1582. bLocalTime
  1583. );
  1584. }
  1585. inline HRESULT CMetaInterface::GetLastChangeTime(
  1586. IN METADATA_HANDLE hMDHandle,
  1587. IN LPCTSTR lpszMDPath,
  1588. OUT FILETIME * pftMDLastChangeTime,
  1589. IN BOOL bLocalTime
  1590. )
  1591. {
  1592. ASSERT_PTR(m_pInterface);
  1593. ASSURE_PROPER_INTERFACE();
  1594. return m_pInterface->GetLastChangeTime(
  1595. hMDHandle,
  1596. lpszMDPath,
  1597. pftMDLastChangeTime,
  1598. bLocalTime
  1599. );
  1600. }
  1601. inline HRESULT CMetaInterface::AddKey(
  1602. IN METADATA_HANDLE hKey,
  1603. IN LPCTSTR lpszMDPath
  1604. )
  1605. {
  1606. ASSERT_PTR(m_pInterface);
  1607. ASSURE_PROPER_INTERFACE();
  1608. return m_pInterface->AddKey(hKey, lpszMDPath);
  1609. }
  1610. inline HRESULT CMetaInterface::DeleteKey(
  1611. IN METADATA_HANDLE hKey,
  1612. IN LPCTSTR lpszMDPath
  1613. )
  1614. {
  1615. ASSERT_PTR(m_pInterface);
  1616. ASSURE_PROPER_INTERFACE();
  1617. return m_pInterface->DeleteKey(hKey, lpszMDPath);
  1618. }
  1619. inline HRESULT CMetaInterface::DeleteChildKeys(
  1620. IN METADATA_HANDLE hKey,
  1621. IN LPCTSTR lpszMDPath
  1622. )
  1623. {
  1624. ASSERT_PTR(m_pInterface);
  1625. ASSURE_PROPER_INTERFACE();
  1626. return m_pInterface->DeleteChildKeys(hKey, lpszMDPath);
  1627. }
  1628. inline HRESULT CMetaInterface::EnumKeys(
  1629. IN METADATA_HANDLE hKey,
  1630. IN LPCTSTR lpszMDPath,
  1631. OUT LPTSTR lpszMDName,
  1632. IN DWORD dwIndex
  1633. )
  1634. {
  1635. ASSERT_PTR(m_pInterface);
  1636. ASSURE_PROPER_INTERFACE();
  1637. return m_pInterface->EnumKeys(hKey, lpszMDPath, lpszMDName, dwIndex);
  1638. }
  1639. inline HRESULT CMetaInterface::CopyKey(
  1640. IN METADATA_HANDLE hSourceKey,
  1641. IN LPCTSTR lpszMDSourcePath,
  1642. IN METADATA_HANDLE hDestKey,
  1643. IN LPCTSTR lpszMDDestPath,
  1644. IN BOOL fOverwrite,
  1645. IN BOOL fCopy
  1646. )
  1647. {
  1648. ASSERT_PTR(m_pInterface);
  1649. ASSURE_PROPER_INTERFACE();
  1650. return m_pInterface->CopyKey(
  1651. hSourceKey,
  1652. lpszMDSourcePath,
  1653. hDestKey,
  1654. lpszMDDestPath,
  1655. fOverwrite,
  1656. fCopy
  1657. );
  1658. }
  1659. inline HRESULT CMetaInterface::RenameKey(
  1660. IN METADATA_HANDLE hKey,
  1661. IN LPCTSTR lpszMDPath,
  1662. IN LPCTSTR lpszNewName
  1663. )
  1664. {
  1665. ASSERT_PTR(m_pInterface);
  1666. ASSURE_PROPER_INTERFACE();
  1667. return m_pInterface->RenameKey(hKey, lpszMDPath, lpszNewName);
  1668. }
  1669. inline HRESULT CMetaInterface::GetData(
  1670. IN METADATA_HANDLE hKey,
  1671. IN LPCTSTR lpszMDPath,
  1672. OUT METADATA_RECORD * pmdRecord,
  1673. OUT DWORD * pdwRequiredDataLen
  1674. )
  1675. {
  1676. ASSERT_PTR(m_pInterface);
  1677. ASSURE_PROPER_INTERFACE();
  1678. return m_pInterface->GetData(
  1679. hKey,
  1680. lpszMDPath,
  1681. pmdRecord,
  1682. pdwRequiredDataLen
  1683. );
  1684. }
  1685. inline HRESULT CMetaInterface::SetData(
  1686. IN METADATA_HANDLE hKey,
  1687. IN LPCTSTR lpszMDPath,
  1688. IN METADATA_RECORD * pmdRecord
  1689. )
  1690. {
  1691. ASSERT_PTR(m_pInterface);
  1692. ASSURE_PROPER_INTERFACE();
  1693. return m_pInterface->SetData(
  1694. hKey,
  1695. lpszMDPath,
  1696. pmdRecord
  1697. );
  1698. }
  1699. inline HRESULT CMetaInterface::DeleteData(
  1700. IN METADATA_HANDLE hKey,
  1701. IN LPCTSTR lpszMDPath,
  1702. IN DWORD dwMDIdentifier,
  1703. IN DWORD dwMDDataType
  1704. )
  1705. {
  1706. ASSERT_PTR(m_pInterface);
  1707. ASSURE_PROPER_INTERFACE();
  1708. return m_pInterface->DeleteData(
  1709. hKey,
  1710. lpszMDPath,
  1711. dwMDIdentifier,
  1712. dwMDDataType
  1713. );
  1714. }
  1715. inline HRESULT CMetaInterface::EnumData(
  1716. IN METADATA_HANDLE hKey,
  1717. IN LPCTSTR lpszMDPath,
  1718. OUT METADATA_RECORD * pmdRecord,
  1719. IN DWORD dwIndex,
  1720. OUT DWORD * pdwRequiredDataLen
  1721. )
  1722. {
  1723. ASSERT_PTR(m_pInterface);
  1724. ASSURE_PROPER_INTERFACE();
  1725. return m_pInterface->EnumData(
  1726. hKey,
  1727. lpszMDPath,
  1728. pmdRecord,
  1729. dwIndex,
  1730. pdwRequiredDataLen
  1731. );
  1732. }
  1733. inline HRESULT CMetaInterface::GetAllData(
  1734. IN METADATA_HANDLE hKey,
  1735. IN LPCTSTR lpszMDPath,
  1736. IN DWORD dwMDAttributes,
  1737. IN DWORD dwMDUserType,
  1738. IN DWORD dwMDDataType,
  1739. OUT DWORD * pdwMDNumDataEntries,
  1740. OUT DWORD * pdwMDDataSetNumber,
  1741. IN DWORD dwMDBufferSize,
  1742. OUT LPBYTE pbMDBuffer,
  1743. OUT DWORD * pdwRequiredBufferSize
  1744. )
  1745. {
  1746. ASSERT_PTR(m_pInterface);
  1747. ASSURE_PROPER_INTERFACE();
  1748. return m_pInterface->GetAllData(
  1749. hKey,
  1750. lpszMDPath,
  1751. dwMDAttributes,
  1752. dwMDUserType,
  1753. dwMDDataType,
  1754. pdwMDNumDataEntries,
  1755. pdwMDDataSetNumber,
  1756. dwMDBufferSize,
  1757. pbMDBuffer,
  1758. pdwRequiredBufferSize
  1759. );
  1760. }
  1761. inline HRESULT CMetaInterface::DeleteAllData(
  1762. IN METADATA_HANDLE hKey,
  1763. IN LPCTSTR lpszMDPath,
  1764. IN DWORD dwMDUserType,
  1765. IN DWORD dwMDDataType
  1766. )
  1767. {
  1768. ASSERT_PTR(m_pInterface);
  1769. ASSURE_PROPER_INTERFACE();
  1770. return m_pInterface->DeleteAllData(
  1771. hKey,
  1772. lpszMDPath,
  1773. dwMDUserType,
  1774. dwMDDataType
  1775. );
  1776. }
  1777. inline HRESULT CMetaInterface::CopyData(
  1778. IN METADATA_HANDLE hMDSourceKey,
  1779. IN LPCTSTR lpszMDSourcePath,
  1780. IN METADATA_HANDLE hMDDestKey,
  1781. IN LPCTSTR lpszMDDestPath,
  1782. IN DWORD dwMDAttributes,
  1783. IN DWORD dwMDUserType,
  1784. IN DWORD dwMDDataType,
  1785. IN BOOL fCopy
  1786. )
  1787. {
  1788. ASSERT_PTR(m_pInterface);
  1789. ASSURE_PROPER_INTERFACE();
  1790. return m_pInterface->CopyData(
  1791. hMDSourceKey,
  1792. lpszMDSourcePath,
  1793. hMDDestKey,
  1794. lpszMDDestPath,
  1795. dwMDAttributes,
  1796. dwMDUserType,
  1797. dwMDDataType,
  1798. fCopy
  1799. );
  1800. }
  1801. inline HRESULT CMetaInterface::GetDataPaths(
  1802. IN METADATA_HANDLE hKey,
  1803. IN LPCTSTR lpszMDPath,
  1804. IN DWORD dwMDIdentifier,
  1805. IN DWORD dwMDDataType,
  1806. IN DWORD dwMDBufferSize,
  1807. OUT LPTSTR lpszBuffer,
  1808. OUT DWORD * pdwMDRequiredBufferSize
  1809. )
  1810. {
  1811. ASSERT_PTR(m_pInterface);
  1812. ASSURE_PROPER_INTERFACE();
  1813. return m_pInterface->GetDataPaths(
  1814. hKey,
  1815. lpszMDPath,
  1816. dwMDIdentifier,
  1817. dwMDDataType,
  1818. dwMDBufferSize,
  1819. lpszBuffer,
  1820. pdwMDRequiredBufferSize
  1821. );
  1822. }
  1823. inline HRESULT CMetaInterface::Backup(
  1824. IN LPCTSTR lpszBackupLocation,
  1825. IN DWORD dwMDVersion,
  1826. IN DWORD dwMDFlags
  1827. )
  1828. {
  1829. ASSERT_PTR(m_pInterface);
  1830. ASSURE_PROPER_INTERFACE();
  1831. return m_pInterface->Backup(lpszBackupLocation, dwMDVersion, dwMDFlags);
  1832. }
  1833. inline HRESULT CMetaInterface::Restore(
  1834. IN LPCTSTR lpszBackupLocation,
  1835. IN DWORD dwMDVersion,
  1836. IN DWORD dwMDFlags
  1837. )
  1838. {
  1839. ASSERT_PTR(m_pInterface);
  1840. ASSURE_PROPER_INTERFACE();
  1841. return m_pInterface->Restore(lpszBackupLocation, dwMDVersion, dwMDFlags);
  1842. }
  1843. inline HRESULT CMetaInterface::EnumBackups(
  1844. OUT LPTSTR lpszBackupLocation,
  1845. OUT DWORD * pdwMDVersion,
  1846. OUT FILETIME * pftMDBackupTime,
  1847. IN DWORD dwIndex
  1848. )
  1849. {
  1850. ASSERT_PTR(m_pInterface);
  1851. ASSURE_PROPER_INTERFACE();
  1852. return m_pInterface->EnumBackups(
  1853. lpszBackupLocation,
  1854. pdwMDVersion,
  1855. pftMDBackupTime,
  1856. dwIndex
  1857. );
  1858. }
  1859. inline HRESULT CMetaInterface::DeleteBackup(
  1860. IN LPCTSTR lpszBackupLocation,
  1861. IN DWORD dwMDVersion
  1862. )
  1863. {
  1864. ASSERT_PTR(m_pInterface);
  1865. ASSURE_PROPER_INTERFACE();
  1866. return m_pInterface->DeleteBackup(lpszBackupLocation, dwMDVersion);
  1867. }
  1868. inline HRESULT CMetaInterface::SaveData()
  1869. {
  1870. ASSERT_PTR(m_pInterface);
  1871. ASSURE_PROPER_INTERFACE();
  1872. return m_pInterface->SaveData();
  1873. }
  1874. inline HRESULT CMetaInterface::GetSystemChangeNumber(
  1875. OUT DWORD * pdwChangeNumber
  1876. )
  1877. {
  1878. ASSERT_PTR(m_pInterface);
  1879. ASSURE_PROPER_INTERFACE();
  1880. return m_pInterface->GetSystemChangeNumber(pdwChangeNumber);
  1881. }
  1882. inline HRESULT CMetaKey::AddKey(
  1883. IN LPCTSTR lpszMDPath
  1884. )
  1885. {
  1886. return CMetaInterface::AddKey(m_hKey, lpszMDPath);
  1887. }
  1888. inline HRESULT CMetaKey::DeleteKey(
  1889. IN LPCTSTR lpszMDPath
  1890. )
  1891. {
  1892. return CMetaInterface::DeleteKey(m_hKey, lpszMDPath);
  1893. }
  1894. inline HRESULT CMetaKey::RenameKey(
  1895. IN LPCTSTR lpszMDPath,
  1896. IN LPCTSTR lpszNewName
  1897. )
  1898. {
  1899. return CMetaInterface::RenameKey(m_hKey, lpszMDPath, lpszNewName);
  1900. }
  1901. inline HRESULT CMetaKey::ReOpen()
  1902. {
  1903. return Open(m_dwFlags, m_strMetaPath, m_hBase);
  1904. }
  1905. inline HRESULT CMetaKey::ReOpen(DWORD dwFlags)
  1906. {
  1907. return Open(dwFlags, m_strMetaPath, m_hBase);
  1908. }
  1909. inline BOOL CMetaKey::IsHomeDirectoryPath() const
  1910. {
  1911. return CMetabasePath::IsHomeDirectoryPath(m_strMetaPath);
  1912. }
  1913. inline HRESULT CMetaKey::QueryValue(
  1914. IN DWORD dwID,
  1915. OUT BOOL & fValue,
  1916. IN BOOL * pfInheritanceOverride,
  1917. IN LPCTSTR lpszMDPath,
  1918. OUT DWORD * pdwAttributes
  1919. )
  1920. {
  1921. ASSERT(sizeof(DWORD) == sizeof(BOOL));
  1922. return CMetaKey::QueryValue(
  1923. dwID,
  1924. (DWORD &)fValue,
  1925. pfInheritanceOverride,
  1926. lpszMDPath,
  1927. pdwAttributes
  1928. );
  1929. }
  1930. inline HRESULT CMetaKey::SetValue(
  1931. IN DWORD dwID,
  1932. IN DWORD dwValue,
  1933. IN BOOL * pfInheritanceOverride, OPTIONAL
  1934. IN LPCTSTR lpszMDPath OPTIONAL
  1935. )
  1936. {
  1937. return SetPropertyValue(
  1938. dwID,
  1939. sizeof(dwValue),
  1940. &dwValue,
  1941. pfInheritanceOverride,
  1942. lpszMDPath
  1943. );
  1944. }
  1945. inline HRESULT CMetaKey::SetValue(
  1946. IN DWORD dwID,
  1947. IN BOOL fValue,
  1948. IN BOOL * pfInheritanceOverride,
  1949. IN LPCTSTR lpszMDPath
  1950. )
  1951. {
  1952. ASSERT(sizeof(DWORD) == sizeof(BOOL));
  1953. return CMetaKey::SetValue(
  1954. dwID,
  1955. (DWORD)fValue,
  1956. pfInheritanceOverride,
  1957. lpszMDPath
  1958. );
  1959. }
  1960. inline HRESULT CMetaKey::SetValue(
  1961. IN DWORD dwID,
  1962. IN CString & strValue,
  1963. IN BOOL * pfInheritanceOverride, OPTIONAL
  1964. IN LPCTSTR lpszMDPath OPTIONAL
  1965. )
  1966. {
  1967. return SetPropertyValue(
  1968. dwID,
  1969. (strValue.GetLength() + 1) * sizeof(TCHAR),
  1970. (void *)(LPCTSTR)strValue,
  1971. pfInheritanceOverride,
  1972. lpszMDPath
  1973. );
  1974. }
  1975. inline HRESULT CWamInterface::AppDelete(
  1976. IN LPCTSTR szMDPath,
  1977. IN BOOL fRecursive
  1978. )
  1979. {
  1980. ASSERT_PTR(m_pInterface);
  1981. ASSURE_PROPER_INTERFACE();
  1982. return m_pInterface->AppDelete(szMDPath, fRecursive);
  1983. }
  1984. inline HRESULT CWamInterface::AppUnLoad(
  1985. IN LPCTSTR szMDPath,
  1986. IN BOOL fRecursive
  1987. )
  1988. {
  1989. ASSERT_PTR(m_pInterface);
  1990. ASSURE_PROPER_INTERFACE();
  1991. return m_pInterface->AppUnLoad(szMDPath, fRecursive);
  1992. }
  1993. inline HRESULT CWamInterface::AppGetStatus(
  1994. IN LPCTSTR szMDPath,
  1995. OUT DWORD * pdwAppStatus
  1996. )
  1997. {
  1998. ASSERT_PTR(m_pInterface);
  1999. ASSURE_PROPER_INTERFACE();
  2000. return m_pInterface->AppGetStatus(szMDPath, pdwAppStatus);
  2001. }
  2002. inline HRESULT CWamInterface::AppDeleteRecoverable(
  2003. IN LPCTSTR szMDPath,
  2004. IN BOOL fRecursive
  2005. )
  2006. {
  2007. ASSERT_PTR(m_pInterface);
  2008. ASSURE_PROPER_INTERFACE();
  2009. return m_pInterface->AppDeleteRecoverable(szMDPath, fRecursive);
  2010. }
  2011. inline HRESULT CWamInterface::AppRecover(
  2012. IN LPCTSTR szMDPath,
  2013. IN BOOL fRecursive
  2014. )
  2015. {
  2016. ASSERT_PTR(m_pInterface);
  2017. ASSURE_PROPER_INTERFACE();
  2018. return m_pInterface->AppRecover(szMDPath, fRecursive);
  2019. }
  2020. inline /* virtual */ HRESULT CWamInterface::ApplyProxyBlanket()
  2021. {
  2022. return m_auth.ApplyProxyBlanket(m_pInterface);
  2023. }
  2024. ////////////////////////////
  2025. inline /* virtual */ HRESULT CMetaBack::ApplyProxyBlanket()
  2026. {
  2027. HRESULT hr = CMetaInterface::ApplyProxyBlanket();
  2028. return SUCCEEDED(hr) ? CWamInterface::ApplyProxyBlanket() : hr;
  2029. }
  2030. inline HRESULT CMetaBack::Next(
  2031. OUT DWORD * pdwVersion,
  2032. OUT LPTSTR lpszLocation,
  2033. OUT FILETIME * pftBackupTime
  2034. )
  2035. {
  2036. return EnumBackups(
  2037. lpszLocation,
  2038. pdwVersion,
  2039. pftBackupTime,
  2040. m_dwIndex++
  2041. );
  2042. }
  2043. inline HRESULT CMetaBack::NextHistory(
  2044. OUT DWORD * pdwMDMajorVersion,
  2045. OUT DWORD * pdwMDMinorVersion,
  2046. OUT LPTSTR lpszLocation,
  2047. OUT FILETIME * pftBackupTime
  2048. )
  2049. {
  2050. return EnumHistory(
  2051. lpszLocation,
  2052. pdwMDMajorVersion,
  2053. pdwMDMinorVersion,
  2054. pftBackupTime,
  2055. m_dwIndex++
  2056. );
  2057. }
  2058. inline HRESULT CMetaBack::Backup(
  2059. IN LPCTSTR lpszLocation
  2060. )
  2061. {
  2062. return CMetaInterface::Backup(
  2063. lpszLocation,
  2064. MD_BACKUP_NEXT_VERSION,
  2065. MD_BACKUP_SAVE_FIRST
  2066. );
  2067. }
  2068. inline HRESULT CMetaBack::Delete(
  2069. IN LPCTSTR lpszLocation,
  2070. IN DWORD dwVersion
  2071. )
  2072. {
  2073. return DeleteBackup(lpszLocation, dwVersion);
  2074. }
  2075. inline HRESULT CMetaBack::RestoreHistoryBackup(
  2076. IN LPCTSTR pszMDHistoryLocation,
  2077. IN DWORD dwMDMajorVersion,
  2078. IN DWORD dwMDMinorVersion,
  2079. IN DWORD dwMDFlags
  2080. )
  2081. {
  2082. return RestoreHistory(
  2083. pszMDHistoryLocation,
  2084. dwMDMajorVersion,
  2085. dwMDMinorVersion,
  2086. dwMDFlags
  2087. );
  2088. }
  2089. inline BOOL CIISApplication::IsEnabledApplication() const
  2090. {
  2091. return m_dwAppState == APPSTATUS_STOPPED
  2092. || m_dwAppState == APPSTATUS_RUNNING;
  2093. }
  2094. inline HRESULT CIISApplication::Delete(
  2095. IN BOOL fRecursive
  2096. )
  2097. {
  2098. ASSERT(!m_strWamPath.IsEmpty());
  2099. return AppDelete(m_strWamPath, fRecursive);
  2100. }
  2101. inline HRESULT CIISApplication::Unload(
  2102. IN BOOL fRecursive
  2103. )
  2104. {
  2105. ASSERT(!m_strWamPath.IsEmpty());
  2106. return AppUnLoad(m_strWamPath, fRecursive);
  2107. }
  2108. inline HRESULT CIISApplication::DeleteRecoverable(
  2109. IN BOOL fRecursive
  2110. )
  2111. {
  2112. ASSERT(!m_strWamPath.IsEmpty());
  2113. return AppDeleteRecoverable(m_strWamPath, fRecursive);
  2114. }
  2115. inline HRESULT CIISApplication::Recover(
  2116. IN BOOL fRecursive
  2117. )
  2118. {
  2119. ASSERT(!m_strWamPath.IsEmpty());
  2120. return AppRecover(m_strWamPath, fRecursive);
  2121. }
  2122. inline HRESULT CIISSvcControl::Create()
  2123. {
  2124. return CIISInterface::Create(
  2125. 1,
  2126. &IID_IIisServiceControl,
  2127. &CLSID_IisServiceControl,
  2128. NULL,
  2129. (IUnknown **)&m_pInterface
  2130. );
  2131. }
  2132. inline HRESULT CIISSvcControl::Stop(
  2133. IN DWORD dwTimeoutMsecs,
  2134. IN BOOL fForce
  2135. )
  2136. {
  2137. ASSERT_PTR(m_pInterface);
  2138. ASSURE_PROPER_INTERFACE();
  2139. return m_pInterface->Stop(dwTimeoutMsecs, (DWORD)fForce);
  2140. }
  2141. inline HRESULT CIISSvcControl::Start(
  2142. IN DWORD dwTimeoutMsecs
  2143. )
  2144. {
  2145. ASSERT_PTR(m_pInterface);
  2146. ASSURE_PROPER_INTERFACE();
  2147. return m_pInterface->Start(dwTimeoutMsecs);
  2148. }
  2149. inline HRESULT CIISSvcControl::Reboot(
  2150. IN DWORD dwTimeouMsecs,
  2151. IN BOOL fForceAppsClosed
  2152. )
  2153. {
  2154. ASSERT_PTR(m_pInterface);
  2155. ASSURE_PROPER_INTERFACE();
  2156. return m_pInterface->Reboot(dwTimeouMsecs, (DWORD)fForceAppsClosed);
  2157. }
  2158. inline HRESULT CIISSvcControl::Status(
  2159. IN DWORD dwBufferSize,
  2160. OUT LPBYTE pbBuffer,
  2161. OUT DWORD * MDRequiredBufferSize,
  2162. OUT DWORD * pdwNumServices
  2163. )
  2164. {
  2165. ASSERT_PTR(m_pInterface);
  2166. ASSURE_PROPER_INTERFACE();
  2167. return m_pInterface->Status(
  2168. dwBufferSize,
  2169. pbBuffer,
  2170. MDRequiredBufferSize,
  2171. pdwNumServices
  2172. );
  2173. }
  2174. inline HRESULT CIISSvcControl::Kill()
  2175. {
  2176. ASSERT_PTR(m_pInterface);
  2177. ASSURE_PROPER_INTERFACE();
  2178. return m_pInterface->Kill();
  2179. }
  2180. inline /* virtual */ HRESULT CIISSvcControl::ApplyProxyBlanket()
  2181. {
  2182. return m_auth.ApplyProxyBlanket(m_pInterface);
  2183. }
  2184. #endif // _MDKEYS_H_