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.

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