Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module stssites.hxx | Declaration of CSTSSites
  6. @end
  7. Author:
  8. Brian Berkowitz [brianb] 10/15/2001
  9. Revision History:
  10. Name Date Comments
  11. brianb 10/15/2001 Created
  12. --*/
  13. #ifndef _STSSITES_HXX_
  14. #define _STSSITES_HXX_
  15. class CVssAutoMetabaseHandle
  16. {
  17. private:
  18. CVssAutoMetabaseHandle(const CVssAutoMetabaseHandle&);
  19. public:
  20. CVssAutoMetabaseHandle
  21. (
  22. IMSAdminBase *pMetabase,
  23. METADATA_HANDLE handle = METADATA_MASTER_ROOT_HANDLE
  24. ) :
  25. m_handle(handle),
  26. m_pMetabase(pMetabase)
  27. {
  28. }
  29. // Automatically closes the handle
  30. ~CVssAutoMetabaseHandle()
  31. {
  32. Close();
  33. }
  34. // Returns the value of the actual handle
  35. operator METADATA_HANDLE () const
  36. {
  37. return m_handle;
  38. }
  39. // This function is used to get the value of the new handle in
  40. // calls that return handles as OUT paramters.
  41. // This funciton guarantees that a memory leak will not occur
  42. // if a handle is already allocated.
  43. PMETADATA_HANDLE ResetAndGetAddress()
  44. {
  45. // Close previous handle and set the current value to NULL
  46. Close();
  47. // Return the address of the actual handle
  48. return &m_handle;
  49. };
  50. // Close the current handle and set the current value to NULL
  51. void Close()
  52. {
  53. if (m_handle != METADATA_MASTER_ROOT_HANDLE)
  54. {
  55. // Ignore the returned BOOL
  56. m_pMetabase->CloseKey(m_handle);
  57. m_handle = METADATA_MASTER_ROOT_HANDLE;
  58. }
  59. }
  60. private:
  61. METADATA_HANDLE m_handle;
  62. CComPtr<IMSAdminBase> m_pMetabase;
  63. };
  64. // class for accessing Sharepoint metadata including location of contents,
  65. // location of security information, and DSN for site databases
  66. class CSTSSites
  67. {
  68. public:
  69. // constructor
  70. CSTSSites();
  71. // destructor
  72. ~CSTSSites();
  73. // determine whether the current version of sharepoint is supported
  74. bool ValidateSharepointVersion();
  75. // initialize array of sites
  76. bool Initialize();
  77. // return number of sites on the current machine
  78. DWORD GetSiteCount() { return m_cSites; }
  79. // get id of a given site
  80. DWORD GetSiteId(DWORD iSite)
  81. {
  82. BS_ASSERT(iSite < m_cSites);
  83. return m_rgSiteIds[iSite];
  84. }
  85. // get the OLEDB DSN of a given site
  86. VSS_PWSZ GetSiteDSN(DWORD iSite);
  87. // return name of root directory for sites Documents And Settings directory
  88. VSS_PWSZ GetSiteRoles(DWORD iSite);
  89. // return location of the Sharepoint quota database
  90. VSS_PWSZ GetQuotaDatabase();
  91. // lock the Sharepoint quota database
  92. void LockQuotaDatabase();
  93. // unlock the Sharepoint quota database
  94. void UnlockQuotaDatabase();
  95. // get the location of the content root for a site
  96. VSS_PWSZ GetSiteRoot(DWORD iSite);
  97. // get port number of site
  98. DWORD GetSitePort(DWORD iSite);
  99. // get ip address of site
  100. VSS_PWSZ GetSiteIpAddress(DWORD iSite);
  101. // get host name of site
  102. VSS_PWSZ GetSiteHost(DWORD iSite);
  103. // get site name (comment)
  104. VSS_PWSZ GetSiteComment(DWORD iSite);
  105. // lock the site contents
  106. void LockSiteContents(DWORD iSite);
  107. // unlock site contents
  108. void UnlockSites();
  109. private:
  110. // setup interface for metabase
  111. void SetupMetabaseInterface();
  112. // utility routine to strip white characters from a string
  113. static void stripWhiteChars(LPWSTR &wsz);
  114. // get location of All Users folder
  115. LPCWSTR GetAppDataFolder();
  116. // get information about the configuration of a web site
  117. VSS_PWSZ GetSiteBasicInfo(DWORD iSite, DWORD propId);
  118. // try locking a file by opening it with no share mode.
  119. void TryLock(LPCWSTR wszFile, bool bQuotaFile);
  120. // number of sites on this machine
  121. DWORD m_cSites;
  122. // array of site ids
  123. DWORD *m_rgSiteIds;
  124. // root in registry for Sharepoint specific data
  125. CVssRegistryKey m_rootKey;
  126. // handle for owsuser.lck
  127. HANDLE m_hQuotaLock;
  128. // array of content locks
  129. CSimpleArray<HANDLE> m_rgContentLocks;
  130. // metabase interface
  131. CComPtr<IMSAdminBase> m_pMetabase;
  132. // location of all users folder
  133. LPWSTR m_wszAppDataFolder;
  134. };
  135. #endif // _STSSITES_HXX_p