windowsrepl.h 17 KB

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