windowsrepl.h 14 KB

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