Source code of Windows XP (NT5)
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.

644 lines
17 KiB

  1. /*++ BUILD Version: 0001 Increment if a change has global effects
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. ntfrsapi.h
  5. Abstract:
  6. Header file for the application programmer's interfaces to the
  7. File Replication Service (NtFrs) that support they system volumes
  8. and DC Promotion / Demotion.
  9. Environment:
  10. User Mode - Win32
  11. Notes:
  12. --*/
  13. #ifndef _NTFRSAPI_H_
  14. #define _NTFRSAPI_H_
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. //
  19. // Pull in public headers for compat.
  20. //
  21. #include <frsapip.h>
  22. //
  23. // If a file or dir create has a name that starts with the following GUID
  24. // then FRS does not replicate the created file or dir. Note: For dirs
  25. // this means that the directory is never entered in the FRS directory filter
  26. // table so FRS will never replicate the dir (even after it is renamed) or
  27. // any changes to the dir (like ACLs or added streams or attrib changes) or
  28. // any children created under the dir.
  29. //
  30. #define NTFRS_REPL_SUPPRESS_PREFIX L"2ca04e7e-44c8-4076-8890a424b8ad193e"
  31. DWORD
  32. WINAPI
  33. NtFrsApi_PrepareForPromotionW(
  34. IN DWORD ErrorCallBack(IN PWCHAR, IN ULONG) OPTIONAL
  35. );
  36. /*++
  37. Routine Description:
  38. The NtFrs service seeds the system volume during the promotion
  39. of a server to a Domain Controller (DC). The files and directories
  40. for the system volume come from the same machine that is supplying
  41. the initial Directory Service (DS).
  42. This function prepares the NtFrs service on this machine for
  43. promotion by stopping the service, deleting old promotion
  44. state in the registry, and restarting the service.
  45. This function is not idempotent and isn't MT safe.
  46. Arguments:
  47. None.
  48. Return Value:
  49. Win32 Status
  50. --*/
  51. DWORD
  52. WINAPI
  53. NtFrsApi_PrepareForDemotionUsingCredW(
  54. IN SEC_WINNT_AUTH_IDENTITY *Credentials, OPTIONAL
  55. IN HANDLE ClientToken,
  56. IN DWORD ErrorCallBack(IN PWCHAR, IN ULONG) OPTIONAL
  57. );
  58. /*++
  59. Routine Description:
  60. The NtFrs service replicates the enterprise system volume to all
  61. Domain Controllers (DCs) and replicates the domain system volume
  62. to the DCs in a domain until the DC is demoted to a member server.
  63. Replication is stopped by tombstoning the system volume's replica
  64. set.
  65. This function prepares the NtFrs service on this machine for
  66. demotion by stopping the service, deleting old demotion
  67. state in the registry, and restarting the service.
  68. This function is not idempotent and isn't MT safe.
  69. Arguments:
  70. Credentials -- Credentionals to use in ldap binding call, if supplied.
  71. ClientToken -- Impersonation token to use if no Credentials supplied.
  72. Return Value:
  73. Win32 Status
  74. --*/
  75. DWORD
  76. WINAPI
  77. NtFrsApi_PrepareForDemotionW(
  78. IN DWORD ErrorCallBack(IN PWCHAR, IN ULONG) OPTIONAL
  79. );
  80. /*++
  81. Routine Description:
  82. The NtFrs service replicates the enterprise system volume to all
  83. Domain Controllers (DCs) and replicates the domain system volume
  84. to the DCs in a domain until the DC is demoted to a member server.
  85. Replication is stopped by tombstoning the system volume's replica
  86. set.
  87. This function prepares the NtFrs service on this machine for
  88. demotion by stopping the service, deleting old demotion
  89. state in the registry, and restarting the service.
  90. This function is not idempotent and isn't MT safe.
  91. Arguments:
  92. None.
  93. Return Value:
  94. Win32 Status
  95. --*/
  96. #define NTFRSAPI_SERVICE_STATE_IS_UNKNOWN (00)
  97. #define NTFRSAPI_SERVICE_PROMOTING (10)
  98. #define NTFRSAPI_SERVICE_DEMOTING (20)
  99. #define NTFRSAPI_SERVICE_DONE (99)
  100. DWORD
  101. WINAPI
  102. NtFrsApi_StartPromotionW(
  103. IN PWCHAR ParentComputer, OPTIONAL
  104. IN PWCHAR ParentAccount, OPTIONAL
  105. IN PWCHAR ParentPassword, OPTIONAL
  106. IN DWORD DisplayCallBack(IN PWCHAR Display), OPTIONAL
  107. IN DWORD ErrorCallBack(IN PWCHAR, IN ULONG), OPTIONAL
  108. IN PWCHAR ReplicaSetName,
  109. IN PWCHAR ReplicaSetType,
  110. IN DWORD ReplicaSetPrimary,
  111. IN PWCHAR ReplicaSetStage,
  112. IN PWCHAR ReplicaSetRoot
  113. );
  114. /*++
  115. Routine Description:
  116. The NtFrs service seeds the system volume during the promotion
  117. of a server to a Domain Controller (DC). The files and directories
  118. for the system volume come from the same machine that is supplying
  119. the initial Directory Service (DS).
  120. This function kicks off a thread that updates the sysvol information
  121. in the registry and initiates the seeding process. The thread tracks
  122. the progress of the seeding and periodically informs the caller.
  123. The threads started by NtFrsApi_StartPromotionW can be forcefully
  124. terminated with NtFrsApi_AbortPromotionW.
  125. The threads started by NtFrsApi_StartPromotionW can be waited on
  126. with NtFrsApi_WaitForPromotionW.
  127. Arguments:
  128. ParentComputer - An RPC-bindable name of the computer that is
  129. supplying the Directory Service (DS) with its
  130. initial state. The files and directories for
  131. the system volume are replicated from this
  132. parent computer.
  133. ParentAccount - A logon account on ParentComputer.
  134. ParentPassword - The logon account's password on ParentComputer.
  135. DisplayCallBack - Called periodically with a progress display.
  136. ReplicaSetName - Name of the replica set.
  137. ReplicaSetType - Type of replica set (enterprise or domain)
  138. ReplicaSetPrimary - Is this the primary member of the replica set?
  139. - 1 = primary; 0 = not.
  140. ReplicaSetStage - Staging path.
  141. ReplicaSetRoot - Root path.
  142. Return Value:
  143. Win32 Status
  144. --*/
  145. DWORD
  146. WINAPI
  147. NtFrsApi_StartDemotionW(
  148. IN PWCHAR ReplicaSetName,
  149. IN DWORD ErrorCallBack(IN PWCHAR, IN ULONG) OPTIONAL
  150. );
  151. /*++
  152. Routine Description:
  153. The NtFrs service replicates the enterprise system volume to all
  154. Domain Controllers (DCs) and replicates the domain system volume
  155. to the DCs in a domain until the DC is demoted to a member server.
  156. Replication is stopped by tombstoning the system volume's replica
  157. set.
  158. This function kicks off a thread that stops replication of the
  159. system volume on this machine by telling the NtFrs service on
  160. this machine to tombstone the system volume's replica set.
  161. The threads started by NtFrsApi_StartDemotionW can be forcefully
  162. terminated with NtFrsApi_AbortDemotionW.
  163. The threads started by NtFrsApi_StartDemotionW can be waited on
  164. with NtFrsApi_WaitForDemotionW.
  165. Arguments:
  166. ReplicaSetName - Name of the replica set.
  167. Return Value:
  168. Win32 Status
  169. --*/
  170. DWORD
  171. WINAPI
  172. NtFrsApi_WaitForPromotionW(
  173. IN DWORD TimeoutInMilliSeconds,
  174. IN DWORD ErrorCallBack(IN PWCHAR, IN ULONG) OPTIONAL
  175. );
  176. /*++
  177. Routine Description:
  178. The NtFrs service seeds the system volume during the promotion
  179. of a server to a Domain Controller (DC). The files and directories
  180. for the system volume come from the same machine that is supplying
  181. the initial Directory Service (DS).
  182. This function waits for the seeding to finish or to stop w/error.
  183. Arguments:
  184. TimeoutInMilliSeconds - Timeout in milliseconds for waiting for
  185. seeding to finish. INFINITE if no timeout.
  186. Return Value:
  187. Win32 Status
  188. --*/
  189. DWORD
  190. WINAPI
  191. NtFrsApi_WaitForDemotionW(
  192. IN DWORD TimeoutInMilliSeconds,
  193. IN DWORD ErrorCallBack(IN PWCHAR, IN ULONG) OPTIONAL
  194. );
  195. /*++
  196. Routine Description:
  197. The NtFrs service replicates the enterprise system volume to all
  198. Domain Controllers (DCs) and replicates the domain system volume
  199. to the DCs in a domain until the DC is demoted to a member server.
  200. Replication is stopped by tombstoning the system volume's replica
  201. set.
  202. This function waits for the tombstoning to finish or to stop w/error.
  203. Arguments:
  204. TimeoutInMilliSeconds - Timeout in milliseconds for waiting for
  205. seeding to finish. INFINITE if no timeout.
  206. Return Value:
  207. Win32 Status
  208. --*/
  209. DWORD
  210. WINAPI
  211. NtFrsApi_CommitPromotionW(
  212. IN DWORD TimeoutInMilliSeconds,
  213. IN DWORD ErrorCallBack(IN PWCHAR, IN ULONG) OPTIONAL
  214. );
  215. /*++
  216. Routine Description:
  217. WARNING - This function assumes the caller will reboot the system
  218. soon after this call!
  219. The NtFrs service seeds the system volume during the promotion
  220. of a server to a Domain Controller (DC). The files and directories
  221. for the system volume come from the same machine that is supplying
  222. the initial Directory Service (DS).
  223. This function waits for the seeding to finish, stops the service,
  224. and commits the state in the registry. On reboot, the NtFrs Service
  225. updates the DS on this machine with the information in the registry.
  226. Arguments:
  227. TimeoutInMilliSeconds - Timeout in milliseconds for waiting for
  228. seeding to finish. INFINITE if no timeout.
  229. Return Value:
  230. Win32 Status
  231. --*/
  232. DWORD
  233. WINAPI
  234. NtFrsApi_CommitDemotionW(
  235. IN DWORD TimeoutInMilliSeconds,
  236. IN DWORD ErrorCallBack(IN PWCHAR, IN ULONG) OPTIONAL
  237. );
  238. /*++
  239. Routine Description:
  240. WARNING - This function assumes the caller will reboot the system
  241. soon after this call!
  242. The NtFrs service replicates the enterprise system volume to all
  243. Domain Controllers (DCs) and replicates the domain system volume
  244. to the DCs in a domain until the DC is demoted to a member server.
  245. Replication is stopped by tombstoning the system volume's replica
  246. set.
  247. This function waits for the tombstoning to finish, tells the service
  248. to forcibly delete the system volumes' replica sets, stops the service,
  249. and commits the state in the registry. On reboot, the NtFrs Service
  250. updates the DS on this machine with the information in the registry.
  251. Arguments:
  252. TimeoutInMilliSeconds - Timeout in milliseconds for waiting for
  253. tombstoning to finish. INFINITE if no timeout.
  254. Return Value:
  255. Win32 Status
  256. --*/
  257. DWORD
  258. WINAPI
  259. NtFrsApi_AbortPromotionW(
  260. VOID
  261. );
  262. /*++
  263. Routine Description:
  264. The NtFrs service seeds the system volume during the promotion
  265. of a server to a Domain Controller (DC). The files and directories
  266. for the system volume come from the same machine that is supplying
  267. the initial Directory Service (DS).
  268. This function aborts the seeding process by stopping the service,
  269. deleting the promotion state out of the registry, cleaning up
  270. the active threads and the active RPC calls, and finally resetting
  271. the service to its pre-seeding state.
  272. Arguments:
  273. None.
  274. Return Value:
  275. Win32 Status
  276. --*/
  277. DWORD
  278. WINAPI
  279. NtFrsApi_AbortDemotionW(
  280. VOID
  281. );
  282. /*++
  283. Routine Description:
  284. The NtFrs service replicates the enterprise system volume to all
  285. Domain Controllers (DCs) and replicates the domain system volume
  286. to the DCs in a domain until the DC is demoted to a member server.
  287. During demotion, NtFrsApi_StartDemotionW stops replication of
  288. the system volume on this machine by telling the NtFrs service
  289. on this machine to tombstone the system volume's replica set.
  290. This function aborts the tombstoning process by stopping the service,
  291. deleting the demotion state out of the registry, cleaning up
  292. the active threads and the active RPC calls, and finally resetting
  293. the service to its pre-tombstoning state.
  294. Arguments:
  295. None.
  296. Return Value:
  297. Win32 Status
  298. --*/
  299. //
  300. // Type of internal information returned by NtFrsApi_InfoW()
  301. //
  302. #define NTFRSAPI_INFO_TYPE_MIN (0)
  303. #define NTFRSAPI_INFO_TYPE_VERSION (0)
  304. #define NTFRSAPI_INFO_TYPE_SETS (1)
  305. #define NTFRSAPI_INFO_TYPE_DS (2)
  306. #define NTFRSAPI_INFO_TYPE_MEMORY (3)
  307. #define NTFRSAPI_INFO_TYPE_IDTABLE (4)
  308. #define NTFRSAPI_INFO_TYPE_OUTLOG (5)
  309. #define NTFRSAPI_INFO_TYPE_INLOG (6)
  310. #define NTFRSAPI_INFO_TYPE_THREADS (7)
  311. #define NTFRSAPI_INFO_TYPE_STAGE (8)
  312. #define NTFRSAPI_INFO_TYPE_CONFIGTABLE (9)
  313. #define NTFRSAPI_INFO_TYPE_MAX (10)
  314. //
  315. // Internal constants
  316. //
  317. #define NTFRSAPI_DEFAULT_INFO_SIZE (32 * 1024)
  318. #define NTFRSAPI_MINIMUM_INFO_SIZE ( 1 * 1024)
  319. //
  320. // Opaque information from NtFrs.
  321. // Parse with NtFrsApi_InfoLineW().
  322. // Free with NtFrsApi_InfoFreeW();
  323. //
  324. typedef struct _NTFRSAPI_INFO {
  325. ULONG Major;
  326. ULONG Minor;
  327. ULONG NtFrsMajor;
  328. ULONG NtFrsMinor;
  329. ULONG SizeInChars;
  330. ULONG Flags;
  331. ULONG TypeOfInfo;
  332. ULONG TotalChars;
  333. ULONG CharsToSkip;
  334. ULONG OffsetToLines;
  335. ULONG OffsetToFree;
  336. CHAR Lines[1];
  337. } NTFRSAPI_INFO, *PNTFRSAPI_INFO;
  338. //
  339. // RPC Blob must be at least this size
  340. //
  341. #define NTFRSAPI_INFO_HEADER_SIZE (5 * sizeof(ULONG))
  342. //
  343. // NtFrsApi Information Flags
  344. //
  345. #define NTFRSAPI_INFO_FLAGS_VERSION (0x00000001)
  346. #define NTFRSAPI_INFO_FLAGS_FULL (0x00000002)
  347. DWORD
  348. WINAPI
  349. NtFrsApi_InfoW(
  350. IN PWCHAR ComputerName, OPTIONAL
  351. IN ULONG TypeOfInfo,
  352. IN ULONG SizeInChars,
  353. IN OUT PVOID *NtFrsApiInfo
  354. );
  355. /*++
  356. Routine Description:
  357. Return a buffer full of the requested information. The information
  358. can be extracted from the buffer with NtFrsApi_InfoLineW().
  359. *NtFrsApiInfo should be NULL on the first call. On subsequent calls,
  360. *NtFrsApiInfo will be filled in with more data if any is present.
  361. Otherwise, *NtFrsApiInfo is set to NULL and the memory is freed.
  362. The SizeInChars is a suggested size; the actual memory usage
  363. may be different. The function chooses the memory usage if
  364. SizeInChars is 0.
  365. The format of the returned information can change without notice.
  366. Arguments:
  367. ComputerName - Poke the service on this computer. The computer
  368. name can be any RPC-bindable name. Usually, the
  369. NetBIOS or DNS name works just fine. The NetBIOS
  370. name can be found with GetComputerName() or
  371. hostname. The DNS name can be found with
  372. gethostbyname() or ipconfig /all. If NULL, the
  373. service on this computer is contacted. The service
  374. is contacted using Secure RPC.
  375. TypeOfInfo - See the constants beginning with NTFRSAPI_INFO_
  376. in ntfrsapi.h.
  377. SizeInChars - Suggested memory usage; actual may be different.
  378. 0 == Function chooses memory usage
  379. NtFrsApiInfo - Opaque. Parse with NtFrsApi_InfoLineW().
  380. Free with NtFrsApi_InfoFreeW();
  381. Return Value:
  382. Win32 Status
  383. --*/
  384. DWORD
  385. WINAPI
  386. NtFrsApi_InfoLineW(
  387. IN PNTFRSAPI_INFO NtFrsApiInfo,
  388. IN OUT PVOID *InOutLine
  389. );
  390. /*++
  391. Routine Description:
  392. Extract the wchar lines of information from NtFrsApiInformation.
  393. Returns the address of the next L'\0' terminated line of information.
  394. NULL if none.
  395. Arguments:
  396. NtFrsApiInfo - Opaque. Returned by NtFrsApi_InfoW().
  397. Parse with NtFrsApi_InfoLineW().
  398. Free with NtFrsApi_InfoFreeW().
  399. Return Value:
  400. Win32 Status
  401. --*/
  402. BOOL
  403. WINAPI
  404. NtFrsApi_InfoMoreW(
  405. IN PNTFRSAPI_INFO NtFrsApiInfo
  406. );
  407. /*++
  408. Routine Description:
  409. All of the information may not have fit in the buffer. The additional
  410. information can be fetched by calling NtFrsApi_InfoW() again with the
  411. same NtFrsApiInfo struct. NtFrsApi_InfoW() will return NULL in
  412. NtFrsApiInfo if there is no more information.
  413. However, the information returned in subsequent calls to _InfoW() may be
  414. out of sync with the previous information. If the user requires a
  415. coherent information set, then the information buffer should be freed
  416. with NtFrsApi_InfoFreeW() and another call made to NtFrsApi_InfoW()
  417. with an increased SizeInChars. Repeat the procedure until
  418. NtFrsApi_InfoMoreW() returns FALSE.
  419. Arguments:
  420. NtFrsApiInfo - Opaque. Returned by NtFrsApi_InfoW().
  421. Parse with NtFrsApi_InfoLineW().
  422. Free with NtFrsApi_InfoFreeW().
  423. Return Value:
  424. TRUE - The information buffer does *NOT* contain all of the info.
  425. FALSE - The information buffer does contain all of the info.
  426. --*/
  427. DWORD
  428. WINAPI
  429. NtFrsApi_InfoFreeW(
  430. IN PVOID *NtFrsApiInfo
  431. );
  432. /*++
  433. Routine Description:
  434. Free the information buffer allocated by NtFrsApi_InfoW();
  435. Arguments:
  436. NtFrsApiInfo - Opaque. Returned by NtFrsApi_InfoW().
  437. Parse with NtFrsApi_InfoLineW().
  438. Free with NtFrsApi_InfoFreeW().
  439. Return Value:
  440. Win32 Status
  441. --*/
  442. DWORD
  443. WINAPI
  444. NtFrsApi_DeleteSysvolMember(
  445. IN PSEC_WINNT_AUTH_IDENTITY_W pCreds,
  446. IN PWCHAR BindingDC,
  447. IN PWCHAR NTDSSettingsDn,
  448. IN OPTIONAL PWCHAR ComputerDn
  449. );
  450. /*++
  451. Routine Description:
  452. This API is written to be called from NTDSUTIL.EXE to remove
  453. FRS member and subscriber object for a server that is being
  454. removed (without dcpromo-demote) from the list of DCs.
  455. Arguments:
  456. pCreds p Credentials used to bind to the DS.
  457. BindingDC - Name of a DC to perform the delete on.
  458. NTDSSettingsDn - Dn of the "NTDS Settings" object for the server
  459. that is being removed from the sysvol replica set.
  460. ComputerDn - Dn of the computer object for the server that is
  461. being removed from the sysvol replica set.
  462. Return Value:
  463. Win32 Status
  464. --*/
  465. #ifdef __cplusplus
  466. }
  467. #endif
  468. #endif _NTFRSAPI_H_