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.

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