windowsrepl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. /* windows_private.c */
  42. typedef struct windowsprivate Dirsync_Private;
  43. Dirsync_Private* windows_private_new();
  44. void windows_private_set_windows_subtree (const Repl_Agmt *ra,Slapi_DN* sdn );
  45. const Slapi_DN* windows_private_get_windows_subtree (const Repl_Agmt *ra);
  46. void windows_private_set_directory_subtree (const Repl_Agmt *ra,Slapi_DN* sdn );
  47. const Slapi_DN* windows_private_get_directory_subtree (const Repl_Agmt *ra);
  48. LDAPControl* windows_private_dirsync_control(const Repl_Agmt *ra);
  49. ConnResult send_dirsync_search(Repl_Connection *conn);
  50. ConnResult windows_search_entry(Repl_Connection *conn, char* searchbase, char *filter, Slapi_Entry **entry);
  51. ConnResult windows_search_entry_ext(Repl_Connection *conn, char* searchbase, char *filter, Slapi_Entry **entry, LDAPControl **serverctrls);
  52. Slapi_Entry *windows_conn_get_search_result(Repl_Connection *conn );
  53. void windows_private_update_dirsync_control(const Repl_Agmt *ra,LDAPControl **controls );
  54. PRBool windows_private_dirsync_has_more(const Repl_Agmt *ra);
  55. void windows_private_null_dirsync_cookie(const Repl_Agmt *ra);
  56. int windows_private_save_dirsync_cookie(const Repl_Agmt *ra);
  57. int windows_private_load_dirsync_cookie(const Repl_Agmt *ra);
  58. void windows_private_set_create_users(const Repl_Agmt *ra, PRBool value);
  59. PRBool windows_private_create_users(const Repl_Agmt *ra);
  60. void windows_private_set_create_groups(const Repl_Agmt *ra, PRBool value);
  61. PRBool windows_private_create_groups(const Repl_Agmt *ra);
  62. const char *windows_private_get_windows_domain(const Repl_Agmt *ra);
  63. int windows_private_get_isnt4(const Repl_Agmt *ra);
  64. void windows_private_set_isnt4(const Repl_Agmt *ra, int isit);
  65. int windows_private_get_iswin2k3(const Repl_Agmt *ra);
  66. void windows_private_set_iswin2k3(const Repl_Agmt *ra, int isit);
  67. Slapi_Filter* windows_private_get_directory_filter(const Repl_Agmt *ra);
  68. Slapi_Filter* windows_private_get_deleted_filter(const Repl_Agmt *ra);
  69. const char* windows_private_get_purl(const Repl_Agmt *ra);
  70. /*
  71. * The raw entry is the last raw entry read from AD - raw as opposed
  72. * "cooked" - that is, having had schema processing done
  73. */
  74. /* get returns a pointer to the structure - do not free */
  75. Slapi_Entry *windows_private_get_raw_entry(const Repl_Agmt *ra);
  76. /* this is passin - windows_private owns the pointer, not a copy */
  77. void windows_private_set_raw_entry(const Repl_Agmt *ra, Slapi_Entry *e);
  78. void windows_private_set_keep_raw_entry(const Repl_Agmt *ra, int keep);
  79. int windows_private_get_keep_raw_entry(const Repl_Agmt *ra);
  80. void *windows_private_get_api_cookie(const Repl_Agmt *ra);
  81. void windows_private_set_api_cookie(Repl_Agmt *ra, void *cookie);
  82. time_t windows_private_get_sync_interval(const Repl_Agmt *ra);
  83. void windows_private_set_sync_interval(Repl_Agmt *ra, char *str);
  84. PRBool windows_private_get_one_way(const Repl_Agmt *ra);
  85. void windows_private_set_one_way(const Repl_Agmt *ra, PRBool value);
  86. /* in windows_connection.c */
  87. ConnResult windows_conn_connect(Repl_Connection *conn);
  88. void windows_conn_disconnect(Repl_Connection *conn);
  89. void windows_conn_delete(Repl_Connection *conn);
  90. void windows_conn_get_error(Repl_Connection *conn, int *operation, int *error);
  91. void windows_conn_set_error(Repl_Connection *conn, int error);
  92. ConnResult windows_conn_send_add(Repl_Connection *conn, const char *dn, LDAPMod **attrs,
  93. LDAPControl **server_controls, LDAPControl ***returned_controls);
  94. ConnResult windows_conn_send_delete(Repl_Connection *conn, const char *dn,
  95. LDAPControl **server_controls, LDAPControl ***returned_controls);
  96. ConnResult windows_conn_send_modify(Repl_Connection *conn, const char *dn, LDAPMod **mods,
  97. LDAPControl **server_controls, LDAPControl ***returned_controls);
  98. ConnResult windows_conn_send_rename(Repl_Connection *conn, const char *dn,
  99. const char *newrdn, const char *newparent, int deleteoldrdn,
  100. LDAPControl **server_controls, LDAPControl ***returned_controls);
  101. ConnResult windows_conn_send_extended_operation(Repl_Connection *conn, const char *extop_oid,
  102. struct berval *payload, char **retoidp, struct berval **retdatap,
  103. LDAPControl **server_controls, LDAPControl ***returned_controls);
  104. const char *windows_conn_get_status(Repl_Connection *conn);
  105. void windows_conn_start_linger(Repl_Connection *conn);
  106. void windows_conn_cancel_linger(Repl_Connection *conn);
  107. ConnResult windows_conn_replica_supports_ds5_repl(Repl_Connection *conn);
  108. ConnResult windows_conn_replica_supports_dirsync(Repl_Connection *conn);
  109. ConnResult windows_conn_replica_is_win2k3(Repl_Connection *conn);
  110. ConnResult windows_conn_read_entry_attribute(Repl_Connection *conn, const char *dn, char *type,
  111. struct berval ***returned_bvals);
  112. ConnResult windows_conn_push_schema(Repl_Connection *conn, CSN **remotecsn);
  113. void windows_conn_set_timeout(Repl_Connection *conn, long timeout);
  114. void windows_conn_set_agmt_changed(Repl_Connection *conn);
  115. int windows_check_user_password(Repl_Connection *conn, Slapi_DN *sdn, char *password);
  116. /* Used to work around a schema incompatibility between Microsoft and the IETF */
  117. #define FAKE_STREET_ATTR_NAME "in#place#of#streetaddress"
  118. /* Used to work around contrained attribute legth for initials on AD */
  119. #define AD_INITIALS_LENGTH 6
  120. /* Used to check for pre-hashed passwords when syncing */
  121. #define PASSWD_CLEAR_PREFIX "{clear}"
  122. #define PASSWD_CLEAR_PREFIX_LEN 7
  123. /* Used for GUID format conversion */
  124. #define NTUNIQUEID_LENGTH 32
  125. #define AD_GUID_LENGTH 36
  126. /*
  127. * Periodic synchronization interval. This is used for scheduling the periodic_dirsync event.
  128. * The time is in seconds.
  129. */
  130. #define PERIODIC_DIRSYNC_INTERVAL 5 * 60 /* default value is 5 minutes */
  131. /*
  132. * One way sync flags. Used to indicate the direction when one-way sync is used.
  133. */
  134. #define ONE_WAY_SYNC_DISABLED 0
  135. #define ONE_WAY_SYNC_FROM_AD 1
  136. #define ONE_WAY_SYNC_TO_AD 2
  137. /* called for each replication agreement - so the winsync
  138. plugin can be agreement specific and store agreement
  139. specific data
  140. */
  141. void windows_plugin_init(Repl_Agmt *ra);
  142. 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);
  143. /* called before searching for a single entry from AD - agmt_dn will be NULL */
  144. 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);
  145. /* called before an internal search to get a single DS entry - agmt_dn will be NULL */
  146. 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);
  147. /* called before the total update to get all entries from the DS to sync to AD */
  148. 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);
  149. 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);
  150. 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);
  151. 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);
  152. 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);
  153. 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);
  154. 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);
  155. void winsync_plugin_call_get_new_ds_user_dn_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry,
  156. char **new_dn_string, const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix);
  157. void winsync_plugin_call_get_new_ds_group_dn_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry,
  158. char **new_dn_string, const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix);
  159. 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);
  160. 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);
  161. int winsync_plugin_call_can_add_entry_to_ad_cb(const Repl_Agmt *ra, const Slapi_Entry *local_entry, const Slapi_DN *remote_dn);
  162. void winsync_plugin_call_begin_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree,
  163. const Slapi_DN *ad_subtree, int is_total);
  164. void winsync_plugin_call_end_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree,
  165. const Slapi_DN *ad_subtree, int is_total);
  166. void winsync_plugin_call_destroy_agmt_cb(const Repl_Agmt *ra,
  167. const Slapi_DN *ds_subtree,
  168. const Slapi_DN *ad_subtree);
  169. /*
  170. Call stack for all places where windows_LDAPMessage2Entry is called:
  171. windows_LDAPMessage2Entry
  172. ++windows_seach_entry_ext
  173. ++++windows_search_entry
  174. ++++++windows_get_remote_entry
  175. map_dn_values
  176. windows_create_remote_entry
  177. process_replay_add
  178. windows_process_total_add
  179. windows_map_mods_for_replay
  180. windows_replay_update
  181. send_updates
  182. windows_inc_run
  183. windows_create_local_entry
  184. windows_process_dirsync_entry
  185. windows_generate_update_mods
  186. windows_update_remote_entry
  187. process_replay_add
  188. windows_process_total_add
  189. windows_update_local_entry
  190. windows_process_dirsync_entry
  191. process_replay_add
  192. windows_replay_update
  193. map_entry_dn_outbound
  194. map_dn_values
  195. windows_replay_update
  196. windows_process_total_entry
  197. send_entry
  198. windows_tot_run
  199. windows_process_total_add
  200. windows_process_total_entry
  201. send_entry
  202. windows_tot_run
  203. windows_process_dirsync_entry
  204. windows_dirsync_inc_run
  205. find_entry_by_attr_value_remote
  206. map_entry_dn_outbound
  207. ++++windows_get_remote_tombstone
  208. map_windows_tombstone_dn
  209. process_replay_add
  210. ++windows_conn_get_search_result
  211. windows_dirsync_inc_run
  212. windows_inc_protocol
  213. ++send_updates
  214. ++++windows_replay_update
  215. */