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.

251 lines
7.2 KiB

  1. // smb.h: SMB shares, sessions and open resources
  2. #ifndef __SMB_H_INCLUDED__
  3. #define __SMB_H_INCLUDED__
  4. #include "FileSvc.h" // FileServiceProvider
  5. #include "shlobj.h" // LPITEMIDLIST
  6. //
  7. // helper functions
  8. //
  9. HRESULT GetDCInfo(
  10. IN LPCTSTR ptchServerName,
  11. OUT CString& strDCName
  12. );
  13. HRESULT GetADsPathOfComputerObject(
  14. IN LPCTSTR ptchServerName,
  15. OUT CString& strADsPath,
  16. OUT CString& strDCName
  17. );
  18. HRESULT CheckSchemaVersion(IN LPCTSTR ptchServerName);
  19. BOOL CheckPolicyOnSharePublish(IN LPCTSTR ptchShareName);
  20. HRESULT PutMultiValuesIntoVarArray(
  21. IN LPCTSTR pszValues,
  22. OUT VARIANT* pVar
  23. );
  24. HRESULT GetSingleOrMultiValuesFromVarArray(
  25. IN VARIANT* pVar,
  26. OUT CString& strValues
  27. );
  28. HRESULT IsValueInVarArray(
  29. IN VARIANT* pVar,
  30. IN LPCTSTR ptchValue
  31. );
  32. // forward declarations
  33. class CSmbCookieBlock;
  34. class SmbFileServiceProvider : public FileServiceProvider
  35. {
  36. public:
  37. SmbFileServiceProvider( CFileMgmtComponentData* pFileMgmtData );
  38. virtual DWORD OpenShare(LPCTSTR ptchServerName, LPCTSTR ptchShareName);
  39. virtual HRESULT ConfirmDeleteShare(LPCTSTR ptchServerName, LPCTSTR ptchShareName);
  40. virtual DWORD DeleteShare(LPCTSTR ptchServerName, LPCTSTR ptchShareName);
  41. virtual DWORD CloseSession(CFileMgmtResultCookie* pcookie);
  42. virtual DWORD CloseResource(CFileMgmtResultCookie* pcookie);
  43. virtual VOID DisplayShareProperties(
  44. LPPROPERTYSHEETCALLBACK pCallBack,
  45. LPDATAOBJECT pDataObject,
  46. LONG_PTR handle);
  47. virtual DWORD ReadShareProperties(
  48. LPCTSTR ptchServerName,
  49. LPCTSTR ptchShareName,
  50. OUT PVOID* ppvPropertyBlock,
  51. OUT CString& strDescription,
  52. OUT CString& strPath,
  53. OUT BOOL* pfEditDescription,
  54. OUT BOOL* pfEditPath,
  55. OUT DWORD* pdwShareType);
  56. virtual DWORD WriteShareProperties(
  57. LPCTSTR ptchServerName,
  58. LPCTSTR ptchShareName,
  59. PVOID pvPropertyBlock,
  60. LPCTSTR ptchDescription,
  61. LPCTSTR ptchPath);
  62. virtual HRESULT ReadSharePublishInfo(
  63. LPCTSTR ptchServerName,
  64. LPCTSTR ptchShareName,
  65. OUT BOOL* pbPublish,
  66. OUT CString& strUNCPath,
  67. OUT CString& strDescription,
  68. OUT CString& strKeywords,
  69. OUT CString& strManagedBy);
  70. virtual HRESULT WriteSharePublishInfo(
  71. LPCTSTR ptchServerName,
  72. LPCTSTR ptchShareName,
  73. IN BOOL bPublish,
  74. LPCTSTR ptchDescription,
  75. LPCTSTR ptchKeywords,
  76. LPCTSTR ptchManagedBy);
  77. virtual DWORD ReadShareType(
  78. LPCTSTR ptchServerName,
  79. LPCTSTR ptchShareName,
  80. DWORD* pdwShareType );
  81. virtual DWORD ReadShareFlags(
  82. LPCTSTR ptchServerName,
  83. LPCTSTR ptchShareName,
  84. DWORD* pdwFlags );
  85. virtual DWORD WriteShareFlags(
  86. LPCTSTR ptchServerName,
  87. LPCTSTR ptchShareName,
  88. DWORD dwFlags );
  89. virtual BOOL GetCachedFlag( DWORD dwFlags, DWORD dwFlagToCheck );
  90. virtual VOID SetCachedFlag( DWORD* pdwFlags, DWORD dwNewFlag );
  91. virtual VOID FreeShareProperties(PVOID pvPropertyBlock);
  92. virtual HRESULT PopulateShares(
  93. IResultData* pResultData,
  94. CFileMgmtCookie* pcookie);
  95. // if pResultData is not NULL, add sessions/resources to the listbox
  96. // if pResultData is NULL, delete all sessions/resources
  97. // if pResultData is NULL, return SUCCEEDED(hr) to continue or
  98. // FAILED(hr) to abort
  99. virtual HRESULT EnumerateSessions(
  100. IResultData* pResultData,
  101. CFileMgmtCookie* pcookie,
  102. bool bAddToResultPane);
  103. virtual HRESULT EnumerateResources(
  104. IResultData* pResultData,
  105. CFileMgmtCookie* pcookie);
  106. virtual VOID FreeData(PVOID pv);
  107. virtual DWORD QueryMaxUsers(PVOID pvPropertyBlock);
  108. virtual VOID SetMaxUsers( PVOID pvPropertyBlock, DWORD dwMaxUsers);
  109. virtual LPCTSTR QueryTransportString();
  110. HRESULT AddSMBShareItems(
  111. IResultData* pResultData,
  112. CFileMgmtCookie* pParentCookie,
  113. PVOID pinfo,
  114. DWORD nItems);
  115. HRESULT HandleSMBSessionItems(
  116. IResultData* pResultData,
  117. CFileMgmtCookie* pParentCookie,
  118. PVOID pinfo,
  119. DWORD nItems,
  120. BOOL bAddToResultPane);
  121. HRESULT HandleSMBResourceItems(
  122. IResultData* pResultData,
  123. CFileMgmtCookie* pParentCookie,
  124. PVOID pinfo,
  125. DWORD nItems);
  126. private:
  127. CString m_strTransportSMB;
  128. };
  129. class CSmbCookie : public CFileMgmtResultCookie
  130. {
  131. public:
  132. inline CSmbCookie( FileMgmtObjectType objecttype )
  133. : CFileMgmtResultCookie( objecttype ),
  134. m_pCookieBlock (0)
  135. {}
  136. virtual HRESULT GetTransport( OUT FILEMGMT_TRANSPORT* pTransport );
  137. virtual void AddRefCookie();
  138. virtual void ReleaseCookie();
  139. // CHasMachineName
  140. CSmbCookieBlock* m_pCookieBlock;
  141. DECLARE_FORWARDS_MACHINE_NAME(m_pCookieBlock)
  142. };
  143. class CSmbCookieBlock : public CCookieBlock<CSmbCookie>, public CStoresMachineName
  144. {
  145. public:
  146. inline CSmbCookieBlock(
  147. CSmbCookie* aCookies, // use vector ctor, we use vector dtor
  148. INT cCookies,
  149. LPCTSTR lpcszMachineName,
  150. PVOID pvCookieData)
  151. : CCookieBlock<CSmbCookie>( aCookies, cCookies ),
  152. CStoresMachineName( lpcszMachineName ),
  153. m_pvCookieData( pvCookieData )
  154. {
  155. for (int i = 0; i < cCookies; i++)
  156. // {
  157. // aCookies[i].ReadMachineNameFrom( (CHasMachineName*)this );
  158. aCookies[i].m_pCookieBlock = this;
  159. // }
  160. }
  161. virtual ~CSmbCookieBlock();
  162. private:
  163. PVOID m_pvCookieData;
  164. };
  165. class CSmbShareCookie : public CSmbCookie
  166. {
  167. public:
  168. inline CSmbShareCookie() : CSmbCookie( FILEMGMT_SHARE ) {}
  169. virtual HRESULT GetShareName( OUT CString& strShareName );
  170. virtual HRESULT GetExplorerViewDescription( OUT CString& strExplorerViewDescription );
  171. inline virtual DWORD GetNumOfCurrentUses() { return GetShareInfo()->shi2_current_uses; }
  172. virtual BSTR GetColumnText(int nCol);
  173. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  174. inline SHARE_INFO_2* GetShareInfo()
  175. {
  176. ASSERT( NULL != m_pobject );
  177. return (SHARE_INFO_2*)m_pobject;
  178. }
  179. virtual HRESULT GetSharePIDList( OUT LPITEMIDLIST *ppidl );
  180. };
  181. class CSmbSessionCookie : public CSmbCookie
  182. {
  183. public:
  184. inline CSmbSessionCookie() : CSmbCookie( FILEMGMT_SESSION )
  185. {
  186. }
  187. virtual HRESULT GetSessionClientName( OUT CString& strShareName );
  188. virtual HRESULT GetSessionUserName( OUT CString& strShareName );
  189. inline virtual DWORD GetNumOfOpenFiles() { return GetSessionInfo()->sesi1_num_opens; }
  190. inline virtual DWORD GetConnectedTime() { return GetSessionInfo()->sesi1_time; }
  191. inline virtual DWORD GetIdleTime() { return GetSessionInfo()->sesi1_idle_time; }
  192. virtual BSTR GetColumnText(int nCol);
  193. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  194. inline SESSION_INFO_1* GetSessionInfo()
  195. {
  196. ASSERT( NULL != m_pobject );
  197. return (SESSION_INFO_1*)m_pobject;
  198. }
  199. };
  200. class CSmbResourceCookie : public CSmbCookie
  201. {
  202. public:
  203. inline CSmbResourceCookie() : CSmbCookie( FILEMGMT_RESOURCE ) {}
  204. virtual HRESULT GetFileID( DWORD* pdwFileID );
  205. inline virtual DWORD GetNumOfLocks() { return GetFileInfo()->fi3_num_locks; }
  206. virtual BSTR GetColumnText(int nCol);
  207. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  208. inline FILE_INFO_3* GetFileInfo()
  209. {
  210. ASSERT( NULL != m_pobject );
  211. return (FILE_INFO_3*)m_pobject;
  212. }
  213. };
  214. #endif // ~__SMB_H_INCLUDED__