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.

2454 lines
50 KiB

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