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.

254 lines
13 KiB

  1. //mkdso.h
  2. //
  3. // Exit status codes. Exit codes start with 100 to keep them
  4. // distinct from the MKDSXE_ error codes in mkdsx.h
  5. //
  6. #define MKDSOE_SUCCESS 100 // "Success."
  7. #define MKDSOE_BAD_ARG 101 // "Invalid Arguments."
  8. #define MKDSOE_CANT_BIND 102 // "Could not bind to the DC."
  9. #define MKDSOE_NO_NTFRS_SETTINGS 103 // "Could not find 'NTFRS Settings' object. Check the /settingsdn parameter."
  10. #define MKDSOE_SET_OBJ_CRE_FAILED 104 // "Error creating replica set."
  11. #define MKDSOE_SET_OBJ_UPDATE_FAILED 105 // "Error updating replica set."
  12. #define MKDSOE_SET_NOT_FOUND_UPDATE 106 // "Error updating replica set; set not found."
  13. #define MKDSOE_SET_DUPS_FOUND_UPDATE 107 // "Error updating replica set; duplicate sets found."
  14. #define MKDSOE_SET_DUPS_FOUND_DELETE 108 // "Error deleting replica set; duplicate sets found."
  15. #define MKDSOE_SET_DELETE_FAILED 109 // "Error deleting replica set."
  16. #define MKDSOE_SET_NOT_FOUND_DELETE 110 // "Error deleting replica set; set not found."
  17. #define MKDSOE_MULTIPLE_SETS_DELETED 111 // "Deleting multiple sets."
  18. #define MKDSOE_SET_DUMP_FAILED 112 // "Error dumping replica set."
  19. #define MKDSOE_SET_NOT_FOUND_DUMP 113 // "Error dumping replica set; set not found."
  20. #define MKDSOE_MULTIPLE_SETS_DUMPED 114 // "Dumping duplicate sets."
  21. #define MKDSOE_MEMBER_OBJ_CRE_FAILED 115 // "Error creating replica member."
  22. #define MKDSOE_MEMBER_OBJ_UPDATE_FAILED 116 // "Error updating replica member."
  23. #define MKDSOE_MEMBER_NOT_FOUND_UPDATE 117 // "Error updating replica member; member not found."
  24. #define MKDSOE_MEMBER_DUPS_FOUND_UPDATE 118 // "Error updating replica member; duplicate members found."
  25. #define MKDSOE_MEMBER_DUPS_FOUND_DELETE 119 // "Error deleting member; duplicate subscribers found."
  26. #define MKDSOE_MEMBER_DELETE_FAILED 120 // "Error deleting replica member."
  27. #define MKDSOE_MEMBER_NOT_FOUND_DELETE 121 // "Error deleting replica member; member not found."
  28. #define MKDSOE_MULTIPLE_MEMBERS_DELETED 122 // "Deleting multiple members."
  29. #define MKDSOE_MEMBER_DUMP_FAILED 123 // "Error dumping replica member."
  30. #define MKDSOE_MEMBER_NOT_FOUND_DUMP 124 // "Error dumping replica member; member not found."
  31. #define MKDSOE_MULTIPLE_MEMBERS_DUMPED 125 // "Dumping duplicate members."
  32. #define MKDSOE_SUBSCRIBER_OBJ_CRE_FAILED 126 // "Error creating subscriber."
  33. #define MKDSOE_SUBSCRIBER_OBJ_UPDATE_FAILED 127 // "Error updating subscriber."
  34. #define MKDSOE_SUBSCRIBER_NOT_FOUND_UPDATE 128 // "Error updating subscriber; subscriber not found."
  35. #define MKDSOE_SUBSCRIBER_DUPS_FOUND_UPDATE 129 // "Error updating subscriber; duplicate subscribers found."
  36. #define MKDSOE_SUBSCRIBER_DELETE_FAILED 130 // "Error deleting subscriber."
  37. #define MKDSOE_SUBSCRIBER_NOT_FOUND_DELETE 131 // "Error deleting subscriber; subscriber not found."
  38. #define MKDSOE_MULTIPLE_SUBSCRIBERS_DELETE 132 // "Deleting multiple subscribers."
  39. #define MKDSOE_SUBSCRIBER_DUPS_FOUND_DELETE 133 // "Error deleting subscriber; duplicate subscribers found."
  40. #define MKDSOE_SUBSCRIBER_DUMP_FAILED 134 // "Error dumping subscriber."
  41. #define MKDSOE_SUBSCRIBER_NOT_FOUND_DUMP 135 // "Error dumping subscriber; subscriber not found."
  42. #define MKDSOE_MULTIPLE_SUBSCRIBERS_DUMPED 136 // "Dumping duplicate subscribers."
  43. #define MKDSOE_RSTYPE_MAX 4
  44. #define MKDSOE_SUBSCRIPTION L"NTFRS Subscriptions"
  45. #define FRST_SIZE_OF_SCHEDULE_GRID 168 // 168 bytes for the schedule (7days*24hours).
  46. #define FRST_SIZE_OF_SCHEDULE 188 // 20 bytes for the SCHEDULE and SCHEDULE_HEADER structure and
  47. #define WIN_SUCCESS(_Status) (_Status == ERROR_SUCCESS)
  48. #define FREE(_x_) { if (_x_) free(_x_); _x_ = NULL; }
  49. //
  50. // Is a handle valid?
  51. // Some functions set the handle to NULL and some to
  52. // INVALID_HANDLE_VALUE (-1). This define handles both
  53. // cases.
  54. //
  55. #define HANDLE_IS_VALID(_Handle) ((_Handle) && ((_Handle) != INVALID_HANDLE_VALUE))
  56. //
  57. // Only close valid handles and then set the handle invalid.
  58. // FRS_CLOSE(handle);
  59. //
  60. #define FRS_CLOSE(_Handle) \
  61. if (HANDLE_IS_VALID(_Handle)) { \
  62. CloseHandle(_Handle); \
  63. (_Handle) = INVALID_HANDLE_VALUE; \
  64. }
  65. VOID
  66. PrintSchedule(
  67. PSCHEDULE Schedule
  68. );
  69. #define FRS_LDAP_SEARCH_PAGESIZE 1000
  70. typedef struct _FRS_LDAP_SEARCH_CONTEXT {
  71. BOOL bOpen;
  72. ULONG EntriesInPage;
  73. ULONG CurrentEntry;
  74. ULONG TotalEntries;
  75. LDAPMessage * LdapMsg;
  76. LDAPMessage * CurrentLdapMsg;
  77. PWCHAR Filter;
  78. PWCHAR BaseDn;
  79. DWORD Scope;
  80. DWORD PageSize;
  81. PWCHAR * Attrs;
  82. } FRS_LDAP_SEARCH_CONTEXT, *PFRS_LDAP_SEARCH_CONTEXT;
  83. //Macros for prints.
  84. #define DPRINT0(str) (bVerboseMode) ? printf(str):printf("")
  85. #define DPRINT1(str,p1) (bVerboseMode) ? printf(str,p1):printf("")
  86. #define DPRINT2(str,p1,p2) (bVerboseMode) ? printf(str,p1,p2):printf("")
  87. #define DPRINT3(str,p1,p2,p3) (bVerboseMode) ? printf(str,p1,p2,p3):printf("")
  88. #define DPRINT4(str,p1,p2,p3,p4) (bVerboseMode) ? printf(str,p1,p2,p3,p4):printf("")
  89. #define NDPRINT0(str) (!bVerboseMode) ? printf(str):printf("")
  90. #define NDPRINT1(str,p1) (!bVerboseMode) ? printf(str,p1):printf("")
  91. #define NDPRINT2(str,p1,p2) (!bVerboseMode) ? printf(str,p1,p2):printf("")
  92. //
  93. // Some useful DS object classes and object attributes
  94. //
  95. #define SCHEMA_NAMING_CONTEXT L"CN=Schema"
  96. #define CONFIG_NAMING_CONTEXT L"CN=Configuration"
  97. #define DOMAIN_NAMING_CONTEXT L"DC="
  98. #define ATTR_ATTRIBUTE_ID L"attributeID"
  99. #define ATTR_AUTH_LEVEL L"frsPartnerAuthLevel"
  100. #define ATTR_CLASS L"objectClass"
  101. #define ATTR_CLASS_SCHEMA L"classSchema"
  102. #define ATTR_CN L"cn"
  103. #define ATTR_COMPUTER L"computer"
  104. #define ATTR_COMPUTER_REF L"frsComputerReference"
  105. #define ATTR_COMPUTER_REF_BL L"frsComputerReferenceBL"
  106. #define ATTR_CONTAINER L"container"
  107. #define ATTR_CONTROL_CREATION L"frsControlDataCreation"
  108. #define ATTR_CXTION L"nTDSConnection"
  109. #define ATTR_DEFAULT_NAMING_CONTEXT L"defaultNamingContext"
  110. #define ATTR_DESCRIPTION L"description"
  111. #define ATTR_DIRECTORY_FILTER L"frsDirectoryFilter"
  112. #define ATTR_DN L"distinguishedName"
  113. #define ATTR_DNS L"machineDNSName"
  114. #define ATTR_DNS_HOST_NAME L"dNSHostName"
  115. #define ATTR_DS_POLL L"frsDSPoll"
  116. #define ATTR_ENABLED_CXTION L"enabledConnection"
  117. #define ATTR_EXTENSIONS L"frsExtensions"
  118. #define ATTR_FALSE L"FALSE"
  119. #define ATTR_FAULT_CONDITION L"frsFaultCondition"
  120. #define ATTR_FILE_FILTER L"frsFileFilter"
  121. #define ATTR_FLAGS L"frsFlags"
  122. #define ATTR_FROM_SERVER L"fromServer"
  123. #define ATTR_GOVERNS_ID L"governsID"
  124. #define ATTR_INBOUND_BACKLOG L"frsControlInboundBacklog"
  125. #define ATTR_LDAP_DISPLAY L"lDAPDisplayName"
  126. #define ATTR_LEVEL_LIMIT L"frsLevelLimit"
  127. #define ATTR_MEMBER L"nTFRSMember"
  128. #define ATTR_MEMBER_REF L"frsMemberReference"
  129. #define ATTR_MEMBER_REF_BL L"frsMemberReferenceBL"
  130. #define ATTR_NAMING_CONTEXTS L"namingContexts"
  131. #define ATTR_NEW_SET_GUID L"frsReplicaSetGUID"
  132. #define ATTR_NEW_VERSION_GUID L"frsVersionGuid"
  133. #define ATTR_NTDS_SITE_SETTINGS L"nTDSSiteSettings"
  134. #define ATTR_NTFRS_SETTINGS L"nTFRSSettings"
  135. #define ATTR_NTFRS_SITE_SETTINGS L"nTFRSSiteSettings"
  136. #define ATTR_OBJECT_GUID L"objectGUID"
  137. #define ATTR_OLD_SET_GUID L"replicaSetGUID"
  138. #define ATTR_OLD_VERSION_GUID L"replicaVersionGuid"
  139. #define ATTR_OPTIONS L"options"
  140. #define ATTR_OPTIONS_0 L"0"
  141. #define ATTR_OUTBOUND_BACKLOG L"frsControlOutboundBacklog"
  142. #define ATTR_PRIMARY_MEMBER L"frsPrimaryMember"
  143. #define ATTR_REPLICA_ROOT L"frsRootPath"
  144. #define ATTR_REPLICA_SET L"nTFRSReplicaSet"
  145. #define ATTR_REPLICA_STAGE L"frsStagingPath"
  146. #define ATTR_ROOT L""
  147. #define ATTR_SAM L"sAMAccountName"
  148. #define ATTR_SCHEDULE L"schedule"
  149. #define ATTR_SERVER L"server"
  150. #define ATTR_SERVER_REF L"serverReference"
  151. #define ATTR_SERVER_REF_BL L"serverReferenceBL"
  152. #define ATTR_SERVICE_COMMAND L"frsServiceCommand"
  153. #define ATTR_SERVICE_COMMAND_STATUS L"frsServiceCommandStatus"
  154. #define ATTR_SET_TYPE L"frsReplicaSetType"
  155. #define ATTR_SUBSCRIBER L"nTFRSSubscriber"
  156. #define ATTR_SUBSCRIPTIONS L"nTFRSSubscriptions"
  157. #define ATTR_SUPERIORS L"possSuperiors"
  158. #define ATTR_SYSTEM_FLAGS L"systemFlags"
  159. #define ATTR_SYSTEM_MAY_CONTAIN L"systemMayContain"
  160. #define ATTR_SYSTEM_MUST_CONTAIN L"systemMustContain"
  161. #define ATTR_SYSTEM_POSS_SUPERIORS L"systemPossSuperiors"
  162. #define ATTR_TRUE L"TRUE"
  163. #define ATTR_UPDATE_TIMEOUT L"frsUpdateTimeout"
  164. #define ATTR_USER L"user"
  165. #define ATTR_VERSION L"frsVersion"
  166. #define ATTR_WORKING_PATH L"frsWorkingPath"
  167. #define CN_NTDS_SITE_SETTINGS L"NTDS Site Settings"
  168. #define CN_SERVERS L"Servers"
  169. #define CN_TEST_SETTINGS L"NTFRS Test Settings"
  170. #define CN_SUBSCRIPTIONS L"NTFRS Subscriptions"
  171. #define CN_SITES L"Sites"
  172. #define CN_SERVICES L"Services"
  173. #define CN_SYSTEM L"System"
  174. #define CN_SYSVOLS L"Microsoft System Volumes"
  175. #define CN_NTDS_SETTINGS L"NTDS Settings"
  176. #define CN_NTFRS_SETTINGS L"File Replication Service"
  177. #define CN_DOMAIN_SYSVOL L"Domain System Volume (SYSVOL share)"
  178. #define CLASS_ANY L"(objectClass=*)"
  179. #define CLASS_SUBSCRIPTIONS L"(objectClass=nTFRSSubscriptions)"
  180. #define CLASS_COMPUTER L"(objectClass=computer)"
  181. #define CLASS_SUBSCRIBER L"(objectClass=nTFRSSubscriber)"
  182. #define CLASS_NTFRS_SETTINGS L"(objectClass=nTFRSSettings)"
  183. #define CLASS_NTDS_SETTINGS L"(objectClass=nTDSSettings)"
  184. #define CLASS_CXTION L"(objectClass=nTDSConnection)"
  185. #define CLASS_NTFRS_REPLICA_SET L"(objectClass=nTFRSReplicaSet)"
  186. #define CLASS_SCHEMA L"(objectClass=classSchema)"
  187. #define CLASS_SERVER L"(objectClass=server)"
  188. #define CLASS_MEMBER L"(objectClass=nTFRSMember)"
  189. #define CLASS_NTDS_DSA L"(objectClass=nTDSDSA)"
  190. #define CLASS_SITE_SETTINGS L"(|(objectClass=nTDSSiteSettings)"\
  191. L"(objectClass=nTFRSSiteSettings))"
  192. #define CLASS_TOPOLOGY L"(|(objectClass=nTDSSettings)" \
  193. L"(objectClass=nTFRSSettings)" \
  194. L"(objectClass=nTFRSReplicaSet)" \
  195. L"(objectClass=nTDSConnection))"
  196. #define CLASS_DELETABLE L"(|(objectClass=nTFRSSiteSettings)" \
  197. L"(objectClass=nTFRSSettings)" \
  198. L"(objectClass=nTFRSReplicaSet)" \
  199. L"(objectClass=nTDSConnection))"
  200. #define MK_ATTRS_1(_attr_, _a1) \
  201. _attr_[0] = _a1; _attr_[1] = NULL;
  202. #define MK_ATTRS_2(_attr_, _a1, _a2) \
  203. _attr_[0] = _a1; _attr_[1] = _a2; _attr_[2] = NULL;
  204. #define MK_ATTRS_3(_attr_, _a1, _a2, _a3) \
  205. _attr_[0] = _a1; _attr_[1] = _a2; _attr_[2] = _a3; _attr_[3] = NULL;
  206. #define MK_ATTRS_4(_attr_, _a1, _a2, _a3, _a4) \
  207. _attr_[0] = _a1; _attr_[1] = _a2; _attr_[2] = _a3; _attr_[3] = _a4; \
  208. _attr_[4] = NULL;
  209. #define MK_ATTRS_5(_attr_, _a1, _a2, _a3, _a4, _a5) \
  210. _attr_[0] = _a1; _attr_[1] = _a2; _attr_[2] = _a3; _attr_[3] = _a4; \
  211. _attr_[4] = _a5; _attr_[5] = NULL;
  212. #define MK_ATTRS_6(_attr_, _a1, _a2, _a3, _a4, _a5, _a6) \
  213. _attr_[0] = _a1; _attr_[1] = _a2; _attr_[2] = _a3; _attr_[3] = _a4; \
  214. _attr_[4] = _a5; _attr_[5] = _a6; _attr_[6] = NULL;
  215. #define MK_ATTRS_7(_attr_, _a1, _a2, _a3, _a4, _a5, _a6, _a7) \
  216. _attr_[0] = _a1; _attr_[1] = _a2; _attr_[2] = _a3; _attr_[3] = _a4; \
  217. _attr_[4] = _a5; _attr_[5] = _a6; _attr_[6] = _a7; _attr_[7] = NULL;
  218. #define MK_ATTRS_8(_attr_, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) \
  219. _attr_[0] = _a1; _attr_[1] = _a2; _attr_[2] = _a3; _attr_[3] = _a4; \
  220. _attr_[4] = _a5; _attr_[5] = _a6; _attr_[6] = _a7; _attr_[7] = _a8; \
  221. _attr_[8] = NULL;