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.

338 lines
7.3 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2000, Microsoft Corporation
  4. //
  5. // File: DfsADBlobRootFolder.hxx
  6. //
  7. // Contents: the Root DFS Folder class for ADBlob Store
  8. //
  9. // Classes: DfsADBlobRootFolder
  10. //
  11. // History: Dec. 8 2000, Author: udayh
  12. // April 10, 2001 Rohanp - Added ADSI specific function calls
  13. //
  14. //-----------------------------------------------------------------------------
  15. #ifndef __DFS_ADBLOB_ROOT_FOLDER__
  16. #define __DFS_ADBLOB_ROOT_FOLDER__
  17. #include "DfsRootFolder.hxx"
  18. #include "DfsADBlobStore.hxx"
  19. #include "DfsAdBlobCache.hxx"
  20. #include <shellapi.h>
  21. #include <ole2.h>
  22. #include <activeds.h>
  23. //+----------------------------------------------------------------------------
  24. //
  25. // Class: DfsADBlobRootFolder
  26. //
  27. // Synopsis: This class implements The Dfs ADBlob root folder.
  28. //
  29. //-----------------------------------------------------------------------------
  30. class DfsADBlobRootFolder: public DfsRootFolder
  31. {
  32. private:
  33. DfsADBlobStore *_pStore; // Pointer to registered store
  34. // that owns this root.
  35. DfsADBlobCache * _pBlobCache;
  36. protected:
  37. DfsStore *
  38. GetMetadataStore()
  39. {
  40. return _pStore;
  41. }
  42. DfsADBlobCache *
  43. GetMetadataBlobCache()
  44. {
  45. return _pBlobCache;
  46. }
  47. //
  48. // Force a flush of the entire cache whether the direct mode
  49. // is set or not
  50. //
  51. DFSSTATUS
  52. Flush()
  53. {
  54. return GetMetadataBlobCache()->WriteBlobToAd(TRUE);
  55. }
  56. DFSSTATUS
  57. UpdateRootFromBlob( BOOLEAN fForceSync,
  58. BOOLEAN FromPDC);
  59. //
  60. // Function GetMetadataKey: Gets the ADBlob metadata key for
  61. // this root folder.
  62. //
  63. DFSSTATUS
  64. GetMetadataHandle( PDFS_METADATA_HANDLE pRootHandle )
  65. {
  66. DFSSTATUS Status = STATUS_SUCCESS;
  67. HRESULT hr = S_OK;
  68. DfsADBlobCache * pBlobCache = NULL;
  69. Status = GetMetadataKey( &pBlobCache );
  70. if(pBlobCache != NULL)
  71. {
  72. *pRootHandle = CreateMetadataHandle(pBlobCache);
  73. }
  74. return Status;
  75. }
  76. VOID
  77. ReleaseMetadataHandle( DFS_METADATA_HANDLE RootHandle )
  78. {
  79. DfsADBlobCache * pBlobCache = NULL;
  80. pBlobCache = (DfsADBlobCache*)ExtractFromMetadataHandle(RootHandle);
  81. ReleaseMetadataKey(pBlobCache);
  82. //
  83. // review: pContainer? where did this come from!
  84. //
  85. DestroyMetadataHandle(pContainer);
  86. return;
  87. }
  88. private:
  89. DFSSTATUS
  90. GetMetadataKey( DfsADBlobCache * *pBlobCache )
  91. {
  92. DFSSTATUS Status = ERROR_SUCCESS;
  93. *pBlobCache = GetMetadataBlobCache();
  94. if(*pBlobCache == NULL)
  95. {
  96. Status = ERROR_FILE_NOT_FOUND;
  97. }
  98. return Status;
  99. }
  100. VOID
  101. ReleaseMetadataKey( DfsADBlobCache * pBlobCache )
  102. {
  103. UNREFERENCED_PARAMETER(pBlobCache);
  104. return NOTHING;
  105. }
  106. public:
  107. //
  108. // Function DfsADBlobRootFolder: Constructor.
  109. // Initializes the ADBlobRootFolder class instance.
  110. //
  111. DfsADBlobRootFolder(
  112. LPWSTR NameContext,
  113. LPWSTR RootRegKeyName,
  114. PUNICODE_STRING pLogicalName,
  115. PUNICODE_STRING pPhysicalShare,
  116. DfsADBlobStore *pParentStore,
  117. DFSSTATUS *pStatus );
  118. ~DfsADBlobRootFolder()
  119. {
  120. DfsReleaseDomainName(&_DfsVisibleContext);
  121. if (_pBlobCache != NULL)
  122. {
  123. _pBlobCache->ReleaseReference();
  124. _pBlobCache = NULL;
  125. }
  126. if (_pStore != NULL)
  127. {
  128. _pStore->ReleaseReference();
  129. _pStore = NULL;
  130. }
  131. }
  132. //
  133. // Function Synchronize: This function overrides the synchronize
  134. // defined in the base class.
  135. // The synchronize function updates the root folder's children
  136. // with the uptodate information available in the store's metadata.
  137. //
  138. DFSSTATUS
  139. Synchronize(BOOLEAN fForceSynch = FALSE, BOOLEAN CalledByAPi = FALSE);
  140. DFSSTATUS
  141. EnumerateBlobCacheAndCreateFolders(void);
  142. DFSSTATUS
  143. GetMetadataLogicalToLinkName( PUNICODE_STRING pIn,
  144. PUNICODE_STRING pOut )
  145. {
  146. UNICODE_STRING ServerComp;
  147. UNICODE_STRING ShareComp;
  148. return DfsGetPathComponents( pIn,
  149. &ServerComp,
  150. &ShareComp,
  151. pOut );
  152. }
  153. VOID
  154. ReleaseMetadataLogicalToLinkName( PUNICODE_STRING pIn )
  155. {
  156. UNREFERENCED_PARAMETER(pIn);
  157. return NOTHING;
  158. }
  159. DFSSTATUS
  160. ReSynchronize(BOOLEAN fForceSync)
  161. {
  162. DFSSTATUS Status;
  163. Status = Synchronize(fForceSync);
  164. return Status;
  165. }
  166. DFSSTATUS
  167. RootRequestPrologue( LPWSTR DCName )
  168. {
  169. LPWSTR UseDCName = DCName;
  170. DfsString *pPDC = NULL;
  171. PVOID pHandle;
  172. DFSSTATUS Status = ERROR_SUCCESS;
  173. if (UseDCName == NULL)
  174. {
  175. Status = DfsGetBlobPDCName( &pPDC, DFS_FORCE_DC_QUERY );
  176. if(Status != ERROR_SUCCESS)
  177. {
  178. return Status;
  179. }
  180. UseDCName = pPDC->GetString();
  181. }
  182. Status = GetMetadataBlobCache()->GetADObject(&pHandle,
  183. UseDCName );
  184. DfsReleaseBlobPDCName(pPDC);
  185. return Status;
  186. }
  187. VOID
  188. RootRequestEpilogue()
  189. {
  190. GetMetadataBlobCache()->ReleaseADObject(NULL);
  191. }
  192. DFSSTATUS
  193. RootApiRequestPrologue(BOOLEAN WriteRequest,
  194. LPWSTR DCName = NULL)
  195. {
  196. DFSSTATUS Status;
  197. Status = RootRequestPrologue(DCName);
  198. if (Status == ERROR_SUCCESS)
  199. {
  200. Status = CommonRootApiPrologue( WriteRequest );
  201. if (Status != ERROR_SUCCESS)
  202. {
  203. GetMetadataBlobCache()->ReleaseADObject(NULL);
  204. }
  205. }
  206. return Status;
  207. }
  208. VOID
  209. RootApiRequestEpilogue(
  210. BOOLEAN WriteRequest,
  211. DFSSTATUS CompletionStatus )
  212. {
  213. if ((WriteRequest == TRUE) &&
  214. (CompletionStatus == ERROR_SUCCESS) &&
  215. (!DfsCheckDirectMode()))
  216. {
  217. SynchronizeRoots();
  218. }
  219. RootRequestEpilogue();
  220. return NOTHING;
  221. }
  222. DFSSTATUS
  223. RenameLinks(
  224. IN LPWSTR OldDomainName,
  225. IN LPWSTR NewDomainName);
  226. VOID SynchronizeRoots();
  227. ULONG
  228. GetBlobSize()
  229. {
  230. return GetMetadataBlobCache()->GetBlobSize();
  231. }
  232. DFSSTATUS
  233. GetSiteBlob(PVOID *ppBuffer, PULONG pSize)
  234. {
  235. return GetMetadataBlobCache()->GetSiteBlob(ppBuffer, pSize);
  236. }
  237. DFSSTATUS
  238. SetSiteBlob(PVOID pBuffer, ULONG Size)
  239. {
  240. return GetMetadataBlobCache()->SetSiteBlob(pBuffer, Size);
  241. }
  242. DFSSTATUS
  243. CheckResynchronizeAccess( DFSSTATUS AccessCheckStatus )
  244. {
  245. UNREFERENCED_PARAMETER(AccessCheckStatus);
  246. return ERROR_SUCCESS;
  247. }
  248. };
  249. #endif // __DFS_ADBLOB_ROOT_FOLDER__