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.

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