windowsrepl.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. /* windows_private.c */
  13. typedef struct windowsprivate Dirsync_Private;
  14. typedef struct subtreepair {
  15. Slapi_DN *ADsubtree;
  16. Slapi_DN *DSsubtree;
  17. } subtreePair;
  18. Dirsync_Private* windows_private_new();
  19. void windows_private_set_windows_subtree (const Repl_Agmt *ra,Slapi_DN* sdn );
  20. const Slapi_DN* windows_private_get_windows_subtree (const Repl_Agmt *ra);
  21. void windows_private_set_directory_subtree (const Repl_Agmt *ra,Slapi_DN* sdn );
  22. const Slapi_DN* windows_private_get_directory_subtree (const Repl_Agmt *ra);
  23. LDAPControl* windows_private_dirsync_control(const Repl_Agmt *ra);
  24. ConnResult send_dirsync_search(Repl_Connection *conn);
  25. ConnResult windows_search_entry(Repl_Connection *conn, char* searchbase, char *filter, Slapi_Entry **entry);
  26. ConnResult windows_search_entry_ext(Repl_Connection *conn, char* searchbase, char *filter, Slapi_Entry **entry, LDAPControl **serverctrls, int scope);
  27. Slapi_Entry *windows_conn_get_search_result(Repl_Connection *conn );
  28. void windows_private_update_dirsync_control(const Repl_Agmt *ra,LDAPControl **controls );
  29. PRBool windows_private_dirsync_has_more(const Repl_Agmt *ra);
  30. void windows_private_null_dirsync_cookie(const Repl_Agmt *ra);
  31. int windows_private_save_dirsync_cookie(const Repl_Agmt *ra);
  32. int windows_private_load_dirsync_cookie(const Repl_Agmt *ra);
  33. void windows_private_set_create_users(const Repl_Agmt *ra, PRBool value);
  34. PRBool windows_private_create_users(const Repl_Agmt *ra);
  35. void windows_private_set_create_groups(const Repl_Agmt *ra, PRBool value);
  36. PRBool windows_private_create_groups(const Repl_Agmt *ra);
  37. const char *windows_private_get_windows_domain(const Repl_Agmt *ra);
  38. int windows_private_get_isnt4(const Repl_Agmt *ra);
  39. void windows_private_set_isnt4(const Repl_Agmt *ra, int isit);
  40. int windows_private_get_iswin2k3(const Repl_Agmt *ra);
  41. void windows_private_set_iswin2k3(const Repl_Agmt *ra, int isit);
  42. Slapi_Filter* windows_private_get_directory_filter(const Repl_Agmt *ra);
  43. Slapi_Filter* windows_private_get_windows_filter(const Repl_Agmt *ra);
  44. Slapi_Filter* windows_private_get_deleted_filter(const Repl_Agmt *ra);
  45. const char* windows_private_get_purl(const Repl_Agmt *ra);
  46. /*
  47. * The raw entry is the last raw entry read from AD - raw as opposed
  48. * "cooked" - that is, having had schema processing done
  49. */
  50. /* get returns a pointer to the structure - do not free */
  51. Slapi_Entry *windows_private_get_raw_entry(const Repl_Agmt *ra);
  52. /* this is passin - windows_private owns the pointer, not a copy */
  53. void windows_private_set_raw_entry(const Repl_Agmt *ra, Slapi_Entry *e);
  54. void windows_private_set_keep_raw_entry(const Repl_Agmt *ra, int keep);
  55. int windows_private_get_keep_raw_entry(const Repl_Agmt *ra);
  56. void *windows_private_get_api_cookie(const Repl_Agmt *ra);
  57. void windows_private_set_api_cookie(Repl_Agmt *ra, void *cookie);
  58. time_t windows_private_get_sync_interval(const Repl_Agmt *ra);
  59. void windows_private_set_sync_interval(Repl_Agmt *ra, char *str);
  60. PRBool windows_private_get_one_way(const Repl_Agmt *ra);
  61. void windows_private_set_one_way(const Repl_Agmt *ra, PRBool value);
  62. int windows_private_get_move_action(const Repl_Agmt *ra);
  63. void windows_private_set_move_action(const Repl_Agmt *ra, int value);
  64. void windows_private_set_directory_userfilter(const Repl_Agmt *ra, char *filter);
  65. void windows_private_set_windows_userfilter(const Repl_Agmt *ra, char *filter);
  66. const char* windows_private_get_directory_userfilter(const Repl_Agmt *ra);
  67. const char* windows_private_get_windows_userfilter(const Repl_Agmt *ra);
  68. const subtreePair* windows_private_get_subtreepairs(const Repl_Agmt *ra);
  69. void windows_private_set_subtreepairs(const Repl_Agmt *ra, char **parray);
  70. const Slapi_DN* windows_private_get_windows_treetop(const Repl_Agmt *ra);
  71. void windows_private_set_windows_treetop(const Repl_Agmt *ra, char *treetop);
  72. const Slapi_DN* windows_private_get_directory_treetop(const Repl_Agmt *ra);
  73. void windows_private_set_directory_treetop(const Repl_Agmt *ra, char *treetop);
  74. /* in windows_connection.c */
  75. ConnResult windows_conn_connect(Repl_Connection *conn);
  76. void windows_conn_disconnect(Repl_Connection *conn);
  77. void windows_conn_get_error(Repl_Connection *conn, int *operation, int *error);
  78. void windows_conn_set_error(Repl_Connection *conn, int error);
  79. ConnResult windows_conn_send_add(Repl_Connection *conn, const char *dn, LDAPMod **attrs,
  80. LDAPControl **server_controls, LDAPControl ***returned_controls);
  81. ConnResult windows_conn_send_delete(Repl_Connection *conn, const char *dn,
  82. LDAPControl **server_controls, LDAPControl ***returned_controls);
  83. ConnResult windows_conn_send_modify(Repl_Connection *conn, const char *dn, LDAPMod **mods,
  84. LDAPControl **server_controls, LDAPControl ***returned_controls);
  85. ConnResult windows_conn_send_rename(Repl_Connection *conn, const char *dn,
  86. const char *newrdn, const char *newparent, int deleteoldrdn,
  87. LDAPControl **server_controls, LDAPControl ***returned_controls);
  88. ConnResult windows_conn_send_extended_operation(Repl_Connection *conn, const char *extop_oid,
  89. struct berval *payload, char **retoidp, struct berval **retdatap,
  90. LDAPControl **server_controls, LDAPControl ***returned_controls);
  91. const char *windows_conn_get_status(Repl_Connection *conn);
  92. void windows_conn_start_linger(Repl_Connection *conn);
  93. void windows_conn_cancel_linger(Repl_Connection *conn);
  94. ConnResult windows_conn_replica_supports_ds5_repl(Repl_Connection *conn);
  95. ConnResult windows_conn_replica_supports_dirsync(Repl_Connection *conn);
  96. ConnResult windows_conn_replica_is_win2k3(Repl_Connection *conn);
  97. ConnResult windows_conn_read_entry_attribute(Repl_Connection *conn, const char *dn, char *type,
  98. struct berval ***returned_bvals);
  99. ConnResult windows_conn_push_schema(Repl_Connection *conn, CSN **remotecsn);
  100. void windows_conn_set_timeout(Repl_Connection *conn, long timeout);
  101. void windows_conn_set_agmt_changed(Repl_Connection *conn);
  102. int windows_check_user_password(Repl_Connection *conn, Slapi_DN *sdn, char *password);
  103. /* Used to work around a schema incompatibility between Microsoft and the IETF */
  104. #define FAKE_STREET_ATTR_NAME "in#place#of#streetaddress"
  105. /* Used to work around contrained attribute legth for initials on AD */
  106. #define AD_INITIALS_LENGTH 6
  107. /* Used to check for pre-hashed passwords when syncing */
  108. #define PASSWD_CLEAR_PREFIX "{clear}"
  109. #define PASSWD_CLEAR_PREFIX_LEN 7
  110. /* Used for GUID format conversion */
  111. #define NTUNIQUEID_LENGTH 32
  112. #define AD_GUID_LENGTH 36
  113. /*
  114. * Periodic synchronization interval. This is used for scheduling the periodic_dirsync event.
  115. * The time is in seconds.
  116. */
  117. #define PERIODIC_DIRSYNC_INTERVAL 5 * 60 /* default value is 5 minutes */
  118. /*
  119. * One way sync flags. Used to indicate the direction when one-way sync is used.
  120. */
  121. #define ONE_WAY_SYNC_DISABLED 0
  122. #define ONE_WAY_SYNC_FROM_AD 1
  123. #define ONE_WAY_SYNC_TO_AD 2
  124. /*
  125. * Specifies what action for sync to take if it detects an AD entry has
  126. * moved out of scope
  127. */
  128. #define MOVE_DOES_NOTHING 0
  129. #define MOVE_DOES_UNSYNC 1
  130. #define MOVE_DOES_DELETE 2
  131. /* called for each replication agreement - so the winsync
  132. plugin can be agreement specific and store agreement
  133. specific data
  134. */
  135. void windows_plugin_init(Repl_Agmt *ra);
  136. void windows_plugin_cleanup_agmt(Repl_Agmt *ra);
  137. void winsync_plugin_call_dirsync_search_params_cb(const Repl_Agmt *ra, const char *agmt_dn, char **base, int *scope, char **filter, char ***attrs, LDAPControl ***serverctrls);
  138. /* called before searching for a single entry from AD - agmt_dn will be NULL */
  139. void winsync_plugin_call_pre_ad_search_cb(const Repl_Agmt *ra, const char *agmt_dn, char **base, int *scope, char **filter, char ***attrs, LDAPControl ***serverctrls);
  140. /* called before an internal search to get a single DS entry - agmt_dn will be NULL */
  141. void winsync_plugin_call_pre_ds_search_entry_cb(const Repl_Agmt *ra, const char *agmt_dn, char **base, int *scope, char **filter, char ***attrs, LDAPControl ***serverctrls);
  142. /* called before the total update to get all entries from the DS to sync to AD */
  143. void winsync_plugin_call_pre_ds_search_all_cb(const Repl_Agmt *ra, const char *agmt_dn, char **base, int *scope, char **filter, char ***attrs, LDAPControl ***serverctrls);
  144. void winsync_plugin_call_pre_ad_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *do_modify);
  145. void winsync_plugin_call_pre_ad_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *do_modify);
  146. void winsync_plugin_call_pre_ds_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *do_modify);
  147. void winsync_plugin_call_pre_ds_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *do_modify);
  148. void winsync_plugin_call_pre_ds_add_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry);
  149. void winsync_plugin_call_pre_ds_add_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry);
  150. void winsync_plugin_call_get_new_ds_user_dn_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry,
  151. char **new_dn_string, const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix);
  152. void winsync_plugin_call_get_new_ds_group_dn_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry,
  153. char **new_dn_string, const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix);
  154. void winsync_plugin_call_pre_ad_mod_user_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, const Slapi_DN *local_dn, const Slapi_Entry *ds_entry, LDAPMod * const *origmods, Slapi_DN *remote_dn, LDAPMod ***modstosend);
  155. void winsync_plugin_call_pre_ad_mod_group_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, const Slapi_DN *local_dn, const Slapi_Entry *ds_entry, LDAPMod * const *origmods, Slapi_DN *remote_dn, LDAPMod ***modstosend);
  156. int winsync_plugin_call_can_add_entry_to_ad_cb(const Repl_Agmt *ra, const Slapi_Entry *local_entry, const Slapi_DN *remote_dn);
  157. void winsync_plugin_call_begin_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree,
  158. const Slapi_DN *ad_subtree, int is_total);
  159. void winsync_plugin_call_end_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree,
  160. const Slapi_DN *ad_subtree, int is_total);
  161. void winsync_plugin_call_destroy_agmt_cb(const Repl_Agmt *ra,
  162. const Slapi_DN *ds_subtree,
  163. const Slapi_DN *ad_subtree);
  164. void winsync_plugin_call_post_ad_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  165. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  166. Slapi_Mods *smods, int *result);
  167. void winsync_plugin_call_post_ad_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  168. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  169. Slapi_Mods *smods, int *result);
  170. void winsync_plugin_call_post_ds_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  171. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  172. Slapi_Mods *smods, int *result);
  173. void winsync_plugin_call_post_ds_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  174. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  175. Slapi_Mods *smods, int *result);
  176. void winsync_plugin_call_post_ds_add_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  177. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result);
  178. void winsync_plugin_call_post_ds_add_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  179. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result);
  180. void winsync_plugin_call_pre_ad_add_user_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  181. Slapi_Entry *ds_entry);
  182. void winsync_plugin_call_pre_ad_add_group_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  183. Slapi_Entry *ds_entry);
  184. void winsync_plugin_call_post_ad_add_user_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  185. Slapi_Entry *ds_entry, int *result);
  186. void winsync_plugin_call_post_ad_add_group_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  187. Slapi_Entry *ds_entry, int *result);
  188. void winsync_plugin_call_post_ad_mod_user_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  189. const Slapi_DN *local_dn,
  190. const Slapi_Entry *ds_entry,
  191. LDAPMod * const *origmods,
  192. Slapi_DN *remote_dn, LDAPMod **modstosend, int *result);
  193. void winsync_plugin_call_post_ad_mod_group_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  194. const Slapi_DN *local_dn,
  195. const Slapi_Entry *ds_entry,
  196. LDAPMod * const *origmods,
  197. Slapi_DN *remote_dn, LDAPMod **modstosend, int *result);
  198. /*
  199. Call stack for all places where windows_LDAPMessage2Entry is called:
  200. windows_LDAPMessage2Entry
  201. ++windows_seach_entry_ext
  202. ++++windows_search_entry
  203. ++++++windows_get_remote_entry
  204. map_dn_values
  205. windows_create_remote_entry
  206. process_replay_add
  207. windows_process_total_add
  208. windows_map_mods_for_replay
  209. windows_replay_update
  210. send_updates
  211. windows_inc_run
  212. windows_create_local_entry
  213. windows_process_dirsync_entry
  214. windows_generate_update_mods
  215. windows_update_remote_entry
  216. process_replay_add
  217. windows_process_total_add
  218. windows_update_local_entry
  219. windows_process_dirsync_entry
  220. process_replay_add
  221. windows_replay_update
  222. map_entry_dn_outbound
  223. map_dn_values
  224. windows_replay_update
  225. windows_process_total_entry
  226. send_entry
  227. windows_tot_run
  228. windows_process_total_add
  229. windows_process_total_entry
  230. send_entry
  231. windows_tot_run
  232. windows_process_dirsync_entry
  233. windows_dirsync_inc_run
  234. find_entry_by_attr_value_remote
  235. map_entry_dn_outbound
  236. ++++windows_get_remote_tombstone
  237. map_windows_tombstone_dn
  238. process_replay_add
  239. ++windows_conn_get_search_result
  240. windows_dirsync_inc_run
  241. windows_inc_protocol
  242. ++send_updates
  243. ++++windows_replay_update
  244. */