windowsrepl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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, int scope);
  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_get_error(Repl_Connection *conn, int *operation, int *error);
  90. void windows_conn_set_error(Repl_Connection *conn, int error);
  91. ConnResult windows_conn_send_add(Repl_Connection *conn, const char *dn, LDAPMod **attrs,
  92. LDAPControl **server_controls, LDAPControl ***returned_controls);
  93. ConnResult windows_conn_send_delete(Repl_Connection *conn, const char *dn,
  94. LDAPControl **server_controls, LDAPControl ***returned_controls);
  95. ConnResult windows_conn_send_modify(Repl_Connection *conn, const char *dn, LDAPMod **mods,
  96. LDAPControl **server_controls, LDAPControl ***returned_controls);
  97. ConnResult windows_conn_send_rename(Repl_Connection *conn, const char *dn,
  98. const char *newrdn, const char *newparent, int deleteoldrdn,
  99. LDAPControl **server_controls, LDAPControl ***returned_controls);
  100. ConnResult windows_conn_send_extended_operation(Repl_Connection *conn, const char *extop_oid,
  101. struct berval *payload, char **retoidp, struct berval **retdatap,
  102. LDAPControl **server_controls, LDAPControl ***returned_controls);
  103. const char *windows_conn_get_status(Repl_Connection *conn);
  104. void windows_conn_start_linger(Repl_Connection *conn);
  105. void windows_conn_cancel_linger(Repl_Connection *conn);
  106. ConnResult windows_conn_replica_supports_ds5_repl(Repl_Connection *conn);
  107. ConnResult windows_conn_replica_supports_dirsync(Repl_Connection *conn);
  108. ConnResult windows_conn_replica_is_win2k3(Repl_Connection *conn);
  109. ConnResult windows_conn_read_entry_attribute(Repl_Connection *conn, const char *dn, char *type,
  110. struct berval ***returned_bvals);
  111. ConnResult windows_conn_push_schema(Repl_Connection *conn, CSN **remotecsn);
  112. void windows_conn_set_timeout(Repl_Connection *conn, long timeout);
  113. void windows_conn_set_agmt_changed(Repl_Connection *conn);
  114. int windows_check_user_password(Repl_Connection *conn, Slapi_DN *sdn, char *password);
  115. /* Used to work around a schema incompatibility between Microsoft and the IETF */
  116. #define FAKE_STREET_ATTR_NAME "in#place#of#streetaddress"
  117. /* Used to work around contrained attribute legth for initials on AD */
  118. #define AD_INITIALS_LENGTH 6
  119. /* Used to check for pre-hashed passwords when syncing */
  120. #define PASSWD_CLEAR_PREFIX "{clear}"
  121. #define PASSWD_CLEAR_PREFIX_LEN 7
  122. /* Used for GUID format conversion */
  123. #define NTUNIQUEID_LENGTH 32
  124. #define AD_GUID_LENGTH 36
  125. /*
  126. * Periodic synchronization interval. This is used for scheduling the periodic_dirsync event.
  127. * The time is in seconds.
  128. */
  129. #define PERIODIC_DIRSYNC_INTERVAL 5 * 60 /* default value is 5 minutes */
  130. /*
  131. * One way sync flags. Used to indicate the direction when one-way sync is used.
  132. */
  133. #define ONE_WAY_SYNC_DISABLED 0
  134. #define ONE_WAY_SYNC_FROM_AD 1
  135. #define ONE_WAY_SYNC_TO_AD 2
  136. /* called for each replication agreement - so the winsync
  137. plugin can be agreement specific and store agreement
  138. specific data
  139. */
  140. void windows_plugin_init(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. /*
  169. Call stack for all places where windows_LDAPMessage2Entry is called:
  170. windows_LDAPMessage2Entry
  171. ++windows_seach_entry_ext
  172. ++++windows_search_entry
  173. ++++++windows_get_remote_entry
  174. map_dn_values
  175. windows_create_remote_entry
  176. process_replay_add
  177. windows_process_total_add
  178. windows_map_mods_for_replay
  179. windows_replay_update
  180. send_updates
  181. windows_inc_run
  182. windows_create_local_entry
  183. windows_process_dirsync_entry
  184. windows_generate_update_mods
  185. windows_update_remote_entry
  186. process_replay_add
  187. windows_process_total_add
  188. windows_update_local_entry
  189. windows_process_dirsync_entry
  190. process_replay_add
  191. windows_replay_update
  192. map_entry_dn_outbound
  193. map_dn_values
  194. windows_replay_update
  195. windows_process_total_entry
  196. send_entry
  197. windows_tot_run
  198. windows_process_total_add
  199. windows_process_total_entry
  200. send_entry
  201. windows_tot_run
  202. windows_process_dirsync_entry
  203. windows_dirsync_inc_run
  204. find_entry_by_attr_value_remote
  205. map_entry_dn_outbound
  206. ++++windows_get_remote_tombstone
  207. map_windows_tombstone_dn
  208. process_replay_add
  209. ++windows_conn_get_search_result
  210. windows_dirsync_inc_run
  211. windows_inc_protocol
  212. ++send_updates
  213. ++++windows_replay_update
  214. */