windowsrepl.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. Slapi_Entry *windows_private_get_curr_entry(const Repl_Agmt *ra);
  65. void windows_private_set_curr_entry(const Repl_Agmt *ra, Slapi_Entry *e);
  66. char **windows_private_get_range_attrs(const Repl_Agmt *ra);
  67. void windows_private_set_range_attrs(const Repl_Agmt *ra, char **attrs);
  68. void windows_private_set_directory_userfilter(const Repl_Agmt *ra, char *filter);
  69. void windows_private_set_windows_userfilter(const Repl_Agmt *ra, char *filter);
  70. const char* windows_private_get_directory_userfilter(const Repl_Agmt *ra);
  71. const char* windows_private_get_windows_userfilter(const Repl_Agmt *ra);
  72. const subtreePair* windows_private_get_subtreepairs(const Repl_Agmt *ra);
  73. void windows_private_set_subtreepairs(const Repl_Agmt *ra, char **parray);
  74. const Slapi_DN* windows_private_get_windows_treetop(const Repl_Agmt *ra);
  75. void windows_private_set_windows_treetop(const Repl_Agmt *ra, char *treetop);
  76. const Slapi_DN* windows_private_get_directory_treetop(const Repl_Agmt *ra);
  77. void windows_private_set_directory_treetop(const Repl_Agmt *ra, char *treetop);
  78. /* in windows_connection.c */
  79. ConnResult windows_conn_connect(Repl_Connection *conn);
  80. void windows_conn_disconnect(Repl_Connection *conn);
  81. void windows_conn_get_error(Repl_Connection *conn, int *operation, int *error);
  82. void windows_conn_set_error(Repl_Connection *conn, int error);
  83. ConnResult windows_conn_send_add(Repl_Connection *conn, const char *dn, LDAPMod **attrs,
  84. LDAPControl **server_controls, LDAPControl ***returned_controls);
  85. ConnResult windows_conn_send_delete(Repl_Connection *conn, const char *dn,
  86. LDAPControl **server_controls, LDAPControl ***returned_controls);
  87. ConnResult windows_conn_send_modify(Repl_Connection *conn, const char *dn, LDAPMod **mods,
  88. LDAPControl **server_controls, LDAPControl ***returned_controls);
  89. ConnResult windows_conn_send_rename(Repl_Connection *conn, const char *dn,
  90. const char *newrdn, const char *newparent, int deleteoldrdn,
  91. LDAPControl **server_controls, LDAPControl ***returned_controls);
  92. ConnResult windows_conn_send_extended_operation(Repl_Connection *conn, const char *extop_oid,
  93. struct berval *payload, char **retoidp, struct berval **retdatap,
  94. LDAPControl **server_controls, LDAPControl ***returned_controls);
  95. const char *windows_conn_get_status(Repl_Connection *conn);
  96. void windows_conn_start_linger(Repl_Connection *conn);
  97. void windows_conn_cancel_linger(Repl_Connection *conn);
  98. ConnResult windows_conn_replica_supports_ds5_repl(Repl_Connection *conn);
  99. ConnResult windows_conn_replica_supports_dirsync(Repl_Connection *conn);
  100. ConnResult windows_conn_replica_is_win2k3(Repl_Connection *conn);
  101. ConnResult windows_conn_read_entry_attribute(Repl_Connection *conn, const char *dn, char *type,
  102. struct berval ***returned_bvals);
  103. ConnResult windows_conn_push_schema(Repl_Connection *conn, CSN **remotecsn);
  104. void windows_conn_set_timeout(Repl_Connection *conn, long timeout);
  105. void windows_conn_set_agmt_changed(Repl_Connection *conn);
  106. int windows_check_user_password(Repl_Connection *conn, Slapi_DN *sdn, char *password);
  107. /* Used to work around a schema incompatibility between Microsoft and the IETF */
  108. #define FAKE_STREET_ATTR_NAME "in#place#of#streetaddress"
  109. /* Used to work around contrained attribute legth for initials on AD */
  110. #define AD_INITIALS_LENGTH 6
  111. /* Used to check for pre-hashed passwords when syncing */
  112. #define PASSWD_CLEAR_PREFIX "{clear}"
  113. #define PASSWD_CLEAR_PREFIX_LEN 7
  114. /* Used for GUID format conversion */
  115. #define NTUNIQUEID_LENGTH 32
  116. #define AD_GUID_LENGTH 36
  117. /*
  118. * Periodic synchronization interval. This is used for scheduling the periodic_dirsync event.
  119. * The time is in seconds.
  120. */
  121. #define PERIODIC_DIRSYNC_INTERVAL 5 * 60 /* default value is 5 minutes */
  122. /*
  123. * One way sync flags. Used to indicate the direction when one-way sync is used.
  124. */
  125. #define ONE_WAY_SYNC_DISABLED 0
  126. #define ONE_WAY_SYNC_FROM_AD 1
  127. #define ONE_WAY_SYNC_TO_AD 2
  128. /*
  129. * Specifies what action for sync to take if it detects an AD entry has
  130. * moved out of scope
  131. */
  132. #define MOVE_DOES_NOTHING 0
  133. #define MOVE_DOES_UNSYNC 1
  134. #define MOVE_DOES_DELETE 2
  135. /* called for each replication agreement - so the winsync
  136. plugin can be agreement specific and store agreement
  137. specific data
  138. */
  139. void windows_plugin_init(Repl_Agmt *ra);
  140. void windows_plugin_cleanup_agmt(Repl_Agmt *ra);
  141. 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);
  142. /* called before searching for a single entry from AD - agmt_dn will be NULL */
  143. 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);
  144. /* called before an internal search to get a single DS entry - agmt_dn will be NULL */
  145. 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);
  146. /* called before the total update to get all entries from the DS to sync to AD */
  147. 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);
  148. 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);
  149. 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);
  150. 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);
  151. 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);
  152. 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);
  153. 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);
  154. void winsync_plugin_call_get_new_ds_user_dn_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry,
  155. char **new_dn_string, const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix);
  156. void winsync_plugin_call_get_new_ds_group_dn_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry,
  157. char **new_dn_string, const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix);
  158. 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);
  159. 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);
  160. int winsync_plugin_call_can_add_entry_to_ad_cb(const Repl_Agmt *ra, const Slapi_Entry *local_entry, const Slapi_DN *remote_dn);
  161. void winsync_plugin_call_begin_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree,
  162. const Slapi_DN *ad_subtree, int is_total);
  163. void winsync_plugin_call_end_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree,
  164. const Slapi_DN *ad_subtree, int is_total);
  165. void winsync_plugin_call_destroy_agmt_cb(const Repl_Agmt *ra,
  166. const Slapi_DN *ds_subtree,
  167. const Slapi_DN *ad_subtree);
  168. void winsync_plugin_call_post_ad_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  169. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  170. Slapi_Mods *smods, int *result);
  171. void winsync_plugin_call_post_ad_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  172. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  173. Slapi_Mods *smods, int *result);
  174. void winsync_plugin_call_post_ds_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  175. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  176. Slapi_Mods *smods, int *result);
  177. void winsync_plugin_call_post_ds_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  178. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  179. Slapi_Mods *smods, int *result);
  180. void winsync_plugin_call_post_ds_add_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  181. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result);
  182. void winsync_plugin_call_post_ds_add_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  183. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result);
  184. void winsync_plugin_call_pre_ad_add_user_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  185. Slapi_Entry *ds_entry);
  186. void winsync_plugin_call_pre_ad_add_group_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  187. Slapi_Entry *ds_entry);
  188. void winsync_plugin_call_post_ad_add_user_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  189. Slapi_Entry *ds_entry, int *result);
  190. void winsync_plugin_call_post_ad_add_group_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  191. Slapi_Entry *ds_entry, int *result);
  192. void winsync_plugin_call_post_ad_mod_user_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  193. const Slapi_DN *local_dn,
  194. const Slapi_Entry *ds_entry,
  195. LDAPMod * const *origmods,
  196. Slapi_DN *remote_dn, LDAPMod **modstosend, int *result);
  197. void winsync_plugin_call_post_ad_mod_group_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  198. const Slapi_DN *local_dn,
  199. const Slapi_Entry *ds_entry,
  200. LDAPMod * const *origmods,
  201. Slapi_DN *remote_dn, LDAPMod **modstosend, int *result);
  202. /*
  203. Call stack for all places where windows_LDAPMessage2Entry is called:
  204. windows_LDAPMessage2Entry
  205. ++windows_seach_entry_ext
  206. ++++windows_search_entry
  207. ++++++windows_get_remote_entry
  208. map_dn_values
  209. windows_create_remote_entry
  210. process_replay_add
  211. windows_process_total_add
  212. windows_map_mods_for_replay
  213. windows_replay_update
  214. send_updates
  215. windows_inc_run
  216. windows_create_local_entry
  217. windows_process_dirsync_entry
  218. windows_generate_update_mods
  219. windows_update_remote_entry
  220. process_replay_add
  221. windows_process_total_add
  222. windows_update_local_entry
  223. windows_process_dirsync_entry
  224. process_replay_add
  225. windows_replay_update
  226. map_entry_dn_outbound
  227. map_dn_values
  228. windows_replay_update
  229. windows_process_total_entry
  230. send_entry
  231. windows_tot_run
  232. windows_process_total_add
  233. windows_process_total_entry
  234. send_entry
  235. windows_tot_run
  236. windows_process_dirsync_entry
  237. windows_dirsync_inc_run
  238. find_entry_by_attr_value_remote
  239. map_entry_dn_outbound
  240. ++++windows_get_remote_tombstone
  241. map_windows_tombstone_dn
  242. process_replay_add
  243. ++windows_conn_get_search_result
  244. windows_dirsync_inc_run
  245. windows_inc_protocol
  246. ++send_updates
  247. ++++windows_replay_update
  248. */