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.

287 lines
8.5 KiB

  1. /*++
  2. Module Name:
  3. DfsJP.h
  4. Abstract:
  5. This module contains the declaration of the DfsJunctionPoint COM Class. This class
  6. provides methods to get information of a junction point and to enumerate
  7. Replicas of the junction point. It implements IDfsJunctionPoint and provides
  8. an enumerator through get__NewEnum().
  9. --*/
  10. #ifndef _DFSJP_H
  11. #define _DFSJP_H
  12. #include "resource.h" // main symbols
  13. #include "dfsenums.h"
  14. #include <list>
  15. using namespace std;
  16. #define ARRAY_COUNT_FOR_DFS_INFO_3 2
  17. #define ARRAY_COUNT_FOR_DFS_STORAGE_INFO 3
  18. class REPLICAINFO
  19. {
  20. public:
  21. CComBSTR m_bstrServerName;
  22. CComBSTR m_bstrShareName;
  23. long m_lDfsStorageState;
  24. HRESULT Init(BSTR bstrServerName, BSTR bstrShareName, long lDfsStorageState)
  25. {
  26. ReSet();
  27. RETURN_INVALIDARG_IF_TRUE(!bstrServerName);
  28. RETURN_INVALIDARG_IF_TRUE(!bstrShareName);
  29. HRESULT hr = S_OK;
  30. do {
  31. m_bstrServerName = bstrServerName;
  32. BREAK_OUTOFMEMORY_IF_NULL((BSTR)m_bstrServerName, &hr);
  33. m_bstrShareName = bstrShareName;
  34. BREAK_OUTOFMEMORY_IF_NULL((BSTR)m_bstrShareName, &hr);
  35. m_lDfsStorageState = lDfsStorageState;
  36. } while (0);
  37. if (FAILED(hr))
  38. ReSet();
  39. return hr;
  40. }
  41. void ReSet()
  42. {
  43. if (m_bstrServerName) m_bstrServerName.Empty();
  44. if (m_bstrShareName) m_bstrShareName.Empty();
  45. m_lDfsStorageState = DFS_STORAGE_STATE_OFFLINE;
  46. }
  47. REPLICAINFO* Copy()
  48. {
  49. REPLICAINFO* pNew = new REPLICAINFO;
  50. if (pNew)
  51. {
  52. HRESULT hr = S_OK;
  53. do {
  54. pNew->m_bstrServerName = m_bstrServerName;
  55. BREAK_OUTOFMEMORY_IF_NULL((BSTR)pNew->m_bstrServerName, &hr);
  56. pNew->m_bstrShareName = m_bstrShareName;
  57. BREAK_OUTOFMEMORY_IF_NULL((BSTR)pNew->m_bstrShareName, &hr);
  58. pNew->m_lDfsStorageState = m_lDfsStorageState;
  59. } while (0);
  60. if (FAILED(hr))
  61. {
  62. delete pNew;
  63. pNew = NULL;
  64. }
  65. }
  66. return pNew;
  67. }
  68. };
  69. typedef list<REPLICAINFO*> REPLICAINFOLIST;
  70. class ATL_NO_VTABLE CDfsJunctionPoint :
  71. public CComObjectRootEx<CComSingleThreadModel>,
  72. public CComCoClass<CDfsJunctionPoint, &CLSID_DfsJunctionPoint>,
  73. public IDispatchImpl<IDfsJunctionPoint, &IID_IDfsJunctionPoint, &LIBID_DFSCORELib>
  74. {
  75. public:
  76. DECLARE_REGISTRY_RESOURCEID(IDR_DFSJP)
  77. BEGIN_COM_MAP(CDfsJunctionPoint)
  78. COM_INTERFACE_ENTRY(IDfsJunctionPoint)
  79. COM_INTERFACE_ENTRY(IDispatch)
  80. END_COM_MAP()
  81. // IDfsJunctionPoint
  82. public:
  83. //Contructor.
  84. CDfsJunctionPoint();
  85. //Destructor.
  86. ~CDfsJunctionPoint();
  87. // Returns a DfsReplica Enumerator.
  88. STDMETHOD(get__NewEnum)
  89. (
  90. /*[out, retval]*/
  91. LPUNKNOWN *pVal // The IEnumVARIANT Pointer is returned in this.
  92. );
  93. // Returns the number of replicas for
  94. STDMETHOD(get_CountOfDfsReplicas) // this Junction Point
  95. (
  96. /*[out, retval]*/ long *pVal // The number of replicas.
  97. );
  98. // Intialises a DfsJunctionPoint COM
  99. STDMETHOD(Initialize) // Object. Should be called after CoCreateInstance.
  100. (
  101. /*[in]*/ IUnknown *i_piDfsRoot,
  102. /*[in]*/ BSTR i_szEntryPath, // The junction point Dfs Path. Eg. "//DOM/Dfs/JP".
  103. /*[in]*/ BOOL i_bReplicaSetExist,
  104. /*[in]*/ BSTR i_bstrReplicaSetDN
  105. );
  106. // Gets the comment associated with
  107. STDMETHOD(get_Comment) // the Junctionpoint.
  108. (
  109. /*[out, retval]*/ BSTR *pVal // The Comment.
  110. );
  111. // Sets the comment. Sets in memory as
  112. STDMETHOD(put_Comment) // well in the network PKT.
  113. (
  114. /*[in]*/ BSTR newVal
  115. );
  116. // Gets the Junction Name. Justs gets
  117. // the last part of the entry path.
  118. STDMETHOD(get_JunctionName) // E.g "usa\Products" for "\\DOM\Dfs\usa\Products".
  119. (
  120. /*[in]*/ BOOL i_bDfsNameIncluded,
  121. /*[out, retval]*/ BSTR *pVal // The junction name.
  122. );
  123. // Gets the entry path of the junction
  124. STDMETHOD(get_EntryPath) // point. Eg. "\\Dom\Dfs\usa\Products".
  125. (
  126. /*[out, retval]*/ BSTR *pVal
  127. );
  128. // Get Dfs JuncitonPoint State.
  129. STDMETHOD(get_State)
  130. (
  131. /*[out, retval]*/ long *pVal // The state of the junction point.
  132. );
  133. STDMETHOD(get_ReplicaSetDN) // get the prefix DN of the corresponding replica set.
  134. (
  135. /*[out, retval]*/ BSTR *pVal
  136. );
  137. STDMETHOD(get_ReplicaSetExist)
  138. (
  139. /*[out, retval]*/ BOOL *pVal
  140. );
  141. STDMETHOD(get_ReplicaSetExistEx)
  142. (
  143. /*[out]*/ BSTR* o_pbstrDC,
  144. /*[out, retval]*/ BOOL *pVal
  145. );
  146. STDMETHOD(put_ReplicaSetExist)
  147. (
  148. /*[in]*/ BOOL newVal
  149. );
  150. STDMETHOD( AddReplica ) // Adds a new replica to the junction point.
  151. (
  152. /* [in]*/ BSTR i_szServerName,
  153. /* [in]*/ BSTR i_szShareName,
  154. /* [out, retval]*/ VARIANT* o_pvarReplicaObject
  155. );
  156. STDMETHOD( RemoveReplica ) // Removes a Replica from the Junction Point.
  157. (
  158. /* [in]*/ BSTR i_szServerName,
  159. /* [in]*/ BSTR i_szShareName
  160. );
  161. STDMETHOD( RemoveAllReplicas ) // Delete the Junction Point.
  162. (
  163. );
  164. STDMETHOD( get_Timeout )
  165. (
  166. /*[out, retval]*/ long* pVal
  167. );
  168. // Sets the time out for the junction point.
  169. STDMETHOD( put_Timeout )
  170. (
  171. /*[in]*/ long newVal
  172. );
  173. STDMETHOD( DeleteRootReplica )
  174. (
  175. /*[in]*/ BSTR i_bstrDomainName,
  176. /*[in]*/ BSTR i_bstrDfsName,
  177. /*[in]*/ BSTR i_bstrServerName,
  178. /*[in]*/ BSTR i_bstrShareName,
  179. /*[in]*/ BOOL i_bForce
  180. );
  181. STDMETHOD( GetOneRootReplica )
  182. (
  183. /*[out]*/ BSTR* o_pbstrServerName,
  184. /*[out]*/ BSTR* o_pbstrShareName
  185. );
  186. STDMETHOD(InitializeEx)
  187. (
  188. /*[in]*/ IUnknown *piDfsRoot,
  189. /*[in]*/ VARIANT *pVar,
  190. /*[in]*/ BOOL bReplicaSetExist,
  191. /*[in]*/ BSTR bstrReplicaSetDN
  192. );
  193. protected:
  194. //Member Variables
  195. CComPtr<IDfsRoot> m_spiDfsRoot;
  196. CComBSTR m_bstrEntryPath;
  197. CComBSTR m_bstrJunctionName; // given \\ntbuilds\release\dir1\dir2, it's dir1\dir2
  198. CComBSTR m_bstrJunctionNameEx; // given \\ntbuilds\release\dir1\dir2, it's release\dir1\dir2
  199. CComBSTR m_bstrReplicaSetDN;
  200. BOOL m_bReplicaSetExist;
  201. REPLICAINFOLIST m_Replicas; // List of Replicas.
  202. protected:
  203. //Helper Functions
  204. void _FreeMemberVariables();
  205. HRESULT _GetReplicaSetDN
  206. (
  207. BSTR i_szEntryPath
  208. );
  209. HRESULT _GetDfsType(
  210. OUT DFS_TYPE* o_pdwDfsType,
  211. OUT BSTR* o_pbstrDomainName,
  212. OUT BSTR* o_pbstrDomainDN
  213. );
  214. HRESULT _Init(
  215. PDFS_INFO_3 pDfsInfo,
  216. BOOL bReplicaSetExist,
  217. BSTR bstrReplicaSetDN
  218. );
  219. HRESULT _AddToReplicaList
  220. (
  221. BSTR bstrServerName,
  222. BSTR bstrShareName,
  223. long lDfsStorageState
  224. );
  225. void _DeleteFromReplicaList(BSTR bstrServerName, BSTR bstrShareName);
  226. HRESULT _GetDfsStorageState
  227. (
  228. BSTR i_szServerName,
  229. BSTR i_szShareName,
  230. long* o_pVal
  231. );
  232. };
  233. #endif //_DFSJP_H