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.

212 lines
5.3 KiB

  1. /*++
  2. Copyright (c) 1991-1997 Microsoft Corporation
  3. Module Name:
  4. changelg.h
  5. Abstract:
  6. Defines and routines needed to interface with changelg.c.
  7. Read the comments in the abstract for changelg.c to determine the
  8. restrictions on the use of that module.
  9. Author:
  10. Cliff Van Dyke (cliffv) 07-May-1992
  11. Environment:
  12. User mode only.
  13. Contains NT-specific code.
  14. Requires ANSI C extensions: slash-slash comments, long external names.
  15. Revision History:
  16. 02-Jan-1992 (madana)
  17. added support for builtin/multidomain replication.
  18. --*/
  19. #if ( _MSC_VER >= 800 )
  20. #pragma warning ( 3 : 4100 ) // enable "Unreferenced formal parameter"
  21. #pragma warning ( 3 : 4219 ) // enable "trailing ',' used for variable argument list"
  22. #endif
  23. #define DS_VALID_SERVICE_BITS ( DS_WRITABLE_FLAG | DS_KDC_FLAG | DS_DS_FLAG | DS_TIMESERV_FLAG | DS_GC_FLAG | DS_GOOD_TIMESERV_FLAG)
  24. #define DS_OUTOFPROC_VALID_SERVICE_BITS ( DS_TIMESERV_FLAG | DS_GOOD_TIMESERV_FLAG )
  25. #define DS_DNS_SERVICE_BITS ( DS_KDC_FLAG | DS_GC_FLAG | DS_DS_FLAG )
  26. /////////////////////////////////////////////////////////////////////////////
  27. //
  28. // Structures and variables describing the Change Log
  29. //
  30. /////////////////////////////////////////////////////////////////////////////
  31. //
  32. // Change log entry is a variable length record, the variable fields SID and
  33. // ObjectName will follow the structure.
  34. //
  35. typedef struct _CHANGELOG_ENTRY_V3 {
  36. LARGE_INTEGER SerialNumber; // always align this on 8 byte boundary
  37. DWORD Size;
  38. USHORT DeltaType;
  39. UCHAR DBIndex;
  40. UCHAR ReplicateImmediately;
  41. ULONG ObjectRid;
  42. USHORT ObjectSidOffset;
  43. USHORT ObjectNameOffset; // null terminated unicode string
  44. } CHANGELOG_ENTRY_V3, *PCHANGELOG_ENTRY_V3;
  45. typedef struct _CHANGELOG_ENTRY {
  46. LARGE_INTEGER SerialNumber; // always align this on 8 byte boundary
  47. ULONG ObjectRid;
  48. USHORT Flags;
  49. #define CHANGELOG_SID_SPECIFIED 0x04
  50. #define CHANGELOG_NAME_SPECIFIED 0x08
  51. #define CHANGELOG_PDC_PROMOTION 0x10
  52. //
  53. // The following bits were used in NT 4.0. Avoid them if at all possible
  54. #define CHANGELOG_REPLICATE_IMMEDIATELY 0x01
  55. #define CHANGELOG_PASSWORD_CHANGE 0x02
  56. #define CHANGELOG_PREVIOUSLY_USED_BITS 0x23
  57. UCHAR DBIndex;
  58. UCHAR DeltaType;
  59. } CHANGELOG_ENTRY, *PCHANGELOG_ENTRY;
  60. //
  61. // List of changes the netlogon needs to be aware of.
  62. //
  63. typedef struct _CHANGELOG_NOTIFICATION {
  64. LIST_ENTRY Next;
  65. enum CHANGELOG_NOTIFICATION_TYPE {
  66. ChangeLogTrustAccountAdded, // ObjectName/ObjectRid specified
  67. ChangeLogTrustAccountDeleted, // ObjectName specified
  68. ChangeLogTrustAdded, // ObjectSid specified
  69. ChangeLogTrustDeleted, // ObjectSid specified
  70. ChangeLogRoleChanged, // Role of the LSA changed
  71. ChangeDnsNames, // DNS names should change
  72. ChangeLogDsChanged, // Sundry DS information changed
  73. ChangeLogLsaPolicyChanged, // Sundry LSA Policy information changed
  74. ChangeLogNtdsDsaDeleted // NTDS-DSA object deleted
  75. } EntryType;
  76. UNICODE_STRING ObjectName;
  77. PSID ObjectSid;
  78. ULONG ObjectRid;
  79. GUID ObjectGuid;
  80. GUID DomainGuid;
  81. UNICODE_STRING DomainName;
  82. } CHANGELOG_NOTIFICATION, *PCHANGELOG_NOTIFICATION;
  83. //
  84. // To serialize change log access
  85. //
  86. #define LOCK_CHANGELOG() EnterCriticalSection( &NlGlobalChangeLogCritSect )
  87. #define UNLOCK_CHANGELOG() LeaveCriticalSection( &NlGlobalChangeLogCritSect )
  88. //
  89. // Index to supported data bases.
  90. //
  91. #define SAM_DB 0 // index to SAM database structure
  92. #define BUILTIN_DB 1 // index to BUILTIN database structure
  93. #define LSA_DB 2 // index to LSA database
  94. #define VOID_DB 3 // index to unused database (used to mark changelog
  95. // entry as invalid)
  96. #define NUM_DBS 3 // number of databases supported
  97. //
  98. // Netlogon started flag, used by the changelog to determine the
  99. // netlogon service is successfully started and initialization
  100. // completed.
  101. //
  102. typedef enum {
  103. NetlogonStopped,
  104. NetlogonStarting,
  105. NetlogonStarted
  106. } _CHANGELOG_NETLOGON_STATE;
  107. //
  108. // Role of the machine from the changelog's perspective.
  109. //
  110. typedef enum _CHANGELOG_ROLE {
  111. ChangeLogPrimary,
  112. ChangeLogBackup,
  113. ChangeLogMemberWorkstation,
  114. ChangeLogUnknown
  115. } CHANGELOG_ROLE;
  116. /////////////////////////////////////////////////////////////////////////////
  117. //
  118. // Procedure forwards
  119. //
  120. /////////////////////////////////////////////////////////////////////////////
  121. NTSTATUS
  122. NlInitChangeLog(
  123. VOID
  124. );
  125. NTSTATUS
  126. NlCloseChangeLog(
  127. VOID
  128. );
  129. NTSTATUS
  130. NetpNotifyRole (
  131. IN POLICY_LSA_SERVER_ROLE Role
  132. );
  133. DWORD
  134. NlBackupChangeLogFile(
  135. VOID
  136. );
  137. NET_API_STATUS
  138. NlpFreeNetlogonDllHandles (
  139. VOID
  140. );
  141. NTSTATUS
  142. NlSendChangeLogNotification(
  143. IN enum CHANGELOG_NOTIFICATION_TYPE EntryType,
  144. IN PUNICODE_STRING ObjectName,
  145. IN PSID ObjectSid,
  146. IN ULONG ObjectRid,
  147. IN GUID *ObjectGuid,
  148. IN GUID *DomainGuid,
  149. IN PUNICODE_STRING DomainName
  150. );
  151. VOID
  152. NlWaitForChangeLogBrowserNotify(
  153. VOID
  154. );