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.

2120 lines
52 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. inetprop.h
  5. Abstract:
  6. Internet Properties base classes definitions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef _INETPROP_H_
  14. #define _INETPROP_H_
  15. //
  16. // CDialog parameters
  17. //
  18. #define USE_DEFAULT_CAPTION (0)
  19. //
  20. // InitializeAndFetch parameters
  21. //
  22. #define WITHOUT_INHERITANCE (FALSE)
  23. #define WITH_INHERITANCE (TRUE)
  24. //
  25. // SSL Port number to use if SSL is not enabled
  26. //
  27. #define SSL_NOT_ENABLED (0)
  28. //
  29. // Bandwidth and compression definitions
  30. //
  31. #define INFINITE_BANDWIDTH (0xffffffff)
  32. #define KILOBYTE (1024L)
  33. #define MEGABYTE (1024L * KILOBYTE)
  34. #define DEF_BANDWIDTH (1 * MEGABYTE)
  35. #define DEF_MAX_COMPDIR_SIZE (1 * MEGABYTE)
  36. //
  37. // Arbitrary help IDs for user browser dialogs
  38. //
  39. #define IDHELP_USRBROWSER (0x30000)
  40. #define IDHELP_MULT_USRBROWSER (0x30100)
  41. //
  42. // Attribute crackers
  43. //
  44. #define IS_VROOT(dwAttributes) ((dwAttributes & FILE_ATTRIBUTE_VIRTUAL_DIRECTORY) != 0)
  45. #define IS_DIR(dwAttributes) ((dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
  46. #define IS_FILE(dwAttributes) ((dwAttributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_VIRTUAL_DIRECTORY)) == 0)
  47. //
  48. // Metabase constants
  49. //
  50. COMDLL extern const LPCTSTR g_cszTemplates;
  51. COMDLL extern const LPCTSTR g_cszCompression;
  52. COMDLL extern const LPCTSTR g_cszMachine;
  53. COMDLL extern const LPCTSTR g_cszMimeMap;
  54. COMDLL extern const LPCTSTR g_cszRoot;
  55. COMDLL extern const LPCTSTR g_cszSep;
  56. COMDLL extern const TCHAR g_chSep;
  57. //
  58. // Utility Functions
  59. //
  60. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  61. //
  62. // Forward Definitions
  63. //
  64. class CIPAddress;
  65. BOOL COMDLL
  66. GetIUsrAccount(
  67. IN LPCTSTR lpszServer,
  68. IN CWnd * pParent,
  69. OUT CString & str
  70. );
  71. //
  72. // Build registry key name
  73. //
  74. COMDLL LPCTSTR
  75. GenerateRegistryKey(
  76. OUT CString & strBuffer,
  77. IN LPCTSTR lpszSubKey = NULL
  78. );
  79. //
  80. // Get server comment
  81. //
  82. COMDLL NET_API_STATUS
  83. GetInetComment(
  84. IN LPCTSTR lpwstrServer,
  85. IN DWORD dwServiceMask,
  86. IN DWORD dwInstance,
  87. IN int cchComment,
  88. OUT LPTSTR lpszComment
  89. );
  90. //
  91. // Get current service status
  92. //
  93. COMDLL NET_API_STATUS
  94. QueryInetServiceStatus(
  95. LPCTSTR lpszServer,
  96. LPCTSTR lpszService,
  97. int * pnState
  98. );
  99. //
  100. // Change service state
  101. //
  102. COMDLL NET_API_STATUS
  103. ChangeInetServiceState(
  104. IN LPCTSTR lpszServer,
  105. IN LPCTSTR lpszService,
  106. IN int nNewState,
  107. IN int * pnCurrentState
  108. );
  109. //
  110. // Determine if the given server name refers to the local machine
  111. //
  112. COMDLL BOOL
  113. IsServerLocal(
  114. IN LPCTSTR lpszServer
  115. );
  116. //
  117. // Determine the given server name exists on the network
  118. //
  119. COMDLL BOOL
  120. DoesServerExist(
  121. IN LPCTSTR lpszServer
  122. );
  123. //
  124. // Compare server name against the local machine
  125. // if local, return NULL. Otherwise return machine name
  126. //
  127. COMDLL LPCTSTR NormalizeServerName(
  128. IN LPCTSTR lpszServerName
  129. );
  130. //
  131. // Get volume information system flags for the given path
  132. //
  133. COMDLL BOOL GetVolumeInformationSystemFlags(
  134. IN LPCTSTR lpszPath,
  135. OUT DWORD * pdwSystemFlags
  136. );
  137. //
  138. // Alloc string using ISM allocator
  139. //
  140. COMDLL LPTSTR
  141. ISMAllocString(
  142. IN CString & str
  143. );
  144. //
  145. // Determine if the currently logged-in user us an administrator
  146. // or operator in the virtual server provided
  147. //
  148. COMDLL DWORD
  149. DetermineIfAdministrator(
  150. IN CMetaInterface * pInterface,
  151. IN LPCTSTR lpszService,
  152. IN DWORD dwInstance,
  153. OUT BOOL* pfAdministrator
  154. );
  155. //
  156. // Utility classes
  157. //
  158. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  159. class COMDLL CBlob
  160. /*++
  161. Class Description:
  162. Binary large object class, which owns its pointer
  163. Public Interface:
  164. CBlob : Constructors
  165. ~CBlob : Destructor
  166. SetValue : Assign the value
  167. GetSize : Get the byte size
  168. GetData : Get pointer to the byte stream
  169. --*/
  170. {
  171. //
  172. // Constructors/Destructor
  173. //
  174. public:
  175. //
  176. // Initialize empty blob
  177. //
  178. CBlob();
  179. //
  180. // Initialize with binary data
  181. //
  182. CBlob(
  183. IN DWORD dwSize,
  184. IN PBYTE pbItem,
  185. IN BOOL fMakeCopy = TRUE
  186. );
  187. //
  188. // Copy constructor
  189. //
  190. CBlob(IN const CBlob & blob);
  191. //
  192. // Destructor destroys the pointer
  193. //
  194. ~CBlob();
  195. //
  196. // Operators
  197. //
  198. public:
  199. CBlob & operator =(const CBlob & blob);
  200. BOOL operator ==(const CBlob & blob) const;
  201. BOOL operator !=(const CBlob & blob) const { return !operator ==(blob); }
  202. //
  203. // Access
  204. //
  205. public:
  206. //
  207. // Clean up internal data
  208. //
  209. void CleanUp();
  210. //
  211. // Set the current value of the blob
  212. //
  213. void SetValue(
  214. IN DWORD dwSize,
  215. IN PBYTE pbItem,
  216. IN BOOL fMakeCopy = TRUE
  217. );
  218. //
  219. // TRUE if the blob is currently empty
  220. //
  221. BOOL IsEmpty() const { return m_dwSize == 0L; }
  222. //
  223. // Return the size of the blob in bytes
  224. //
  225. DWORD GetSize() const { return m_dwSize; }
  226. //
  227. // Get a pointer to the byte stream
  228. //
  229. PBYTE GetData();
  230. private:
  231. DWORD m_dwSize;
  232. PBYTE m_pbItem;
  233. };
  234. class CMaskedDWORD
  235. /*++
  236. Class Description:
  237. A masked DWORD class. This class performs assignments and comparison
  238. on a masked range of the DWORD value. For example, if a mask of
  239. 0x000000FF is set, any comparisons or assignments will only involve
  240. the least significant byte. A comparison against another DWORD will
  241. only compare that least significant byte, and an assignment will only
  242. set the least significant byte, leaving the rest untouched.
  243. Public Interface:
  244. CMaskedDWORD : Constructor
  245. operator == : Comparison operator
  246. operator != : Comparison operator
  247. operator = : Assignment operator
  248. operator DWORD : Cast to the value
  249. void SetMask : Set the mask
  250. --*/
  251. {
  252. //
  253. // Constructor/Destructor
  254. //
  255. public:
  256. CMaskedDWORD(
  257. IN DWORD dwValue = 0L,
  258. IN DWORD dwMask = 0xFFFFFFFF
  259. )
  260. : m_dwValue(dwValue),
  261. m_dwMask(dwMask)
  262. {
  263. }
  264. public:
  265. BOOL operator ==(DWORD dwValue) const;
  266. BOOL operator !=(DWORD dwValue) const { return !(operator ==(dwValue)); }
  267. CMaskedDWORD & operator =(DWORD dwValue);
  268. operator DWORD() const { return m_dwValue; }
  269. operator DWORD &() { return m_dwValue; }
  270. void SetMask(DWORD dwMask) { m_dwMask = dwMask; }
  271. private:
  272. DWORD m_dwValue;
  273. DWORD m_dwMask;
  274. };
  275. //
  276. // Forward Definitions
  277. //
  278. class CIPAddress;
  279. template <class TYPE, class ARG_TYPE>
  280. class CMPProp
  281. {
  282. public:
  283. CMPProp(ARG_TYPE value);
  284. CMPProp();
  285. operator ARG_TYPE() const;
  286. CMPProp<TYPE, ARG_TYPE> & operator =(ARG_TYPE value);
  287. BOOL m_fDirty;
  288. TYPE m_value;
  289. };
  290. template <class TYPE, class ARG_TYPE>
  291. inline CMPProp<TYPE, ARG_TYPE>::CMPProp(ARG_TYPE value)
  292. : m_value(value),
  293. m_fDirty(FALSE)
  294. {
  295. }
  296. template <class TYPE, class ARG_TYPE>
  297. inline CMPProp<TYPE, ARG_TYPE>::CMPProp()
  298. : m_value(),
  299. m_fDirty(FALSE)
  300. {
  301. }
  302. template <class TYPE, class ARG_TYPE>
  303. inline CMPProp<TYPE, ARG_TYPE>::operator ARG_TYPE() const
  304. {
  305. return (ARG_TYPE)m_value;
  306. }
  307. template <class TYPE, class ARG_TYPE>
  308. inline CMPProp<TYPE, ARG_TYPE> & CMPProp<TYPE, ARG_TYPE>::operator =(ARG_TYPE value)
  309. {
  310. if (m_value != value)
  311. {
  312. m_value = value;
  313. m_fDirty = TRUE;
  314. }
  315. return *this;
  316. }
  317. //
  318. // MP Access (use operators where possible!)
  319. //
  320. #define MP_V(x) (x.m_value)
  321. #define MP_D(x) (x.m_fDirty)
  322. //
  323. // Common property types
  324. //
  325. typedef CMPProp<CBlob, CBlob&> MP_CBlob;
  326. typedef CMPProp<CString, LPCTSTR> MP_CString;
  327. typedef CMPProp<CStringListEx, CStringListEx &> MP_CStringListEx;
  328. typedef CMPProp<CILong, LONG> MP_CILong;
  329. typedef CMPProp<int, int> MP_int;
  330. typedef CMPProp<DWORD, DWORD> MP_DWORD;
  331. typedef CMPProp<BOOL, BOOL> MP_BOOL;
  332. typedef CMPProp<CMaskedDWORD, DWORD> MP_CMaskedDWORD;
  333. //
  334. // CODEWORK: Turns these into proper methods
  335. //
  336. #define BEGIN_META_WRITE()\
  337. { \
  338. HRESULT hr = S_OK; \
  339. do \
  340. { \
  341. m_dwaDirtyProps.RemoveAll(); \
  342. #define META_WRITE(id, value)\
  343. if(MP_D(value)) \
  344. { \
  345. if (!IsOpen()) \
  346. { \
  347. hr = OpenForWriting(); \
  348. if (FAILED(hr)) break; \
  349. } \
  350. hr = SetValue(id, MP_V(value)); \
  351. if (FAILED(hr)) break; \
  352. MP_D(value) = FALSE; \
  353. m_dwaDirtyProps.AddTail(id); \
  354. } \
  355. #define META_WRITE_INHERITANCE(id, value, foverride)\
  356. if(MP_D(value)) \
  357. { \
  358. if (!IsOpen()) \
  359. { \
  360. hr = OpenForWriting(); \
  361. if (FAILED(hr)) break; \
  362. } \
  363. hr = SetValue(id, MP_V(value), &foverride);\
  364. if (FAILED(hr)) break; \
  365. MP_D(value) = FALSE; \
  366. m_dwaDirtyProps.AddTail(id); \
  367. } \
  368. #define META_DELETE(id)\
  369. FlagPropertyForDeletion(id); \
  370. #define END_META_WRITE(err)\
  371. POSITION pos; \
  372. pos = m_dwaDeletedProps.GetHeadPosition();\
  373. while(pos != NULL) \
  374. { \
  375. DWORD dwID = m_dwaDeletedProps.GetNext(pos);\
  376. if (!IsOpen()) \
  377. { \
  378. hr = OpenForWriting(FALSE); \
  379. if (SUCCEEDED(hr)) \
  380. { \
  381. TRACEEOLID("Deleting #" << dwID);\
  382. hr = DeleteValue(dwID); \
  383. m_dwaDirtyProps.AddTail(dwID); \
  384. } \
  385. } \
  386. } \
  387. m_dwaDeletedProps.RemoveAll(); \
  388. if (IsOpen()) Close(); \
  389. pos = m_dwaDirtyProps.GetHeadPosition();\
  390. hr = S_OK; \
  391. while(pos != NULL) \
  392. { \
  393. hr = CheckDescendants(m_dwaDirtyProps.GetNext(pos), m_strServerName, m_strMetaRoot); \
  394. if (FAILED(hr)) break; \
  395. } \
  396. } \
  397. while(FALSE); \
  398. err = hr; \
  399. }
  400. //
  401. // Binding helper macros. Place calls that allow rebinding
  402. // between these blocks
  403. //
  404. #define BEGIN_ASSURE_BINDING_SECTION\
  405. { \
  406. BOOL fRepeat; \
  407. do \
  408. { \
  409. fRepeat = FALSE; \
  410. #define END_ASSURE_BINDING_SECTION(err, pInterface, CANCEL_ERROR)\
  411. if (err.Win32Error() == RPC_S_SERVER_UNAVAILABLE) \
  412. { \
  413. err = COMDLL_RebindInterface( \
  414. pInterface, \
  415. &fRepeat, \
  416. CANCEL_ERROR \
  417. ); \
  418. } \
  419. } \
  420. while(fRepeat); \
  421. }
  422. /* ABSTRACT */ class COMDLL CMetaProperties : public CMetaKey
  423. /*++
  424. Class Description:
  425. Abstract base class that reads all metadata at a specific
  426. metabase path.
  427. Public Interface:
  428. QueryResult : Get result code from construction
  429. QueryMetaPath : Get the metabase path
  430. Virtual Interface:
  431. ParseFields : Break up data into member variables
  432. --*/
  433. {
  434. //
  435. // Constructor/Destructor
  436. //
  437. protected:
  438. //
  439. // Constructor which creates new interface
  440. //
  441. CMetaProperties(
  442. IN LPCTSTR lpszServerName,
  443. IN LPCTSTR lpszService = NULL,
  444. IN DWORD dwInstance = MASTER_INSTANCE,
  445. IN LPCTSTR lpszParentPath = NULL,
  446. IN LPCTSTR lpszAlias = NULL
  447. );
  448. //
  449. // Construct with existing interface
  450. //
  451. CMetaProperties(
  452. IN const CMetaInterface * pInterface,
  453. IN LPCTSTR lpszService = NULL,
  454. IN DWORD dwInstance = MASTER_INSTANCE,
  455. IN LPCTSTR lpszParentPath = NULL,
  456. IN LPCTSTR lpszAlias = NULL
  457. );
  458. //
  459. // Construct with open key
  460. //
  461. CMetaProperties(
  462. IN const CMetaKey * pKey,
  463. IN LPCTSTR lpszMDPath
  464. );
  465. //
  466. // Construct with open key (specifically for instances)
  467. //
  468. CMetaProperties(
  469. IN const CMetaKey * pKey,
  470. IN DWORD dwPath
  471. );
  472. //
  473. // Destructor
  474. //
  475. ~CMetaProperties();
  476. public:
  477. //
  478. // GetAllData()
  479. //
  480. virtual HRESULT LoadData();
  481. virtual HRESULT WriteDirtyProps();
  482. void FlagPropertyForDeletion(DWORD dwID);
  483. virtual HRESULT CMetaProperties::QueryResult() const;
  484. LPCTSTR QueryMetaRoot() const { return m_strMetaRoot; }
  485. protected:
  486. //
  487. // Call derived class
  488. //
  489. /* PURE */ virtual void ParseFields() = 0;
  490. //
  491. // Clean up
  492. //
  493. void Cleanup();
  494. //
  495. // Open for writing. Optionally creates the path
  496. //
  497. HRESULT OpenForWriting(BOOL fCreate = TRUE);
  498. protected:
  499. BOOL m_fInherit;
  500. HRESULT m_hResult;
  501. CString m_strMetaRoot;
  502. DWORD m_dwMDUserType;
  503. DWORD m_dwMDDataType;
  504. CList<DWORD, DWORD> m_dwaDirtyProps;
  505. CList<DWORD, DWORD> m_dwaDeletedProps;
  506. //
  507. // Read all values
  508. //
  509. DWORD m_dwNumEntries;
  510. DWORD m_dwMDDataLen;
  511. PBYTE m_pbMDData;
  512. };
  513. //
  514. // Machine Properties object
  515. //
  516. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  517. class CMachineProps : public CMetaProperties
  518. /*++
  519. Class Description:
  520. Global machine properties
  521. Public Interface:
  522. CMachineProps : Constructor
  523. WriteDirtyProps : Write dirty properties
  524. --*/
  525. {
  526. public:
  527. CMachineProps(
  528. IN LPCTSTR lpszServerName
  529. );
  530. CMachineProps(
  531. IN const CMetaInterface * pInterface
  532. );
  533. public:
  534. //
  535. // Write Data if dirty
  536. //
  537. HRESULT WriteDirtyProps();
  538. protected:
  539. virtual void ParseFields();
  540. public:
  541. MP_CILong m_nMaxNetworkUse;
  542. };
  543. //
  544. // Compression Properties Object
  545. //
  546. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  547. class COMDLL CIISCompressionProps : public CMetaProperties
  548. /*++
  549. Class Description:
  550. Compression settings
  551. Public Interface:
  552. CIISCompressionProps : Constructor
  553. WriteIfDirty : Write data if dirty
  554. --*/
  555. {
  556. public:
  557. CIISCompressionProps(
  558. IN LPCTSTR lpszServerName,
  559. IN LPCTSTR lpszService = SZ_MBN_WEB,
  560. IN DWORD dwInstance = MASTER_INSTANCE,
  561. IN LPCTSTR lpszParent = NULL,
  562. IN LPCTSTR lpszAlias = NULL
  563. );
  564. public:
  565. //
  566. // Write Data if dirty
  567. //
  568. virtual HRESULT WriteDirtyProps();
  569. //
  570. // Load data
  571. //
  572. virtual HRESULT LoadData();
  573. public:
  574. MP_BOOL m_fEnableStaticCompression;
  575. MP_BOOL m_fEnableDynamicCompression;
  576. MP_BOOL m_fLimitDirectorySize;
  577. MP_DWORD m_dwDirectorySize;
  578. MP_CString m_strDirectory;
  579. protected:
  580. virtual void ParseFields();
  581. private:
  582. BOOL m_fPathDoesNotExist;
  583. };
  584. class COMDLL CMimeTypes : public CMetaProperties
  585. /*++
  586. Class Description:
  587. A list of mime types.
  588. Public Interface:
  589. CMimeTypes : Constructor
  590. WriteIfDirty : Write properties if dirty
  591. --*/
  592. {
  593. public:
  594. //
  595. // Constructor that creates new interface
  596. //
  597. CMimeTypes(
  598. LPCTSTR lpszServerName,
  599. LPCTSTR lpszService = NULL,
  600. DWORD dwInstance = MASTER_INSTANCE,
  601. LPCTSTR lpszParent = NULL,
  602. LPCTSTR lpszAlias = NULL
  603. );
  604. //
  605. // Constructor that uses an existing interface
  606. //
  607. CMimeTypes(
  608. IN const CMetaInterface * pInterface,
  609. LPCTSTR lpszService = NULL,
  610. DWORD dwInstance = MASTER_INSTANCE,
  611. LPCTSTR lpszParent = NULL,
  612. LPCTSTR lpszAlias = NULL
  613. );
  614. public:
  615. //
  616. // Write the data;
  617. //
  618. virtual HRESULT WriteDirtyProps();
  619. protected:
  620. virtual void ParseFields();
  621. public:
  622. MP_CStringListEx m_strlMimeTypes;
  623. };
  624. class COMDLL CServerCapabilities : public CMetaProperties
  625. /*++
  626. Class Description:
  627. Server capabilities object
  628. Public Interface:
  629. CServerCapabilities : Constructor
  630. --*/
  631. {
  632. public:
  633. //
  634. // Constructor
  635. //
  636. CServerCapabilities(
  637. IN LPCTSTR lpszServerName,
  638. IN LPCTSTR lpszService = NULL,
  639. IN DWORD dwInstance = MASTER_INSTANCE
  640. );
  641. public:
  642. BOOL IsSSLSupported() const { return (m_dwCapabilities & IIS_CAP1_SSL_SUPPORT) != 0L; }
  643. BOOL IsSSL128Supported() const { return (m_dwConfiguration & MD_SERVER_CONFIG_SSL_128) != 0L; }
  644. BOOL HasMultipleSites() const { return (m_dwCapabilities & IIS_CAP1_MULTIPLE_INSTANCE) != 0L; }
  645. BOOL HasBwThrottling() const { return (m_dwCapabilities & IIS_CAP1_BW_THROTTLING) != 0L; }
  646. BOOL Has10ConnectionLimit() const { return (m_dwCapabilities & IIS_CAP1_10_CONNECTION_LIMIT) != 0L; }
  647. BOOL HasIPAccessCheck() const { return (m_dwCapabilities & IIS_CAP1_IP_ACCESS_CHECK) != 0L; }
  648. BOOL HasOperatorList() const { return (m_dwCapabilities & IIS_CAP1_OPERATORS_LIST) != 0L; }
  649. BOOL HasFrontPage() const { return (m_dwCapabilities & IIS_CAP1_FP_INSTALLED) != 0L; }
  650. BOOL HasCompression() const { return (m_dwCapabilities & IIS_CAP1_SERVER_COMPRESSION) != 0L; }
  651. BOOL HasCPUThrottling() const { return (m_dwCapabilities & IIS_CAP1_CPU_AUDITING) != 0L; }
  652. BOOL HasDAV() const { return (m_dwCapabilities & IIS_CAP1_DAV) != 0L; }
  653. BOOL HasDigest() const { return (m_dwCapabilities & IIS_CAP1_DIGEST_SUPPORT) != 0L; }
  654. BOOL HasNTCertMapper() const { return (m_dwCapabilities & IIS_CAP1_NT_CERTMAP_SUPPORT) != 0L; }
  655. DWORD QueryMajorVersion() const { return m_dwVersionMajor; }
  656. DWORD QueryMinorVersion() const { return m_dwVersionMinor; }
  657. protected:
  658. virtual void ParseFields();
  659. private:
  660. //
  661. // Capabilities fields
  662. //
  663. MP_DWORD m_dwPlatform;
  664. MP_DWORD m_dwVersionMajor;
  665. MP_DWORD m_dwVersionMinor;
  666. MP_DWORD m_dwCapabilities;
  667. MP_DWORD m_dwConfiguration;
  668. };
  669. class COMDLL CInstanceProps : public CMetaProperties
  670. /*++
  671. Class Description:
  672. Generic instance properties. Construct with lightweight = TRUE
  673. to fetch enough information for enumeration only.
  674. Public Interface:
  675. CInstanceProps: : Constructor
  676. Add : static method to create new instance
  677. Remove : static method to remove instance
  678. ChangeState : Change the state of a property
  679. QueryError : Get the win32 error
  680. GetDisplayText : Generate display name of instance
  681. FillInstanceInfo : Fill ISMINSTANCE_INFO struct
  682. --*/
  683. {
  684. public:
  685. //
  686. // Public method to convert instance info to display text
  687. //
  688. static LPCTSTR GetDisplayText(
  689. OUT CString & strName,
  690. IN LPCTSTR szComment,
  691. IN LPCTSTR szHostHeaderName,
  692. IN LPCTSTR szServiceName,
  693. IN CIPAddress & ia,
  694. IN UINT uPort,
  695. IN DWORD dwID
  696. );
  697. public:
  698. //
  699. // Constructor that creates an interface
  700. //
  701. CInstanceProps(
  702. IN LPCTSTR lpszServerName,
  703. IN LPCTSTR lpszService, // e.g. "W3SVC"
  704. IN DWORD dwInstance = MASTER_INSTANCE,
  705. IN UINT nDefPort = 0U
  706. );
  707. //
  708. // Constructor that reuses existing interface
  709. //
  710. CInstanceProps(
  711. IN const CMetaInterface * pInterface,
  712. IN LPCTSTR lpszService, // e.g. "W3SVC"
  713. IN DWORD dwInstance = MASTER_INSTANCE,
  714. IN UINT nDefPort = 0U
  715. );
  716. //
  717. // Constructor that uses an open parent key,
  718. // open at the service level
  719. //
  720. CInstanceProps(
  721. IN CMetaKey * pKey,
  722. IN DWORD dwInstance = MASTER_INSTANCE,
  723. IN UINT nDefPort = 0U
  724. );
  725. public:
  726. //
  727. // Parse the binding string into component parts
  728. //
  729. static void CrackBinding(
  730. IN CString lpszBinding,
  731. OUT CIPAddress & iaIpAddress,
  732. OUT UINT & nTCPPort,
  733. OUT CString & strDomainName
  734. );
  735. //
  736. // Parse the secure binding string into component parts
  737. //
  738. static void CrackSecureBinding(
  739. IN CString lpszBinding,
  740. OUT CIPAddress & iaIpAddress,
  741. OUT UINT & nSSLPort
  742. );
  743. //
  744. // Find the SSL port applicable to the given
  745. // IP Address. Return the index where this SSL port
  746. // was found, or -1 if it was not found.
  747. //
  748. static int FindMatchingSecurePort(
  749. IN CStringList & strlBindings,
  750. IN CIPAddress & iaIpAddress,
  751. OUT UINT & m_nSSLPort
  752. );
  753. //
  754. // Find ip address/port combo
  755. //
  756. static BOOL IsPortInUse(
  757. IN CStringList & strlBindings,
  758. IN CIPAddress & iaIPAddress,
  759. IN UINT nPort
  760. );
  761. //
  762. // Build binding string
  763. //
  764. static void BuildBinding(
  765. OUT CString & strBinding,
  766. IN CIPAddress & iaIpAddress,
  767. IN UINT & nTCPPort,
  768. IN CString & lpszDomainName
  769. );
  770. //
  771. // Build secure binding string
  772. //
  773. static void BuildSecureBinding(
  774. OUT CString & strBinding,
  775. IN CIPAddress & iaIpAddress,
  776. IN UINT & nSSLPort
  777. );
  778. //
  779. // Create new instance
  780. //
  781. static HRESULT Add(
  782. IN const CMetaInterface * pInterface,
  783. IN LPCTSTR lpszService,
  784. IN LPCTSTR lpszHomePath,
  785. IN LPCTSTR lpszUserName = NULL,
  786. IN LPCTSTR lpszPassword = NULL,
  787. IN LPCTSTR lpszDescription = NULL,
  788. IN LPCTSTR lpszBinding = NULL,
  789. IN LPCTSTR lpszSecureBinding = NULL,
  790. IN DWORD * pdwPermissions = NULL,
  791. IN DWORD * pdwDirBrowsing = NULL,
  792. IN DWORD * pwdAuthFlags = NULL,
  793. OUT DWORD * pdwInstance = NULL
  794. );
  795. //
  796. // Remove existing instance
  797. //
  798. static HRESULT Delete(
  799. IN const CMetaInterface * pInterface,
  800. IN LPCTSTR lpszService,
  801. IN DWORD dwInstance
  802. );
  803. //
  804. // Access
  805. //
  806. public:
  807. //
  808. // Change the running state of the instance
  809. //
  810. HRESULT ChangeState(
  811. IN int nNewState // INet definition
  812. );
  813. //
  814. // Get the WIN32 error
  815. //
  816. DWORD QueryError() const { return m_dwWin32Error; }
  817. //
  818. // Get the instance number
  819. //
  820. DWORD QueryInstance() const { return m_dwInstance; }
  821. //
  822. // Check to see if this is a deletable instance
  823. //
  824. BOOL IsDeletable() const { return !m_fNotDeletable; }
  825. //
  826. // Check to see if this is a cluster enabled instance
  827. //
  828. BOOL IsClusterEnabled() const { return m_fCluster; }
  829. //
  830. // Get ISM state value
  831. //
  832. int QueryISMState() const { return m_nISMState; }
  833. //
  834. // Get the friendly name for this instance
  835. //
  836. LPCTSTR GetDisplayText(
  837. OUT CString & strName,
  838. IN LPCTSTR szServiceName
  839. );
  840. //
  841. // Fill instance info structure
  842. //
  843. void FillInstanceInfo(
  844. OUT ISMINSTANCEINFO * pii,
  845. IN DWORD dwError = ERROR_SUCCESS
  846. );
  847. //
  848. // Get the complete metabase path to the home directory
  849. //
  850. LPCTSTR GetHomePath(OUT CString & str);
  851. //
  852. // Write Data if dirty
  853. //
  854. virtual HRESULT WriteDirtyProps();
  855. protected:
  856. virtual void ParseFields();
  857. //
  858. // Helper to convert state constants
  859. //
  860. void SetISMStateFromServerState();
  861. public:
  862. DWORD m_dwInstance;
  863. public:
  864. //
  865. // Meta values
  866. //
  867. MP_BOOL m_fNotDeletable;
  868. MP_BOOL m_fCluster;
  869. MP_CStringListEx m_strlBindings;
  870. MP_CString m_strComment;
  871. MP_DWORD m_dwState;
  872. MP_DWORD m_dwWin32Error;
  873. //
  874. // Derived Values
  875. //
  876. UINT m_nTCPPort;
  877. CIPAddress m_iaIpAddress;
  878. CString m_strDomainName;
  879. int m_nISMState;
  880. };
  881. class COMDLL CChildNodeProps : public CMetaProperties
  882. {
  883. /*++
  884. Class Description:
  885. Generic child node properties. Could be a vdir, a dir
  886. or a file.
  887. Public Interface:
  888. CChildNodeProps : Constructor
  889. Add : Create new virtual directory
  890. Delete : Delete virtual directory
  891. Rename : Rename virtual directory
  892. QueryError : Get the win32 error
  893. IsPathInherited : Return TRUE if the path was inherited
  894. FillInstanceInfo : Fill instance info structure
  895. FillChildInfo : Fill child info structure
  896. --*/
  897. public:
  898. //
  899. // Constructors
  900. //
  901. CChildNodeProps(
  902. IN LPCTSTR lpszServerName,
  903. IN LPCTSTR lpszService,
  904. IN DWORD dwInstance = MASTER_INSTANCE,
  905. IN LPCTSTR lpszParent = NULL,
  906. IN LPCTSTR lpszAlias = NULL,
  907. IN BOOL fInherit = WITHOUT_INHERITANCE,
  908. IN BOOL fPathOnly = FALSE
  909. );
  910. CChildNodeProps(
  911. IN const CMetaInterface * pInterface,
  912. IN LPCTSTR lpszService,
  913. IN DWORD dwInstance = MASTER_INSTANCE,
  914. IN LPCTSTR lpszParent = NULL,
  915. IN LPCTSTR lpszAlias = NULL,
  916. IN BOOL fInherit = WITHOUT_INHERITANCE,
  917. IN BOOL fPathOnly = FALSE
  918. );
  919. CChildNodeProps(
  920. IN const CMetaKey * pKey,
  921. IN LPCTSTR lpszPath = NULL,
  922. IN BOOL fInherit = WITHOUT_INHERITANCE,
  923. IN BOOL fPathOnly = FALSE
  924. );
  925. public:
  926. //
  927. // Create new virtual directory
  928. //
  929. static HRESULT Add(
  930. IN const CMetaInterface * pInterface,
  931. IN LPCTSTR lpszService,
  932. IN DWORD dwInstance,
  933. IN LPCTSTR lpszParentPath,
  934. IN LPCTSTR lpszAlias,
  935. OUT CString & strAliasCreated,
  936. IN DWORD * pdwPermissions = NULL,
  937. IN DWORD * pdwDirBrowsing = NULL,
  938. IN LPCTSTR lpszVrPath = NULL,
  939. IN LPCTSTR lpszUserName = NULL,
  940. IN LPCTSTR lpszPassword = NULL,
  941. IN BOOL fExactName = TRUE
  942. );
  943. //
  944. // Delete virtual directory
  945. //
  946. static HRESULT Delete(
  947. IN const CMetaInterface * pInterface,
  948. IN LPCTSTR lpszService,
  949. IN DWORD dwInstance, OPTIONAL
  950. IN LPCTSTR lpszParentPath, OPTIONAL
  951. IN LPCTSTR lpszNode
  952. );
  953. //
  954. // Rename virtual directory
  955. //
  956. static HRESULT Rename(
  957. IN const CMetaInterface * pInterface,
  958. IN LPCTSTR lpszService,
  959. IN DWORD dwInstance, OPTIONAL
  960. IN LPCTSTR lpszParentPath, OPTIONAL
  961. IN LPCTSTR lpszOldName,
  962. IN LPCTSTR lpszNewName
  963. );
  964. public:
  965. //
  966. // TRUE, if this is an enabled application
  967. //
  968. BOOL IsEnabledApplication() { return m_fIsAppRoot; }
  969. //
  970. // Get the alias name
  971. //
  972. LPCTSTR QueryAlias() const { return m_strAlias; }
  973. CString & GetAlias() { return m_strAlias; }
  974. //
  975. // Get the error
  976. //
  977. DWORD QueryWin32Error() const { return m_dwWin32Error; }
  978. //
  979. // This is how to separate file/dir props from vdirs
  980. //
  981. BOOL IsPathInherited() const { return m_fPathInherited; }
  982. //
  983. // Empty the path if it was inherited
  984. //
  985. void RemovePathIfInherited();
  986. //
  987. // CODEWORK: Ugly solution.
  988. //
  989. // Call this method to override the inheritance status of the
  990. // http redirect path
  991. //
  992. void MarkRedirAsInherit(BOOL fInherit) { m_fInheritRedirect = fInherit; }
  993. //
  994. // Get the path
  995. //
  996. CString & GetPath() { return MP_V(m_strPath); }
  997. //
  998. // Get the redirected path
  999. //
  1000. CString & GetRedirectedPath() { return m_strRedirectPath; }
  1001. //
  1002. // Get the access perms
  1003. //
  1004. DWORD QueryAccessPerms() const { return m_dwAccessPerms; }
  1005. //
  1006. // Get dir browsing bits
  1007. //
  1008. DWORD QueryDirBrowsing() const { return m_dwDirBrowsing; }
  1009. //
  1010. // True if the child is redirected
  1011. //
  1012. BOOL IsRedirected() const { return !m_strRedirectPath.IsEmpty(); }
  1013. //
  1014. // Fill ISMINSTANCE_INFO fields
  1015. //
  1016. void FillInstanceInfo(OUT ISMINSTANCEINFO * pii);
  1017. //
  1018. // Fill ISMCHILDINFO fields
  1019. //
  1020. void FillChildInfo(OUT ISMCHILDINFO * pii);
  1021. //
  1022. // Write Data if dirty
  1023. //
  1024. virtual HRESULT WriteDirtyProps();
  1025. protected:
  1026. //
  1027. // Break out GetAllData() data to data fields
  1028. //
  1029. virtual void ParseFields();
  1030. //
  1031. // Break down redirect statement into component paths
  1032. //
  1033. void ParseRedirectStatement();
  1034. //
  1035. // Reverse the above -- reassemble the redirect statement
  1036. //
  1037. void BuildRedirectStatement();
  1038. protected:
  1039. //
  1040. // Redirect tags
  1041. //
  1042. static const TCHAR s_chTagSep;
  1043. static const LPCTSTR s_cszExactDestination;
  1044. static const LPCTSTR s_cszChildOnly;
  1045. static const LPCTSTR s_cszPermanent;
  1046. public:
  1047. BOOL m_fIsAppRoot;
  1048. BOOL m_fPathInherited;
  1049. BOOL m_fInheritRedirect;
  1050. BOOL m_fExact; // Redirect tag
  1051. BOOL m_fChild; // Redirect tag
  1052. BOOL m_fPermanent; // Redirect tag
  1053. CString m_strAlias;
  1054. CString m_strFullMetaPath;
  1055. CString m_strRedirectPath; // Redirect _path_
  1056. public:
  1057. MP_BOOL m_fAppIsolated;
  1058. MP_DWORD m_dwWin32Error;
  1059. MP_DWORD m_dwDirBrowsing;
  1060. MP_CString m_strPath;
  1061. MP_CString m_strRedirectStatement; // Path + tags
  1062. MP_CString m_strAppRoot;
  1063. MP_CMaskedDWORD m_dwAccessPerms;
  1064. };
  1065. //
  1066. // ISM Helper Functions
  1067. //
  1068. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1069. inline HRESULT COMDLL_ISMBind(
  1070. IN LPCTSTR lpszServer,
  1071. OUT HANDLE * phServer
  1072. )
  1073. {
  1074. ASSERT(lpszServer != NULL);
  1075. ASSERT(phServer != NULL);
  1076. //
  1077. // Use a metainterface pointer for the handle
  1078. //
  1079. CMetaKey * pKey = new CMetaKey(lpszServer);
  1080. *phServer = pKey;
  1081. return *phServer ? S_OK : CError::HResult(ERROR_NOT_ENOUGH_MEMORY);
  1082. }
  1083. inline HRESULT COMDLL_ISMUnbind(
  1084. IN HANDLE hServer
  1085. )
  1086. {
  1087. CMetaKey * pKey = (CMetaKey *)hServer;
  1088. if (pKey)
  1089. {
  1090. delete pKey;
  1091. return S_OK;
  1092. }
  1093. return CError::HResult(ERROR_INVALID_HANDLE);
  1094. }
  1095. inline CMetaKey * GetMetaKeyFromHandle(IN HANDLE hServer)
  1096. {
  1097. ASSERT(hServer != NULL);
  1098. return (CMetaKey *)hServer;
  1099. }
  1100. inline LPCTSTR GetServerNameFromHandle(IN HANDLE hServer)
  1101. {
  1102. ASSERT(hServer != NULL);
  1103. return ((CMetaKey *)hServer)->QueryServerName();
  1104. }
  1105. //
  1106. // Rebind the interface
  1107. //
  1108. HRESULT COMDLL
  1109. COMDLL_RebindInterface(
  1110. OUT IN CMetaInterface * pInterface,
  1111. OUT BOOL * pfContinue,
  1112. IN DWORD dwCancelError
  1113. );
  1114. //
  1115. // Enumerate Instances
  1116. //
  1117. HRESULT COMDLL
  1118. COMDLL_ISMEnumerateInstances(
  1119. IN CMetaInterface * pInterface,
  1120. OUT ISMINSTANCEINFO * pii,
  1121. OUT IN HANDLE * phEnum,
  1122. IN LPCTSTR lpszService
  1123. );
  1124. //
  1125. // Enumerate Child Nodes
  1126. //
  1127. HRESULT COMDLL
  1128. COMDLL_ISMEnumerateChildren(
  1129. IN CMetaInterface * pInterface,
  1130. OUT ISMCHILDINFO * pii,
  1131. OUT IN HANDLE * phEnum,
  1132. IN LPCTSTR lpszService,
  1133. IN DWORD dwInstance,
  1134. IN LPCTSTR lpszParent
  1135. );
  1136. class COMDLL CInetPropertySheet : public CPropertySheet
  1137. /*++
  1138. Class Description:
  1139. IIS Configuration property sheet class
  1140. Public Interface:
  1141. CInetPropertySheet : Constructor
  1142. ~CInetPropertySheet : Destructor
  1143. cap : Get capabilities
  1144. --*/
  1145. {
  1146. DECLARE_DYNAMIC(CInetPropertySheet)
  1147. //
  1148. // Construction/destruction
  1149. //
  1150. public:
  1151. CInetPropertySheet(
  1152. IN UINT nIDCaption,
  1153. IN LPCTSTR lpszServer,
  1154. IN LPCTSTR lpszService = NULL,
  1155. IN DWORD dwInstance = MASTER_INSTANCE,
  1156. IN LPCTSTR lpszParent = NULL,
  1157. IN LPCTSTR lpszAlias = NULL,
  1158. IN CWnd * pParentWnd = NULL,
  1159. IN LPARAM lParam = 0L,
  1160. IN LONG_PTR handle = 0L,
  1161. IN UINT iSelectPage = 0
  1162. );
  1163. CInetPropertySheet(
  1164. IN LPCTSTR lpszCaption,
  1165. IN LPCTSTR lpszServer,
  1166. IN LPCTSTR lpszService = NULL,
  1167. IN DWORD dwInstance = MASTER_INSTANCE,
  1168. IN LPCTSTR lpszParent = NULL,
  1169. IN LPCTSTR lpszAlias = NULL,
  1170. IN CWnd * pParentWnd = NULL,
  1171. IN LPARAM lParam = 0L,
  1172. IN LONG_PTR handle = 0L,
  1173. IN UINT iSelectPage = 0
  1174. );
  1175. virtual ~CInetPropertySheet();
  1176. //
  1177. // Overrides
  1178. //
  1179. protected:
  1180. //{{AFX_VIRTUAL(CInetPropertySheet)
  1181. //}}AFX_VIRTUAL
  1182. //
  1183. // Access
  1184. //
  1185. public:
  1186. CServerCapabilities & cap() { return m_cap; }
  1187. CString & GetServerName() { return m_strServer; }
  1188. LPCTSTR QueryServerName() const { return m_strServer; }
  1189. LPCTSTR QueryService() const { return m_strService; }
  1190. DWORD QueryInstance() const { return m_dwInstance; }
  1191. BOOL IsMasterInstance() const { return IS_MASTER_INSTANCE(m_dwInstance); }
  1192. LPCTSTR QueryAlias() const { return m_strAlias; }
  1193. LPCTSTR QueryParent() const { return m_strParent; }
  1194. BOOL IsLocal() const { return m_fLocal; }
  1195. BOOL HasAdminAccess() const { return m_fHasAdminAccess; }
  1196. public:
  1197. void AddRef();
  1198. void Release();
  1199. void NotifyMMC();
  1200. void SetModeless();
  1201. BOOL IsModeless() const { return m_bModeless; }
  1202. public:
  1203. virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
  1204. //
  1205. // Override in derived class to load delayed values
  1206. //
  1207. /* PURE */ virtual HRESULT LoadConfigurationParameters() = 0;
  1208. /* PURE */ virtual void FreeConfigurationParameters() = 0;
  1209. //
  1210. // Generated message map functions
  1211. //
  1212. protected:
  1213. //{{AFX_MSG(CInetPropertySheet)
  1214. //}}AFX_MSG
  1215. DECLARE_MESSAGE_MAP()
  1216. void Initialize();
  1217. //
  1218. // Attempt to resolve admin/operator access for the given
  1219. // instance number
  1220. //
  1221. DWORD DetermineAdminAccess(
  1222. IN LPCTSTR lpszService,
  1223. IN DWORD dwInstance
  1224. );
  1225. protected:
  1226. BOOL m_fLocal;
  1227. BOOL m_fHasAdminAccess;
  1228. DWORD m_dwInstance;
  1229. CString m_strServer;
  1230. CString m_strService;
  1231. CString m_strAlias;
  1232. CString m_strParent;
  1233. INT m_refcount;
  1234. CServerCapabilities m_cap;
  1235. private:
  1236. BOOL m_bModeless;
  1237. LONG_PTR m_hConsole;
  1238. LPARAM m_lParam;
  1239. };
  1240. //
  1241. // Metabase Helpers
  1242. //
  1243. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1244. //
  1245. // Get record data size
  1246. //
  1247. inline DWORD RecordDataSize(
  1248. IN METADATA_GETALL_RECORD * pAllRecord,
  1249. IN int iIndex
  1250. )
  1251. {
  1252. return pAllRecord[iIndex].dwMDDataLen;
  1253. }
  1254. //
  1255. // Fetch data at index as DWORD
  1256. //
  1257. inline void FetchMetaValue(
  1258. IN METADATA_GETALL_RECORD * pAllRecord,
  1259. IN int iIndex,
  1260. OUT DWORD & dwValue
  1261. )
  1262. {
  1263. ASSERT(RecordDataSize(pAllRecord, iIndex) == sizeof(DWORD));
  1264. dwValue = *((DWORD UNALIGNED *)((PBYTE)pAllRecord + pAllRecord[iIndex].dwMDDataOffset));
  1265. }
  1266. //
  1267. // Fetch data at index as UINT
  1268. //
  1269. inline void FetchMetaValue(
  1270. IN METADATA_GETALL_RECORD * pAllRecord,
  1271. IN int iIndex,
  1272. OUT UINT & uValue
  1273. )
  1274. {
  1275. ASSERT(RecordDataSize(pAllRecord, iIndex) == sizeof(DWORD));
  1276. uValue = (UINT)*((DWORD UNALIGNED *)((PBYTE)pAllRecord + pAllRecord[iIndex].dwMDDataOffset));
  1277. }
  1278. //
  1279. // Fetch data at index as int
  1280. //
  1281. inline void FetchMetaValue(
  1282. IN METADATA_GETALL_RECORD * pAllRecord,
  1283. IN int iIndex,
  1284. OUT int & iValue
  1285. )
  1286. {
  1287. ASSERT(RecordDataSize(pAllRecord, iIndex) == sizeof(DWORD));
  1288. iValue = (int)*((DWORD UNALIGNED *)((PBYTE)pAllRecord + pAllRecord[iIndex].dwMDDataOffset));
  1289. }
  1290. //
  1291. // Fetch data at index as a CString
  1292. //
  1293. inline void FetchMetaValue(
  1294. IN METADATA_GETALL_RECORD * pAllRecord,
  1295. IN int iIndex,
  1296. OUT CString & strValue
  1297. )
  1298. {
  1299. strValue = (LPTSTR)((PBYTE)pAllRecord + pAllRecord[iIndex].dwMDDataOffset);
  1300. }
  1301. //
  1302. // Fetch data at index as a CStringList
  1303. //
  1304. inline void FetchMetaValue(
  1305. IN METADATA_GETALL_RECORD * pAllRecord,
  1306. IN int iIndex,
  1307. OUT CStringList & strlValue
  1308. )
  1309. {
  1310. ConvertDoubleNullListToStringList(
  1311. ((LPCTSTR)((PBYTE)pAllRecord + pAllRecord[iIndex].dwMDDataOffset)),
  1312. strlValue,
  1313. (RecordDataSize(pAllRecord, iIndex)) / sizeof(TCHAR)
  1314. );
  1315. }
  1316. //
  1317. // Fetch binary data as a blob
  1318. //
  1319. inline void FetchMetaValue(
  1320. IN METADATA_GETALL_RECORD * pAllRecord,
  1321. IN int iIndex,
  1322. OUT CBlob & blob
  1323. )
  1324. {
  1325. blob.SetValue(
  1326. RecordDataSize(pAllRecord, iIndex),
  1327. ((PBYTE)pAllRecord + pAllRecord[iIndex].dwMDDataOffset));
  1328. }
  1329. inline void FetchMetaValue(
  1330. IN METADATA_GETALL_RECORD * pAllRecord,
  1331. IN int iIndex,
  1332. OUT CILong & ilValue
  1333. )
  1334. {
  1335. ilValue = (LONG)*((DWORD UNALIGNED *)((PBYTE)pAllRecord + pAllRecord[iIndex].dwMDDataOffset));
  1336. }
  1337. //
  1338. // Fetch data at index as CString, and check inheritance status
  1339. //
  1340. inline void FetchInheritedMetaValue(
  1341. IN METADATA_GETALL_RECORD * pAllRecord,
  1342. IN int iIndex,
  1343. OUT CString & strValue,
  1344. OUT BOOL & fIsInherited
  1345. )
  1346. {
  1347. strValue = (LPTSTR)((PBYTE)pAllRecord + pAllRecord[iIndex].dwMDDataOffset);
  1348. fIsInherited = (pAllRecord[iIndex].dwMDAttributes & METADATA_ISINHERITED) != 0;
  1349. }
  1350. //
  1351. // Flag Operations
  1352. //
  1353. #define IS_FLAG_SET(dw, flag) ((((dw) & (flag)) != 0) ? TRUE : FALSE)
  1354. #define SET_FLAG(dw, flag) dw |= (flag)
  1355. #define RESET_FLAG(dw, flag) dw &= ~(flag)
  1356. #define SET_FLAG_IF(cond, dw, flag)\
  1357. if (cond) \
  1358. { \
  1359. SET_FLAG(dw, flag); \
  1360. } \
  1361. else \
  1362. { \
  1363. RESET_FLAG(dw, flag); \
  1364. }
  1365. //
  1366. // Meta record crackers
  1367. //
  1368. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1369. #define BEGIN_PARSE_META_RECORDS(dwNumEntries, pbMDData)\
  1370. { \
  1371. METADATA_GETALL_RECORD * pAllRecords = \
  1372. (METADATA_GETALL_RECORD *)pbMDData; \
  1373. ASSERT(pAllRecords != NULL); \
  1374. \
  1375. for (DWORD i = 0; i < dwNumEntries; ++i) \
  1376. { \
  1377. METADATA_GETALL_RECORD * pRec = &pAllRecords[i];\
  1378. switch(pRec->dwMDIdentifier) \
  1379. {
  1380. #define HANDLE_META_RECORD(id, value)\
  1381. case id: \
  1382. FetchMetaValue(pAllRecords, i, MP_V(value));\
  1383. break;
  1384. #define HANDLE_INHERITED_META_RECORD(id, value, fIsInherited)\
  1385. case id: \
  1386. FetchInheritedMetaValue(pAllRecords, i, MP_V(value), fIsInherited);\
  1387. break;
  1388. #define END_PARSE_META_RECORDS\
  1389. } \
  1390. } \
  1391. }
  1392. //
  1393. // Sheet -> page crackers
  1394. //
  1395. #define BEGIN_META_INST_READ(sheet)\
  1396. { \
  1397. sheet * pSheet = (sheet *)GetSheet(); \
  1398. do \
  1399. { \
  1400. if (FAILED(pSheet->QueryInstanceResult())) \
  1401. { \
  1402. break; \
  1403. }
  1404. #define FETCH_INST_DATA_FROM_SHEET(value)\
  1405. value = pSheet->GetInstanceProperties().value; \
  1406. TRACEEOLID(value);
  1407. #define END_META_INST_READ(err)\
  1408. \
  1409. } \
  1410. while(FALSE); \
  1411. }
  1412. #define BEGIN_META_DIR_READ(sheet)\
  1413. { \
  1414. sheet * pSheet = (sheet *)GetSheet(); \
  1415. do \
  1416. { \
  1417. if (FAILED(pSheet->QueryDirectoryResult())) \
  1418. { \
  1419. break; \
  1420. }
  1421. #define FETCH_DIR_DATA_FROM_SHEET(value)\
  1422. value = pSheet->GetDirectoryProperties().value; \
  1423. TRACEEOLID(value);
  1424. #define END_META_DIR_READ(err)\
  1425. \
  1426. } \
  1427. while(FALSE); \
  1428. }
  1429. #define BEGIN_META_INST_WRITE(sheet)\
  1430. { \
  1431. sheet * pSheet = (sheet *)GetSheet(); \
  1432. \
  1433. do \
  1434. { \
  1435. #define STORE_INST_DATA_ON_SHEET(value)\
  1436. pSheet->GetInstanceProperties().value = value;
  1437. #define STORE_INST_DATA_ON_SHEET_REMEMBER(value, dirty)\
  1438. pSheet->GetInstanceProperties().value = value; \
  1439. dirty = MP_D(((sheet *)GetSheet())->GetInstanceProperties().value);
  1440. #define FLAG_INST_DATA_FOR_DELETION(id)\
  1441. pSheet->GetInstanceProperties().FlagPropertyForDeletion(id);
  1442. #define END_META_INST_WRITE(err)\
  1443. \
  1444. } \
  1445. while(FALSE); \
  1446. \
  1447. err = pSheet->GetInstanceProperties().WriteDirtyProps(); \
  1448. }
  1449. #define BEGIN_META_DIR_WRITE(sheet)\
  1450. { \
  1451. sheet * pSheet = (sheet *)GetSheet(); \
  1452. \
  1453. do \
  1454. { \
  1455. #define STORE_DIR_DATA_ON_SHEET(value)\
  1456. pSheet->GetDirectoryProperties().value = value;
  1457. #define STORE_DIR_DATA_ON_SHEET_REMEMBER(value, dirty)\
  1458. pSheet->GetDirectoryProperties().value = value; \
  1459. dirty = MP_D(pSheet->GetDirectoryProperties().value);
  1460. #define INIT_DIR_DATA_MASK(value, mask)\
  1461. MP_V(pSheet->GetDirectoryProperties().value).SetMask(mask);
  1462. #define FLAG_DIR_DATA_FOR_DELETION(id)\
  1463. pSheet->GetDirectoryProperties().FlagPropertyForDeletion(id);
  1464. #define END_META_DIR_WRITE(err)\
  1465. \
  1466. } \
  1467. while(FALSE); \
  1468. \
  1469. err = pSheet->GetDirectoryProperties().WriteDirtyProps(); \
  1470. }
  1471. class COMDLL CInetPropertyPage : public CPropertyPage
  1472. {
  1473. /*++
  1474. Class Description:
  1475. IIS Configuration property page class
  1476. Public Interface:
  1477. CInetPropertyPage : Constructor
  1478. ~CInetPropertyPage : Destructor
  1479. SaveInfo : Save info on this page if dirty
  1480. --*/
  1481. DECLARE_DYNAMIC(CInetPropertyPage)
  1482. //
  1483. // Construction/Destruction
  1484. //
  1485. public:
  1486. CInetPropertyPage(
  1487. IN UINT nIDTemplate,
  1488. IN CInetPropertySheet * pSheet,
  1489. IN UINT nIDCaption = USE_DEFAULT_CAPTION,
  1490. IN BOOL fEnableEnhancedFonts = FALSE
  1491. );
  1492. ~CInetPropertyPage();
  1493. //
  1494. // Dialog Data
  1495. //
  1496. protected:
  1497. //{{AFX_DATA(CInetPropertyPage)
  1498. //enum { IDD = _UNKNOWN_RESOURCE_ID_ };
  1499. //}}AFX_DATA
  1500. //
  1501. // Overrides
  1502. //
  1503. public:
  1504. //
  1505. // Derived classes must provide their own equivalents
  1506. //
  1507. HRESULT LoadConfigurationParameters();
  1508. /* PURE */ virtual HRESULT FetchLoadedValues() = 0;
  1509. /* PURE */ virtual HRESULT SaveInfo() = 0;
  1510. //
  1511. // Is the data on this page dirty?
  1512. //
  1513. BOOL IsDirty() const { return m_bChanged; }
  1514. // ClassWizard generate virtual function overrides
  1515. //{{AFX_VIRTUAL(CInetPropertyPage)
  1516. protected:
  1517. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  1518. //}}AFX_VIRTUAL
  1519. #ifdef _DEBUG
  1520. virtual void AssertValid() const;
  1521. virtual void Dump(CDumpContext& dc) const;
  1522. #endif
  1523. protected:
  1524. //
  1525. // Generated message map functions
  1526. //
  1527. //{{AFX_MSG(CInetPropertyPage)
  1528. afx_msg void OnHelp();
  1529. afx_msg BOOL OnHelpInfo(HELPINFO * pHelpInfo);
  1530. //}}AFX_MSG
  1531. DECLARE_MESSAGE_MAP()
  1532. virtual BOOL OnInitDialog();
  1533. virtual BOOL OnApply();
  1534. //
  1535. // Helper function
  1536. //
  1537. protected:
  1538. BOOL GetIUsrAccount(CString & str);
  1539. //
  1540. // Access Functions
  1541. //
  1542. protected:
  1543. //
  1544. // Get associated property sheet object
  1545. //
  1546. CInetPropertySheet * GetSheet() { return m_pSheet; }
  1547. CString & GetServerName() { return m_pSheet->GetServerName(); }
  1548. LPCTSTR QueryServerName() const { return m_pSheet->QueryServerName(); }
  1549. DWORD QueryInstance() const { return m_pSheet->QueryInstance(); }
  1550. LPCTSTR QueryAlias() const { return m_pSheet->QueryAlias(); }
  1551. LPCTSTR QueryParent() const { return m_pSheet->QueryParent(); }
  1552. BOOL IsLocal() const { return m_pSheet->IsLocal(); }
  1553. BOOL HasAdminAccess() const { return m_pSheet->HasAdminAccess(); }
  1554. BOOL IsMasterInstance() const { return m_pSheet->IsMasterInstance(); }
  1555. //
  1556. // Update MMC with new changes
  1557. //
  1558. void NotifyMMC();
  1559. public:
  1560. //
  1561. // Keep private information on page dirty state, necessary for
  1562. // SaveInfo() later.
  1563. //
  1564. void SetModified(
  1565. IN BOOL bChanged = TRUE
  1566. );
  1567. protected:
  1568. BOOL m_bChanged;
  1569. //
  1570. // Capability bits
  1571. //
  1572. protected:
  1573. BOOL IsSSLSupported() const { return m_pSheet->cap().IsSSLSupported(); }
  1574. BOOL IsSSL128Supported() const { return m_pSheet->cap().IsSSL128Supported(); }
  1575. BOOL HasMultipleSites() const { return m_pSheet->cap().HasMultipleSites(); }
  1576. BOOL HasBwThrottling() const { return m_pSheet->cap().HasBwThrottling(); }
  1577. BOOL Has10ConnectionLimit() const { return m_pSheet->cap().Has10ConnectionLimit(); }
  1578. BOOL HasIPAccessCheck() const { return m_pSheet->cap().HasIPAccessCheck(); }
  1579. BOOL HasOperatorList() const { return m_pSheet->cap().HasOperatorList(); }
  1580. BOOL HasFrontPage() const { return m_pSheet->cap().HasFrontPage(); }
  1581. BOOL HasCompression() const { return m_pSheet->cap().HasCompression(); }
  1582. BOOL HasCPUThrottling() const { return m_pSheet->cap().HasCPUThrottling(); }
  1583. BOOL HasDAV() const { return m_pSheet->cap().HasDAV(); }
  1584. BOOL HasDigest() const { return m_pSheet->cap().HasDigest(); }
  1585. BOOL HasNTCertMapper() const { return m_pSheet->cap().HasNTCertMapper(); }
  1586. protected:
  1587. CInetPropertySheet * m_pSheet;
  1588. INT m_refcount;
  1589. LPFNPSPCALLBACK m_pfnOriginalPropSheetPageProc;
  1590. static UINT CALLBACK PropSheetPageProc(
  1591. IN HWND hWnd,
  1592. IN UINT uMsg,
  1593. IN LPPROPSHEETPAGE ppsp
  1594. );
  1595. protected:
  1596. BOOL m_fEnableEnhancedFonts;
  1597. CFont m_fontBold;
  1598. UINT m_nHelpContext;
  1599. };
  1600. //
  1601. // Inline Expansion
  1602. //
  1603. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1604. inline BOOL CMaskedDWORD::operator ==(DWORD dwValue) const
  1605. {
  1606. return (m_dwValue & m_dwMask) == (dwValue & m_dwMask);
  1607. }
  1608. inline CMaskedDWORD & CMaskedDWORD::operator =(DWORD dwValue)
  1609. {
  1610. m_dwValue = ((m_dwValue &= ~m_dwMask) |= (dwValue & m_dwMask));
  1611. return *this;
  1612. }
  1613. inline CBlob::~CBlob()
  1614. {
  1615. CleanUp();
  1616. }
  1617. inline PBYTE CBlob::GetData()
  1618. {
  1619. return m_pbItem;
  1620. }
  1621. inline LPCTSTR NormalizeServerName(
  1622. IN LPCTSTR lpszServerName
  1623. )
  1624. {
  1625. return !lpszServerName || !::IsServerLocal(lpszServerName)
  1626. ? lpszServerName
  1627. : NULL;
  1628. }
  1629. inline /*virtual */ HRESULT CMetaProperties::WriteDirtyProps()
  1630. {
  1631. ASSERT(FALSE);
  1632. return E_NOTIMPL;
  1633. }
  1634. inline void CMetaProperties::FlagPropertyForDeletion(DWORD dwID)
  1635. {
  1636. m_dwaDeletedProps.AddTail(dwID);
  1637. }
  1638. inline LPCTSTR CInstanceProps::GetDisplayText(
  1639. OUT CString & strName,
  1640. IN LPCTSTR szServiceName
  1641. )
  1642. {
  1643. return CInstanceProps::GetDisplayText(
  1644. strName,
  1645. m_strComment,
  1646. m_strDomainName,
  1647. szServiceName,
  1648. m_iaIpAddress,
  1649. m_nTCPPort,
  1650. QueryInstance()
  1651. );
  1652. }
  1653. inline LPCTSTR CInstanceProps::GetHomePath(CString & str)
  1654. {
  1655. str = m_strMetaRoot + SZ_MBN_SEP_STR + g_cszRoot;
  1656. return str;
  1657. }
  1658. inline void CInstanceProps::FillInstanceInfo(
  1659. OUT ISMINSTANCEINFO * pii,
  1660. IN DWORD dwError OPTIONAL
  1661. )
  1662. {
  1663. pii->dwID = m_dwInstance;
  1664. pii->dwIPAddress = (DWORD)m_iaIpAddress;
  1665. pii->sPort = (SHORT)m_nTCPPort;
  1666. pii->nState = m_nISMState;
  1667. pii->fDeletable = IsDeletable();
  1668. pii->fClusterEnabled = IsClusterEnabled();
  1669. pii->dwError = dwError;
  1670. _tcsncpy(
  1671. pii->szComment,
  1672. m_strComment,
  1673. STRSIZE(pii->szComment)
  1674. );
  1675. _tcsncpy(
  1676. pii->szServerName,
  1677. m_strDomainName,
  1678. STRSIZE(pii->szServerName)
  1679. );
  1680. }
  1681. inline void CChildNodeProps::RemovePathIfInherited()
  1682. {
  1683. if (IsPathInherited())
  1684. {
  1685. MP_V(m_strPath).Empty();
  1686. }
  1687. }
  1688. inline void CChildNodeProps::FillInstanceInfo(ISMINSTANCEINFO * pii)
  1689. {
  1690. _tcsncpy(pii->szPath, GetPath(), STRSIZE(pii->szPath));
  1691. _tcsncpy(pii->szRedirPath, GetRedirectedPath(), STRSIZE(pii->szRedirPath));
  1692. pii->fChildOnlyRedir = m_fChild;
  1693. }
  1694. inline void CChildNodeProps::FillChildInfo(ISMCHILDINFO * pii)
  1695. {
  1696. //
  1697. // Set the output structure
  1698. //
  1699. pii->fInheritedPath = IsPathInherited();
  1700. pii->fEnabledApplication = IsEnabledApplication();
  1701. pii->dwError = QueryWin32Error();
  1702. _tcsncpy(
  1703. pii->szAlias,
  1704. GetAlias(),
  1705. STRSIZE(pii->szAlias)
  1706. );
  1707. _tcsncpy(
  1708. pii->szPath,
  1709. GetPath(),
  1710. STRSIZE(pii->szPath)
  1711. );
  1712. _tcsncpy(
  1713. pii->szRedirPath,
  1714. IsRedirected() ? GetRedirectedPath() : _T(""),
  1715. STRSIZE(pii->szRedirPath)
  1716. );
  1717. pii->fChildOnlyRedir = m_fChild;
  1718. }
  1719. inline void CInetPropertySheet::SetModeless()
  1720. {
  1721. m_bModeless = TRUE;
  1722. }
  1723. inline DWORD CInetPropertySheet::DetermineAdminAccess(
  1724. IN LPCTSTR lpszService,
  1725. IN DWORD dwInstance
  1726. )
  1727. {
  1728. return DetermineIfAdministrator(
  1729. &m_cap, // Reuse existing interface
  1730. lpszService,
  1731. dwInstance,
  1732. &m_fHasAdminAccess
  1733. );
  1734. }
  1735. inline HRESULT CInetPropertyPage::LoadConfigurationParameters()
  1736. {
  1737. return GetSheet()->LoadConfigurationParameters();
  1738. }
  1739. inline BOOL CInetPropertyPage::GetIUsrAccount(CString & str)
  1740. {
  1741. return ::GetIUsrAccount(QueryServerName(), this, str);
  1742. }
  1743. inline void CInetPropertyPage::NotifyMMC()
  1744. {
  1745. m_pSheet->NotifyMMC();
  1746. }
  1747. #endif // _INETPROP_H_