windows_private.c 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569
  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. #include "repl.h"
  43. #include "repl5.h"
  44. #include "slap.h"
  45. #include "slapi-plugin.h"
  46. #include "winsync-plugin.h"
  47. #include "windowsrepl.h"
  48. struct windowsprivate {
  49. Slapi_DN *windows_subtree; /* DN of synchronized subtree (on the windows side) */
  50. Slapi_DN *directory_subtree; /* DN of synchronized subtree on directory side */
  51. /* this simplifies the mapping as it's simply
  52. from the former to the latter container, or
  53. vice versa */
  54. ber_int_t dirsync_flags;
  55. ber_int_t dirsync_maxattributecount;
  56. char *dirsync_cookie;
  57. int dirsync_cookie_len;
  58. PRBool dirsync_cookie_has_more;
  59. PRBool create_users_from_dirsync;
  60. PRBool create_groups_from_dirsync;
  61. char *windows_domain;
  62. int isnt4;
  63. int iswin2k3;
  64. /* This filter is used to determine if an entry belongs to this agreement. We put it here
  65. * so we only have to allocate each filter once instead of doing it every time we receive a change. */
  66. Slapi_Filter *directory_filter; /* Used for checking if local entries need to be sync'd to AD */
  67. Slapi_Filter *deleted_filter; /* Used for checking if an entry is an AD tombstone */
  68. Slapi_Entry *raw_entry; /* "raw" un-schema processed last entry read from AD */
  69. int keep_raw_entry; /* flag to control when the raw entry is set */
  70. void *api_cookie; /* private data used by api callbacks */
  71. time_t sync_interval; /* how often to run the dirsync search, in seconds */
  72. int one_way; /* Indicates if this is a one-way agreement and which direction it is */
  73. int move_action; /* Indicates what to do with DS entry if AD entry is moved out of scope */
  74. Slapi_Entry *curr_entry; /* entry being retrieved; used for the range retrieval */
  75. char **range_attrs; /* next attributes for the range retrieval */
  76. };
  77. static void windows_private_set_windows_domain(const Repl_Agmt *ra, char *domain);
  78. static int
  79. true_value_from_string(char *val)
  80. {
  81. if (strcasecmp (val, "on") == 0 || strcasecmp (val, "yes") == 0 ||
  82. strcasecmp (val, "true") == 0 || strcasecmp (val, "1") == 0)
  83. {
  84. return 1;
  85. } else
  86. {
  87. return 0;
  88. }
  89. }
  90. /* yech - can't declare a constant string array because type_nsds7XX variables
  91. are not constant strings - so have to build a lookup table */
  92. static int
  93. get_next_disallow_attr_type(int *ii, const char **type)
  94. {
  95. switch (*ii) {
  96. case 0: *type = type_nsds7WindowsReplicaArea; break;
  97. case 1: *type = type_nsds7DirectoryReplicaArea; break;
  98. case 2: *type = type_nsds7WindowsDomain; break;
  99. default: *type = NULL; break;
  100. }
  101. if (*type) {
  102. (*ii)++;
  103. return 1;
  104. }
  105. return 0;
  106. }
  107. static int
  108. check_update_allowed(Repl_Agmt *ra, const char *type, Slapi_Entry *e, int *retval)
  109. {
  110. int rc = 1;
  111. /* note - it is not an error to defer setting the value in the ra */
  112. *retval = 1;
  113. if (agmt_get_update_in_progress(ra)) {
  114. const char *distype = NULL;
  115. int ii = 0;
  116. while (get_next_disallow_attr_type(&ii, &distype)) {
  117. if (slapi_attr_types_equivalent(type, distype)) {
  118. char *tmpstr = slapi_entry_attr_get_charptr(e, type);
  119. slapi_log_error(SLAPI_LOG_REPL, windows_repl_plugin_name,
  120. "windows_parse_config_entry: setting %s to %s will be "
  121. "deferred until current update is completed\n",
  122. type, tmpstr);
  123. slapi_ch_free_string(&tmpstr);
  124. rc = 0;
  125. break;
  126. }
  127. }
  128. }
  129. return rc;
  130. }
  131. static int
  132. windows_parse_config_entry(Repl_Agmt *ra, const char *type, Slapi_Entry *e)
  133. {
  134. char *tmpstr = NULL;
  135. int retval = 0;
  136. if (!check_update_allowed(ra, type, e, &retval))
  137. {
  138. return retval;
  139. }
  140. if (type == NULL || slapi_attr_types_equivalent(type,type_nsds7WindowsReplicaArea))
  141. {
  142. tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7WindowsReplicaArea);
  143. if (NULL != tmpstr)
  144. {
  145. windows_private_set_windows_subtree(ra, slapi_sdn_new_dn_passin(tmpstr) );
  146. }
  147. retval = 1;
  148. }
  149. if (type == NULL || slapi_attr_types_equivalent(type,type_nsds7DirectoryReplicaArea))
  150. {
  151. tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7DirectoryReplicaArea);
  152. if (NULL != tmpstr)
  153. {
  154. windows_private_set_directory_subtree(ra, slapi_sdn_new_dn_passin(tmpstr) );
  155. }
  156. retval = 1;
  157. }
  158. if (type == NULL || slapi_attr_types_equivalent(type,type_nsds7CreateNewUsers))
  159. {
  160. tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7CreateNewUsers);
  161. if (NULL != tmpstr && true_value_from_string(tmpstr))
  162. {
  163. windows_private_set_create_users(ra, PR_TRUE);
  164. }
  165. else
  166. {
  167. windows_private_set_create_users(ra, PR_FALSE);
  168. }
  169. slapi_ch_free((void**)&tmpstr);
  170. prot_notify_agmt_changed(agmt_get_protocol(ra), (char *)agmt_get_long_name(ra));
  171. retval = 1;
  172. }
  173. if (type == NULL || slapi_attr_types_equivalent(type,type_nsds7CreateNewGroups))
  174. {
  175. tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7CreateNewGroups);
  176. if (NULL != tmpstr && true_value_from_string(tmpstr))
  177. {
  178. windows_private_set_create_groups(ra, PR_TRUE);
  179. }
  180. else
  181. {
  182. windows_private_set_create_groups(ra, PR_FALSE);
  183. }
  184. slapi_ch_free((void**)&tmpstr);
  185. prot_notify_agmt_changed(agmt_get_protocol(ra), (char *)agmt_get_long_name(ra));
  186. retval = 1;
  187. }
  188. if (type == NULL || slapi_attr_types_equivalent(type,type_nsds7WindowsDomain))
  189. {
  190. tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7WindowsDomain);
  191. if (NULL != tmpstr)
  192. {
  193. windows_private_set_windows_domain(ra,tmpstr);
  194. }
  195. /* No need to free tmpstr because it was aliased by the call above */
  196. tmpstr = NULL;
  197. retval = 1;
  198. }
  199. if (type == NULL || slapi_attr_types_equivalent(type,type_winSyncInterval))
  200. {
  201. tmpstr = slapi_entry_attr_get_charptr(e, type_winSyncInterval);
  202. if (NULL != tmpstr)
  203. {
  204. windows_private_set_sync_interval(ra,tmpstr);
  205. prot_notify_agmt_changed(agmt_get_protocol(ra), (char *)agmt_get_long_name(ra));
  206. }
  207. slapi_ch_free_string(&tmpstr);
  208. retval = 1;
  209. }
  210. if (type == NULL || slapi_attr_types_equivalent(type,type_oneWaySync))
  211. {
  212. tmpstr = slapi_entry_attr_get_charptr(e, type_oneWaySync);
  213. if (NULL != tmpstr)
  214. {
  215. if (strcasecmp(tmpstr, "fromWindows") == 0) {
  216. windows_private_set_one_way(ra, ONE_WAY_SYNC_FROM_AD);
  217. } else if (strcasecmp(tmpstr, "toWindows") == 0) {
  218. windows_private_set_one_way(ra, ONE_WAY_SYNC_TO_AD);
  219. } else {
  220. slapi_log_error(SLAPI_LOG_FATAL, windows_repl_plugin_name,
  221. "Ignoring illegal setting for %s attribute in replication "
  222. "agreement \"%s\". Valid values are \"toWindows\" or "
  223. "\"fromWindows\".\n", type_oneWaySync, slapi_entry_get_dn(e));
  224. windows_private_set_one_way(ra, ONE_WAY_SYNC_DISABLED);
  225. }
  226. }
  227. else
  228. {
  229. windows_private_set_one_way(ra, ONE_WAY_SYNC_DISABLED);
  230. }
  231. slapi_ch_free((void**)&tmpstr);
  232. prot_notify_agmt_changed(agmt_get_protocol(ra), (char *)agmt_get_long_name(ra));
  233. retval = 1;
  234. }
  235. if (type == NULL || slapi_attr_types_equivalent(type,type_winsyncMoveAction))
  236. {
  237. tmpstr = slapi_entry_attr_get_charptr(e, type_winsyncMoveAction);
  238. if (NULL != tmpstr)
  239. {
  240. if (strcasecmp(tmpstr, "delete") == 0) {
  241. windows_private_set_move_action(ra, MOVE_DOES_DELETE);
  242. } else if (strcasecmp(tmpstr, "unsync") == 0) {
  243. windows_private_set_move_action(ra, MOVE_DOES_UNSYNC);
  244. } else if (strcasecmp(tmpstr, "none") == 0) {
  245. windows_private_set_move_action(ra, MOVE_DOES_NOTHING);
  246. } else {
  247. slapi_log_error(SLAPI_LOG_FATAL, windows_repl_plugin_name,
  248. "Ignoring illegal setting for %s attribute in replication "
  249. "agreement \"%s\". Valid values are \"delete\" or "
  250. "\"unsync\".\n", type_winsyncMoveAction, slapi_entry_get_dn(e));
  251. windows_private_set_move_action(ra, MOVE_DOES_NOTHING);
  252. }
  253. }
  254. else
  255. {
  256. windows_private_set_move_action(ra, MOVE_DOES_NOTHING);
  257. }
  258. slapi_ch_free((void**)&tmpstr);
  259. prot_notify_agmt_changed(agmt_get_protocol(ra), (char *)agmt_get_long_name(ra));
  260. retval = 1;
  261. }
  262. return retval;
  263. }
  264. /* Returns non-zero if the modify was ok, zero if not */
  265. int
  266. windows_handle_modify_agreement(Repl_Agmt *ra, const char *type, Slapi_Entry *e)
  267. {
  268. /* Is this a Windows agreement ? */
  269. if (get_agmt_agreement_type(ra) == REPLICA_TYPE_WINDOWS)
  270. {
  271. return windows_parse_config_entry(ra,type,e);
  272. } else
  273. {
  274. return 0;
  275. }
  276. }
  277. void
  278. windows_update_done(Repl_Agmt *agmt, int is_total)
  279. {
  280. /* "flush" the changes made during the update to the agmt */
  281. /* get the agmt entry */
  282. Slapi_DN *agmtdn = slapi_sdn_dup(agmt_get_dn_byref(agmt));
  283. Slapi_Entry *agmte = NULL;
  284. int rc = slapi_search_internal_get_entry(agmtdn, NULL, &agmte,
  285. repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION));
  286. if ((rc == 0) && agmte) {
  287. int ii = 0;
  288. const char *distype = NULL;
  289. while (get_next_disallow_attr_type(&ii, &distype)) {
  290. windows_handle_modify_agreement(agmt, distype, agmte);
  291. }
  292. }
  293. slapi_entry_free(agmte);
  294. slapi_sdn_free(&agmtdn);
  295. }
  296. void
  297. windows_init_agreement_from_entry(Repl_Agmt *ra, Slapi_Entry *e)
  298. {
  299. agmt_set_priv(ra,windows_private_new());
  300. windows_parse_config_entry(ra,NULL,e);
  301. windows_plugin_init(ra);
  302. }
  303. const char* windows_private_get_purl(const Repl_Agmt *ra)
  304. {
  305. const char* windows_purl;
  306. char *hostname;
  307. hostname = agmt_get_hostname(ra);
  308. if(slapi_is_ipv6_addr(hostname)){
  309. /* need to put brackets around the ipv6 address */
  310. windows_purl = slapi_ch_smprintf("ldap://[%s]:%d", hostname, agmt_get_port(ra));
  311. } else {
  312. windows_purl = slapi_ch_smprintf("ldap://%s:%d", hostname, agmt_get_port(ra));
  313. }
  314. slapi_ch_free_string(&hostname);
  315. return windows_purl;
  316. }
  317. Dirsync_Private* windows_private_new()
  318. {
  319. Dirsync_Private *dp;
  320. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_new\n" );
  321. dp = (Dirsync_Private *)slapi_ch_calloc(sizeof(Dirsync_Private),1);
  322. dp->dirsync_maxattributecount = -1;
  323. dp->directory_filter = NULL;
  324. dp->deleted_filter = NULL;
  325. dp->sync_interval = PERIODIC_DIRSYNC_INTERVAL;
  326. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_new\n" );
  327. return dp;
  328. }
  329. void windows_agreement_delete(Repl_Agmt *ra)
  330. {
  331. Dirsync_Private *dp = (Dirsync_Private *) agmt_get_priv(ra);
  332. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_delete\n" );
  333. PR_ASSERT(dp != NULL);
  334. winsync_plugin_call_destroy_agmt_cb(ra, dp->directory_subtree,
  335. dp->windows_subtree);
  336. windows_plugin_cleanup_agmt(ra);
  337. slapi_sdn_free(&dp->directory_subtree);
  338. slapi_sdn_free(&dp->windows_subtree);
  339. slapi_filter_free(dp->directory_filter, 1);
  340. slapi_filter_free(dp->deleted_filter, 1);
  341. slapi_entry_free(dp->raw_entry);
  342. slapi_ch_free_string(&dp->windows_domain);
  343. dp->raw_entry = NULL;
  344. dp->api_cookie = NULL;
  345. slapi_ch_free((void **)dp);
  346. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_delete\n" );
  347. }
  348. int windows_private_get_isnt4(const Repl_Agmt *ra)
  349. {
  350. Dirsync_Private *dp;
  351. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_isnt4\n" );
  352. PR_ASSERT(ra);
  353. dp = (Dirsync_Private *) agmt_get_priv(ra);
  354. PR_ASSERT (dp);
  355. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_isnt4\n" );
  356. return dp->isnt4;
  357. }
  358. void windows_private_set_isnt4(const Repl_Agmt *ra, int isit)
  359. {
  360. Dirsync_Private *dp;
  361. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_isnt4\n" );
  362. PR_ASSERT(ra);
  363. dp = (Dirsync_Private *) agmt_get_priv(ra);
  364. PR_ASSERT (dp);
  365. dp->isnt4 = isit;
  366. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_isnt4\n" );
  367. }
  368. int windows_private_get_iswin2k3(const Repl_Agmt *ra)
  369. {
  370. Dirsync_Private *dp;
  371. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_iswin2k3\n" );
  372. PR_ASSERT(ra);
  373. dp = (Dirsync_Private *) agmt_get_priv(ra);
  374. PR_ASSERT (dp);
  375. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_iswin2k3\n" );
  376. return dp->iswin2k3;
  377. }
  378. void windows_private_set_iswin2k3(const Repl_Agmt *ra, int isit)
  379. {
  380. Dirsync_Private *dp;
  381. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_iswin2k3\n" );
  382. PR_ASSERT(ra);
  383. dp = (Dirsync_Private *) agmt_get_priv(ra);
  384. PR_ASSERT (dp);
  385. dp->iswin2k3 = isit;
  386. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_iswin2k3\n" );
  387. }
  388. /* Returns a copy of the Slapi_Filter pointer. The caller should not free it */
  389. Slapi_Filter* windows_private_get_directory_filter(const Repl_Agmt *ra)
  390. {
  391. Dirsync_Private *dp;
  392. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_directory_filter\n" );
  393. PR_ASSERT(ra);
  394. dp = (Dirsync_Private *) agmt_get_priv(ra);
  395. PR_ASSERT (dp);
  396. if (dp->directory_filter == NULL) {
  397. char *string_filter = slapi_ch_strdup("(&(|(objectclass=ntuser)(objectclass=ntgroup))(ntUserDomainId=*))");
  398. /* The filter gets freed in windows_agreement_delete() */
  399. dp->directory_filter = slapi_str2filter( string_filter );
  400. slapi_ch_free_string(&string_filter);
  401. }
  402. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_directory_filter\n" );
  403. return dp->directory_filter;
  404. }
  405. /* Returns a copy of the Slapi_Filter pointer. The caller should not free it */
  406. Slapi_Filter* windows_private_get_deleted_filter(const Repl_Agmt *ra)
  407. {
  408. Dirsync_Private *dp;
  409. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_deleted_filter\n" );
  410. PR_ASSERT(ra);
  411. dp = (Dirsync_Private *) agmt_get_priv(ra);
  412. PR_ASSERT (dp);
  413. if (dp->deleted_filter == NULL) {
  414. char *string_filter = slapi_ch_strdup("(isdeleted=*)");
  415. /* The filter gets freed in windows_agreement_delete() */
  416. dp->deleted_filter = slapi_str2filter( string_filter );
  417. slapi_ch_free_string(&string_filter);
  418. }
  419. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_deleted_filter\n" );
  420. return dp->deleted_filter;
  421. }
  422. /* Returns a copy of the Slapi_DN pointer, no need to free it */
  423. const Slapi_DN* windows_private_get_windows_subtree (const Repl_Agmt *ra)
  424. {
  425. Dirsync_Private *dp;
  426. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_windows_subtree\n" );
  427. PR_ASSERT(ra);
  428. dp = (Dirsync_Private *) agmt_get_priv(ra);
  429. PR_ASSERT (dp);
  430. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_windows_subtree\n" );
  431. return dp->windows_subtree;
  432. }
  433. const char *
  434. windows_private_get_windows_domain(const Repl_Agmt *ra)
  435. {
  436. Dirsync_Private *dp;
  437. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_windows_domain\n" );
  438. PR_ASSERT(ra);
  439. dp = (Dirsync_Private *) agmt_get_priv(ra);
  440. PR_ASSERT (dp);
  441. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_windows_domain\n" );
  442. return dp->windows_domain;
  443. }
  444. static void
  445. windows_private_set_windows_domain(const Repl_Agmt *ra, char *domain)
  446. {
  447. Dirsync_Private *dp;
  448. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_windows_domain\n" );
  449. PR_ASSERT(ra);
  450. dp = (Dirsync_Private *) agmt_get_priv(ra);
  451. PR_ASSERT (dp);
  452. slapi_ch_free_string(&dp->windows_domain);
  453. dp->windows_domain = domain;
  454. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_windows_domain\n" );
  455. }
  456. /* Returns a copy of the Slapi_DN pointer, no need to free it */
  457. const Slapi_DN* windows_private_get_directory_subtree (const Repl_Agmt *ra)
  458. {
  459. Dirsync_Private *dp;
  460. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_directory_replarea\n" );
  461. PR_ASSERT(ra);
  462. dp = (Dirsync_Private *) agmt_get_priv(ra);
  463. PR_ASSERT (dp);
  464. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_directory_replarea\n" );
  465. return dp->directory_subtree;
  466. }
  467. /* Takes a copy of the sdn passed in */
  468. void windows_private_set_windows_subtree (const Repl_Agmt *ra,Slapi_DN* sdn )
  469. {
  470. Dirsync_Private *dp;
  471. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_windows_replarea\n" );
  472. PR_ASSERT(ra);
  473. PR_ASSERT(sdn);
  474. dp = (Dirsync_Private *) agmt_get_priv(ra);
  475. PR_ASSERT (dp);
  476. slapi_sdn_free(&dp->windows_subtree);
  477. dp->windows_subtree = sdn;
  478. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_windows_replarea\n" );
  479. }
  480. /* Takes a copy of the sdn passed in */
  481. void windows_private_set_directory_subtree (const Repl_Agmt *ra,Slapi_DN* sdn )
  482. {
  483. Dirsync_Private *dp;
  484. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_directory_replarea\n" );
  485. PR_ASSERT(ra);
  486. PR_ASSERT(sdn);
  487. dp = (Dirsync_Private *) agmt_get_priv(ra);
  488. PR_ASSERT (dp);
  489. slapi_sdn_free(&dp->directory_subtree);
  490. dp->directory_subtree = sdn;
  491. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_directory_replarea\n" );
  492. }
  493. PRBool windows_private_create_users(const Repl_Agmt *ra)
  494. {
  495. Dirsync_Private *dp;
  496. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_create_users\n" );
  497. PR_ASSERT(ra);
  498. dp = (Dirsync_Private *) agmt_get_priv(ra);
  499. PR_ASSERT (dp);
  500. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_create_users\n" );
  501. return dp->create_users_from_dirsync;
  502. }
  503. void windows_private_set_create_users(const Repl_Agmt *ra, PRBool value)
  504. {
  505. Dirsync_Private *dp;
  506. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_create_users\n" );
  507. PR_ASSERT(ra);
  508. dp = (Dirsync_Private *) agmt_get_priv(ra);
  509. PR_ASSERT (dp);
  510. dp->create_users_from_dirsync = value;
  511. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_create_users\n" );
  512. }
  513. PRBool windows_private_create_groups(const Repl_Agmt *ra)
  514. {
  515. Dirsync_Private *dp;
  516. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_create_groups\n" );
  517. PR_ASSERT(ra);
  518. dp = (Dirsync_Private *) agmt_get_priv(ra);
  519. PR_ASSERT (dp);
  520. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_create_groups\n" );
  521. return dp->create_groups_from_dirsync;
  522. }
  523. void windows_private_set_create_groups(const Repl_Agmt *ra, PRBool value)
  524. {
  525. Dirsync_Private *dp;
  526. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_create_groups\n" );
  527. PR_ASSERT(ra);
  528. dp = (Dirsync_Private *) agmt_get_priv(ra);
  529. PR_ASSERT (dp);
  530. dp->create_groups_from_dirsync = value;
  531. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_create_groups\n" );
  532. }
  533. int windows_private_get_one_way(const Repl_Agmt *ra)
  534. {
  535. Dirsync_Private *dp;
  536. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_one_way\n" );
  537. PR_ASSERT(ra);
  538. dp = (Dirsync_Private *) agmt_get_priv(ra);
  539. PR_ASSERT (dp);
  540. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_one_way\n" );
  541. return dp->one_way;
  542. }
  543. void windows_private_set_one_way(const Repl_Agmt *ra, int value)
  544. {
  545. Dirsync_Private *dp;
  546. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_one_way\n" );
  547. PR_ASSERT(ra);
  548. dp = (Dirsync_Private *) agmt_get_priv(ra);
  549. PR_ASSERT (dp);
  550. dp->one_way = value;
  551. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_one_way\n" );
  552. }
  553. /*
  554. This function returns the current Dirsync_Private that's inside
  555. Repl_Agmt ra as a ldap control.
  556. */
  557. LDAPControl* windows_private_dirsync_control(const Repl_Agmt *ra)
  558. {
  559. LDAPControl *control = NULL;
  560. BerElement *ber;
  561. Dirsync_Private *dp;
  562. char iscritical = PR_TRUE;
  563. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_dirsync_control\n" );
  564. PR_ASSERT(ra);
  565. dp = (Dirsync_Private *) agmt_get_priv(ra);
  566. PR_ASSERT (dp);
  567. ber = ber_alloc();
  568. ber_printf( ber, "{iio}", dp->dirsync_flags, dp->dirsync_maxattributecount, dp->dirsync_cookie ? dp->dirsync_cookie : "", dp->dirsync_cookie_len );
  569. /* Use a regular directory server instead of a real AD - for testing */
  570. if (getenv("WINSYNC_USE_DS")) {
  571. iscritical = PR_FALSE;
  572. }
  573. slapi_build_control( REPL_DIRSYNC_CONTROL_OID, ber, iscritical, &control);
  574. ber_free(ber,1);
  575. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_dirsync_control\n" );
  576. return control;
  577. }
  578. /*
  579. This function scans the array of controls and updates the Repl_Agmt's
  580. Dirsync_Private if the dirsync control is found.
  581. */
  582. void windows_private_update_dirsync_control(const Repl_Agmt *ra,LDAPControl **controls )
  583. {
  584. Dirsync_Private *dp;
  585. int foundDirsyncControl;
  586. int i;
  587. LDAPControl *dirsync = NULL;
  588. BerElement *ber = NULL;
  589. ber_int_t hasMoreData;
  590. ber_int_t maxAttributeCount;
  591. BerValue *serverCookie = NULL;
  592. #ifdef FOR_DEBUGGING
  593. int return_value = LDAP_SUCCESS;
  594. #endif
  595. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_update_dirsync_control\n" );
  596. PR_ASSERT(ra);
  597. dp = (Dirsync_Private *) agmt_get_priv(ra);
  598. PR_ASSERT (dp);
  599. if (NULL != controls )
  600. {
  601. foundDirsyncControl = 0;
  602. for ( i = 0; (( controls[i] != NULL ) && ( !foundDirsyncControl )); i++ ) {
  603. foundDirsyncControl = !strcmp( controls[i]->ldctl_oid, REPL_DIRSYNC_CONTROL_OID );
  604. }
  605. if ( !foundDirsyncControl )
  606. {
  607. #ifdef FOR_DEBUGGING
  608. return_value = LDAP_CONTROL_NOT_FOUND;
  609. #endif
  610. goto choke;
  611. }
  612. else if (!controls[i-1]->ldctl_value.bv_val) {
  613. #ifdef FOR_DEBUGGING
  614. return_value = LDAP_CONTROL_NOT_FOUND;
  615. #endif
  616. goto choke;
  617. }
  618. else
  619. {
  620. dirsync = slapi_dup_control( controls[i-1]);
  621. }
  622. if (!dirsync || !BV_HAS_DATA((&(dirsync->ldctl_value)))) {
  623. #ifdef FOR_DEBUGGING
  624. return_value = LDAP_CONTROL_NOT_FOUND;
  625. #endif
  626. goto choke;
  627. }
  628. ber = ber_init( &dirsync->ldctl_value ) ;
  629. if (ber_scanf( ber, "{iiO}", &hasMoreData, &maxAttributeCount, &serverCookie) == LBER_ERROR)
  630. {
  631. #ifdef FOR_DEBUGGING
  632. return_value = LDAP_CONTROL_NOT_FOUND;
  633. #endif
  634. goto choke;
  635. }
  636. slapi_ch_free_string(&dp->dirsync_cookie);
  637. dp->dirsync_cookie = ( char* ) slapi_ch_malloc(serverCookie->bv_len + 1);
  638. memcpy(dp->dirsync_cookie, serverCookie->bv_val, serverCookie->bv_len);
  639. dp->dirsync_cookie_len = (int) serverCookie->bv_len; /* XXX shouldn't cast? */
  640. /* dp->dirsync_maxattributecount = maxAttributeCount; We don't need to keep this */
  641. dp->dirsync_cookie_has_more = hasMoreData;
  642. choke:
  643. ber_bvfree(serverCookie);
  644. ber_free(ber,1);
  645. ldap_control_free(dirsync);
  646. }
  647. else
  648. {
  649. #ifdef FOR_DEBUGGING
  650. return_value = LDAP_CONTROL_NOT_FOUND;
  651. #endif
  652. }
  653. #ifdef FOR_DEBUGGING
  654. LDAPDebug1Arg( LDAP_DEBUG_TRACE, "<= windows_private_update_dirsync_control: rc=%d\n", return_value);
  655. #else
  656. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_update_dirsync_control\n" );
  657. #endif
  658. }
  659. PRBool windows_private_dirsync_has_more(const Repl_Agmt *ra)
  660. {
  661. Dirsync_Private *dp;
  662. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_dirsync_has_more\n" );
  663. PR_ASSERT(ra);
  664. dp = (Dirsync_Private *) agmt_get_priv(ra);
  665. PR_ASSERT (dp);
  666. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_dirsync_has_more\n" );
  667. return dp->dirsync_cookie_has_more;
  668. }
  669. void windows_private_null_dirsync_cookie(const Repl_Agmt *ra)
  670. {
  671. Dirsync_Private *dp;
  672. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_null_dirsync_control\n" );
  673. dp = (Dirsync_Private *) agmt_get_priv(ra);
  674. PR_ASSERT (dp);
  675. dp->dirsync_cookie_len = 0;
  676. slapi_ch_free_string(&dp->dirsync_cookie);
  677. dp->dirsync_cookie = NULL;
  678. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_null_dirsync_control\n" );
  679. }
  680. static
  681. Slapi_Mods *windows_private_get_cookie_mod(Dirsync_Private *dp, int modtype)
  682. {
  683. Slapi_Mods *smods = NULL;
  684. smods = slapi_mods_new();
  685. slapi_mods_add( smods, modtype,
  686. "nsds7DirsyncCookie", dp->dirsync_cookie_len , dp->dirsync_cookie);
  687. return smods;
  688. }
  689. /* writes the current cookie into dse.ldif under the replication agreement entry
  690. returns: ldap result code of the operation. */
  691. int
  692. windows_private_save_dirsync_cookie(const Repl_Agmt *ra)
  693. {
  694. Dirsync_Private *dp = NULL;
  695. Slapi_PBlock *pb = NULL;
  696. Slapi_DN* sdn = NULL;
  697. int rc = 0;
  698. Slapi_Mods *mods = NULL;
  699. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_save_dirsync_cookie\n" );
  700. PR_ASSERT(ra);
  701. dp = (Dirsync_Private *) agmt_get_priv(ra);
  702. PR_ASSERT (dp);
  703. pb = slapi_pblock_new ();
  704. mods = windows_private_get_cookie_mod(dp, LDAP_MOD_REPLACE);
  705. sdn = slapi_sdn_dup( agmt_get_dn_byref(ra) );
  706. slapi_modify_internal_set_pb_ext (pb, sdn,
  707. slapi_mods_get_ldapmods_byref(mods), NULL, NULL,
  708. repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0);
  709. slapi_modify_internal_pb (pb);
  710. slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
  711. if (rc == LDAP_NO_SUCH_ATTRIBUTE)
  712. { /* try again, but as an add instead */
  713. slapi_mods_free(&mods);
  714. mods = windows_private_get_cookie_mod(dp, LDAP_MOD_ADD);
  715. slapi_modify_internal_set_pb_ext (pb, sdn,
  716. slapi_mods_get_ldapmods_byref(mods), NULL, NULL,
  717. repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0);
  718. slapi_modify_internal_pb (pb);
  719. slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
  720. }
  721. slapi_pblock_destroy (pb);
  722. slapi_mods_free(&mods);
  723. slapi_sdn_free(&sdn);
  724. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_save_dirsync_cookie\n" );
  725. return rc;
  726. }
  727. /* reads the cookie in dse.ldif to the replication agreement entry
  728. returns: ldap result code of ldap operation, or
  729. LDAP_NO_SUCH_ATTRIBUTE. (this is the equilivent of a null cookie) */
  730. int windows_private_load_dirsync_cookie(const Repl_Agmt *ra)
  731. {
  732. Dirsync_Private *dp = NULL;
  733. Slapi_PBlock *pb = NULL;
  734. Slapi_DN* sdn = NULL;
  735. int rc = 0;
  736. Slapi_Entry *entry = NULL;
  737. Slapi_Attr *attr = NULL;
  738. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_load_dirsync_cookie\n" );
  739. PR_ASSERT(ra);
  740. dp = (Dirsync_Private *) agmt_get_priv(ra);
  741. PR_ASSERT (dp);
  742. pb = slapi_pblock_new ();
  743. sdn = slapi_sdn_dup( agmt_get_dn_byref(ra) );
  744. rc = slapi_search_internal_get_entry(sdn, NULL, &entry,
  745. repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION));
  746. if (rc == 0)
  747. {
  748. rc= slapi_entry_attr_find( entry, type_nsds7DirsyncCookie, &attr );
  749. if (attr)
  750. {
  751. struct berval **vals;
  752. rc = slapi_attr_get_bervals_copy(attr, &vals );
  753. if (vals)
  754. {
  755. dp->dirsync_cookie_len = (int) (vals[0])->bv_len;
  756. slapi_ch_free_string(&dp->dirsync_cookie);
  757. dp->dirsync_cookie = ( char* ) slapi_ch_malloc(dp->dirsync_cookie_len + 1);
  758. memcpy(dp->dirsync_cookie,(vals[0]->bv_val), (vals[0])->bv_len+1);
  759. }
  760. ber_bvecfree(vals);
  761. /* we do not free attr */
  762. }
  763. else
  764. {
  765. rc = LDAP_NO_SUCH_ATTRIBUTE;
  766. }
  767. }
  768. if (entry)
  769. {
  770. slapi_entry_free(entry);
  771. }
  772. slapi_sdn_free( &sdn);
  773. slapi_pblock_destroy (pb);
  774. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_load_dirsync_cookie\n" );
  775. return rc;
  776. }
  777. /* get returns a pointer to the structure - do not free */
  778. Slapi_Entry *windows_private_get_raw_entry(const Repl_Agmt *ra)
  779. {
  780. Dirsync_Private *dp;
  781. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_raw_entry\n" );
  782. dp = (Dirsync_Private *) agmt_get_priv(ra);
  783. PR_ASSERT (dp);
  784. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_raw_entry\n" );
  785. return dp->raw_entry;
  786. }
  787. /* this is passin - windows_private owns the pointer, not a copy */
  788. void windows_private_set_raw_entry(const Repl_Agmt *ra, Slapi_Entry *e)
  789. {
  790. Dirsync_Private *dp;
  791. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_raw_entry\n" );
  792. dp = (Dirsync_Private *) agmt_get_priv(ra);
  793. PR_ASSERT (dp);
  794. /* If the keep raw entry flag is set, just free the passed
  795. * in entry and leave the current raw entry in place. */
  796. if (windows_private_get_keep_raw_entry(ra)) {
  797. slapi_entry_free(e);
  798. } else {
  799. slapi_entry_free(dp->raw_entry);
  800. dp->raw_entry = e;
  801. }
  802. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_raw_entry\n" );
  803. }
  804. /* Setting keep to 1 will cause the current raw entry to remain, even if
  805. * windows_private_set_raw_entry() is called. This behavior will persist
  806. * until this flag is set back to 0. */
  807. void windows_private_set_keep_raw_entry(const Repl_Agmt *ra, int keep)
  808. {
  809. Dirsync_Private *dp;
  810. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_keep_raw_entry\n" );
  811. dp = (Dirsync_Private *) agmt_get_priv(ra);
  812. PR_ASSERT (dp);
  813. dp->keep_raw_entry = keep;
  814. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_keep_raw_entry\n" );
  815. }
  816. int windows_private_get_keep_raw_entry(const Repl_Agmt *ra)
  817. {
  818. Dirsync_Private *dp;
  819. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_keep_raw_entry\n" );
  820. dp = (Dirsync_Private *) agmt_get_priv(ra);
  821. PR_ASSERT (dp);
  822. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_keep_raw_entry\n" );
  823. return dp->keep_raw_entry;
  824. }
  825. void *windows_private_get_api_cookie(const Repl_Agmt *ra)
  826. {
  827. Dirsync_Private *dp;
  828. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_api_cookie\n" );
  829. dp = (Dirsync_Private *) agmt_get_priv(ra);
  830. PR_ASSERT (dp);
  831. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_api_cookie\n" );
  832. return dp->api_cookie;
  833. }
  834. void windows_private_set_api_cookie(Repl_Agmt *ra, void *api_cookie)
  835. {
  836. Dirsync_Private *dp;
  837. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_api_cookie\n" );
  838. dp = (Dirsync_Private *) agmt_get_priv(ra);
  839. PR_ASSERT (dp);
  840. dp->api_cookie = api_cookie;
  841. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_api_cookie\n" );
  842. }
  843. time_t
  844. windows_private_get_sync_interval(const Repl_Agmt *ra)
  845. {
  846. Dirsync_Private *dp;
  847. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_sync_interval\n" );
  848. PR_ASSERT(ra);
  849. dp = (Dirsync_Private *) agmt_get_priv(ra);
  850. PR_ASSERT (dp);
  851. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_sync_interval\n" );
  852. return dp->sync_interval;
  853. }
  854. void
  855. windows_private_set_sync_interval(Repl_Agmt *ra, char *str)
  856. {
  857. Dirsync_Private *dp;
  858. time_t tmpval = 0;
  859. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_sync_interval\n" );
  860. PR_ASSERT(ra);
  861. dp = (Dirsync_Private *) agmt_get_priv(ra);
  862. PR_ASSERT (dp);
  863. if (str && (tmpval = (time_t)atol(str))) {
  864. dp->sync_interval = tmpval;
  865. }
  866. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_sync_interval\n" );
  867. }
  868. int
  869. windows_private_get_move_action(const Repl_Agmt *ra)
  870. {
  871. Dirsync_Private *dp;
  872. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_move_action\n" );
  873. PR_ASSERT(ra);
  874. dp = (Dirsync_Private *) agmt_get_priv(ra);
  875. PR_ASSERT (dp);
  876. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_move_action\n" );
  877. return dp->move_action;
  878. }
  879. void
  880. windows_private_set_move_action(const Repl_Agmt *ra, int value)
  881. {
  882. Dirsync_Private *dp;
  883. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_move_action\n" );
  884. PR_ASSERT(ra);
  885. dp = (Dirsync_Private *) agmt_get_priv(ra);
  886. PR_ASSERT (dp);
  887. dp->move_action = value;
  888. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_move_action\n" );
  889. }
  890. /* Get entry being retrieved; used for the range retrieval */
  891. Slapi_Entry *
  892. windows_private_get_curr_entry(const Repl_Agmt *ra)
  893. {
  894. Dirsync_Private *dp;
  895. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_curr_entry\n" );
  896. PR_ASSERT(ra);
  897. dp = (Dirsync_Private *) agmt_get_priv(ra);
  898. PR_ASSERT (dp);
  899. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_curr_entry\n" );
  900. return dp->curr_entry;
  901. }
  902. /* Set entry being retrieved; used for the range retrieval */
  903. void
  904. windows_private_set_curr_entry(const Repl_Agmt *ra, Slapi_Entry *e)
  905. {
  906. Dirsync_Private *dp;
  907. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_curr_entry\n" );
  908. PR_ASSERT(ra);
  909. dp = (Dirsync_Private *) agmt_get_priv(ra);
  910. PR_ASSERT (dp);
  911. dp->curr_entry = e;
  912. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_curr_entry\n" );
  913. }
  914. /* Get next range retrieval attributes */
  915. char **
  916. windows_private_get_range_attrs(const Repl_Agmt *ra)
  917. {
  918. Dirsync_Private *dp;
  919. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_get_range_attrs\n" );
  920. PR_ASSERT(ra);
  921. dp = (Dirsync_Private *) agmt_get_priv(ra);
  922. PR_ASSERT (dp);
  923. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_get_range_attrs\n" );
  924. return dp->range_attrs;
  925. }
  926. /* Set next range retrieval attributes */
  927. void
  928. windows_private_set_range_attrs(const Repl_Agmt *ra, char **attrs)
  929. {
  930. Dirsync_Private *dp;
  931. LDAPDebug0Args( LDAP_DEBUG_TRACE, "=> windows_private_set_move_action\n" );
  932. PR_ASSERT(ra);
  933. dp = (Dirsync_Private *) agmt_get_priv(ra);
  934. PR_ASSERT (dp);
  935. dp->range_attrs = attrs;
  936. LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_private_set_move_action\n" );
  937. }
  938. static PRCallOnceType winsync_callOnce = {0,0};
  939. struct winsync_plugin {
  940. struct winsync_plugin *next; /* see PRCList - declare here to avoid lots of casting */
  941. struct winsync_plugin *prev; /* see PRCList - declare here to avoid lots of casting */
  942. void **api; /* the api - array of function pointers */
  943. int maxapi; /* the max index i.e. the api version */
  944. int precedence; /* lower number == higher precedence */
  945. };
  946. static struct winsync_plugin winsync_plugin_list;
  947. #define DECL_WINSYNC_API_IDX_FUNC(theapi,idx,maxidx,thetype,thefunc) \
  948. thetype thefunc = (theapi && (idx <= maxidx) && theapi[idx]) ? \
  949. (thetype)theapi[idx] : NULL;
  950. #define WINSYNC_PLUGIN_CALL_PLUGINS_BEGIN(idx,thetype,thefunc) \
  951. struct winsync_plugin *elem; \
  952. for (elem = PR_LIST_HEAD(&winsync_plugin_list); \
  953. elem && (elem != &winsync_plugin_list); \
  954. elem = PR_NEXT_LINK(elem)) { \
  955. DECL_WINSYNC_API_IDX_FUNC(elem->api,idx,elem->maxapi,thetype,thefunc); \
  956. if (thefunc) {
  957. #define WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(idx,thetype,thefunc) \
  958. WINSYNC_PLUGIN_CALL_PLUGINS_BEGIN(idx,thetype,thefunc) \
  959. void *cookie = winsync_plugin_cookie_find(ra, elem->api);
  960. #define WINSYNC_PLUGIN_CALL_PLUGINS_END } /* this one matches if thefunc */ } /* this one matches the for loop */
  961. /* this structure is per agreement - to store the cookie per agreement
  962. for each winsync plugin */
  963. struct winsync_plugin_cookie {
  964. struct winsync_plugin_cookie *next; /* see PRCList - declare here to avoid lots of casting */
  965. struct winsync_plugin_cookie *prev; /* see PRCList - declare here to avoid lots of casting */
  966. void **api; /* the api - array of function pointers */
  967. void *cookie; /* plugin data */
  968. };
  969. static struct winsync_plugin *
  970. new_winsync_plugin(void **theapi, int maxapi, int precedence)
  971. {
  972. struct winsync_plugin *wpi = (struct winsync_plugin *)slapi_ch_calloc(1, sizeof(struct winsync_plugin));
  973. wpi->api = theapi;
  974. wpi->maxapi = maxapi;
  975. wpi->precedence = precedence;
  976. return wpi;
  977. }
  978. static struct winsync_plugin *
  979. windows_plugin_find(void **theapi)
  980. {
  981. struct winsync_plugin *elem = PR_LIST_HEAD(&winsync_plugin_list);
  982. while (elem && (elem != &winsync_plugin_list)) {
  983. if (theapi == elem->api) {
  984. return elem;
  985. }
  986. elem = PR_NEXT_LINK(elem);
  987. }
  988. return NULL;
  989. }
  990. /* returns 0 for success - 1 means already added - -1 means some error */
  991. static int
  992. windows_plugin_add(void **theapi, int maxapi)
  993. {
  994. int precedence = WINSYNC_PLUGIN_DEFAULT_PRECEDENCE;
  995. DECL_WINSYNC_API_IDX_FUNC(theapi,WINSYNC_PLUGIN_PRECEDENCE_CB,maxapi,winsync_plugin_precedence_cb,thefunc);
  996. if (thefunc) {
  997. /* supports precedence */
  998. precedence = (*thefunc)();
  999. }
  1000. if (PR_CLIST_IS_EMPTY(&winsync_plugin_list)) {
  1001. struct winsync_plugin *wpi = new_winsync_plugin(theapi, maxapi, precedence);
  1002. PR_INSERT_LINK(wpi, &winsync_plugin_list);
  1003. return 0;
  1004. } else if (windows_plugin_find(theapi)) {
  1005. return 1; /* already in list */
  1006. } else {
  1007. struct winsync_plugin *wpi = new_winsync_plugin(theapi, maxapi, precedence);
  1008. struct winsync_plugin *elem = PR_LIST_HEAD(&winsync_plugin_list);
  1009. while (elem && (elem != &winsync_plugin_list)) {
  1010. if (precedence < elem->precedence) {
  1011. PR_INSERT_BEFORE(wpi, elem);
  1012. wpi = NULL; /* owned by list now */
  1013. break;
  1014. }
  1015. elem = PR_NEXT_LINK(elem);
  1016. }
  1017. if (elem && wpi) { /* was not added - precedence too high */
  1018. /* just add to end of list */
  1019. PR_INSERT_BEFORE(wpi, elem);
  1020. wpi = NULL; /* owned by list now */
  1021. }
  1022. /* if we got here and wpi is not NULL we need to free wpi */
  1023. slapi_ch_free((void **)&wpi);
  1024. return 0;
  1025. }
  1026. return -1;
  1027. }
  1028. static PRStatus
  1029. windows_plugin_callonce(void)
  1030. {
  1031. char *guids[] = {WINSYNC_v3_0_GUID, WINSYNC_v2_0_GUID, WINSYNC_v1_0_GUID, NULL};
  1032. int maxapis[] = {WINSYNC_PLUGIN_VERSION_3_END, WINSYNC_PLUGIN_VERSION_2_END,
  1033. WINSYNC_PLUGIN_VERSION_1_END, 0};
  1034. int ii;
  1035. PR_INIT_CLIST(&winsync_plugin_list);
  1036. /* loop through all of the registered winsync plugins - look for them in reverse
  1037. version order (e.g. look for v3 first) - if there are no plugins registered
  1038. for the given version, or we have already registered all plugins for a given
  1039. version, just go to the next lowest version */
  1040. for (ii = 0; guids[ii]; ++ii) {
  1041. char *guid = guids[ii];
  1042. int maxapi = maxapis[ii];
  1043. void ***theapis = NULL;
  1044. if (slapi_apib_get_interface_all(guid, &theapis) || (NULL == theapis)) {
  1045. LDAPDebug1Arg(LDAP_DEBUG_PLUGIN,
  1046. "<-- windows_plugin_callonce -- no more windows plugin APIs registered "
  1047. "for GUID [%s] -- end\n",
  1048. guid);
  1049. } else {
  1050. int idx;
  1051. for (idx = 0; theapis && theapis[idx]; ++idx) {
  1052. if (windows_plugin_add(theapis[idx], maxapi)) {
  1053. LDAPDebug(LDAP_DEBUG_PLUGIN,
  1054. "<-- windows_plugin_callonce -- already added windows plugin API "
  1055. "[%d][0x%p] for GUID [%s] -- end\n",
  1056. idx, theapis[idx], guid);
  1057. }
  1058. }
  1059. }
  1060. slapi_ch_free((void **)&theapis);
  1061. }
  1062. return PR_SUCCESS;
  1063. }
  1064. static struct winsync_plugin_cookie *
  1065. new_winsync_plugin_cookie(void **theapi, void *cookie)
  1066. {
  1067. struct winsync_plugin_cookie *wpc = (struct winsync_plugin_cookie *)slapi_ch_calloc(1, sizeof(struct winsync_plugin_cookie));
  1068. wpc->api = theapi;
  1069. wpc->cookie = cookie;
  1070. return wpc;
  1071. }
  1072. static void *
  1073. winsync_plugin_cookie_find(const Repl_Agmt *ra, void **theapi)
  1074. {
  1075. if (ra) {
  1076. struct winsync_plugin_cookie *list = (struct winsync_plugin_cookie *)windows_private_get_api_cookie(ra);
  1077. if (list) {
  1078. struct winsync_plugin_cookie *elem = PR_LIST_HEAD(list);
  1079. while (elem && (elem != list)) {
  1080. if (theapi == elem->api) {
  1081. return elem->cookie;
  1082. }
  1083. elem = PR_NEXT_LINK(elem);
  1084. }
  1085. }
  1086. }
  1087. return NULL;
  1088. }
  1089. static void
  1090. winsync_plugin_cookie_add(struct winsync_plugin_cookie **list, void **theapi, void *cookie)
  1091. {
  1092. struct winsync_plugin_cookie *elem = NULL;
  1093. if (!*list) {
  1094. *list = new_winsync_plugin_cookie(NULL, NULL);
  1095. PR_INIT_CLIST(*list);
  1096. }
  1097. elem = new_winsync_plugin_cookie(theapi, cookie);
  1098. PR_INSERT_BEFORE(elem, *list);
  1099. return;
  1100. }
  1101. void
  1102. windows_plugin_init(Repl_Agmt *ra)
  1103. {
  1104. struct winsync_plugin_cookie *list = NULL;
  1105. void *cookie = NULL;
  1106. LDAPDebug0Args( LDAP_DEBUG_PLUGIN, "--> windows_plugin_init_start -- begin\n");
  1107. if (PR_CallOnce(&winsync_callOnce, windows_plugin_callonce)) {
  1108. PRErrorCode prerr = PR_GetError();
  1109. slapi_log_error(SLAPI_LOG_FATAL, "windows_plugin_init",
  1110. "cannot initialize plugin: %d:%s\n", prerr,
  1111. slapi_pr_strerror(prerr));
  1112. return;
  1113. }
  1114. /* call each plugin init function in turn - store the returned cookie
  1115. indexed by the api */
  1116. {
  1117. WINSYNC_PLUGIN_CALL_PLUGINS_BEGIN(WINSYNC_PLUGIN_INIT_CB,winsync_plugin_init_cb,thefunc)
  1118. cookie = (*thefunc)(windows_private_get_directory_subtree(ra),
  1119. windows_private_get_windows_subtree(ra));
  1120. if (cookie) {
  1121. winsync_plugin_cookie_add(&list, elem->api, cookie);
  1122. }
  1123. WINSYNC_PLUGIN_CALL_PLUGINS_END
  1124. }
  1125. windows_private_set_api_cookie(ra, list);
  1126. LDAPDebug0Args( LDAP_DEBUG_PLUGIN, "<-- windows_plugin_init_start -- end\n");
  1127. return;
  1128. }
  1129. void
  1130. windows_plugin_cleanup_agmt(Repl_Agmt *ra)
  1131. {
  1132. struct winsync_plugin_cookie *list = (struct winsync_plugin_cookie *)windows_private_get_api_cookie(ra);
  1133. struct winsync_plugin_cookie *elem = NULL;
  1134. while (list && !PR_CLIST_IS_EMPTY(list)) {
  1135. elem = PR_LIST_HEAD(list);
  1136. PR_REMOVE_LINK(elem);
  1137. slapi_ch_free((void **)&elem);
  1138. }
  1139. slapi_ch_free((void **)&list);
  1140. windows_private_set_api_cookie(ra, NULL);
  1141. return;
  1142. }
  1143. void
  1144. winsync_plugin_call_dirsync_search_params_cb(const Repl_Agmt *ra, const char *agmt_dn,
  1145. char **base, int *scope, char **filter,
  1146. char ***attrs, LDAPControl ***serverctrls)
  1147. {
  1148. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_DIRSYNC_SEARCH_CB,winsync_search_params_cb,thefunc)
  1149. (*thefunc)(cookie, agmt_dn, base, scope, filter, attrs, serverctrls);
  1150. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1151. return;
  1152. }
  1153. void
  1154. winsync_plugin_call_pre_ad_search_cb(const Repl_Agmt *ra, const char *agmt_dn,
  1155. char **base, int *scope, char **filter,
  1156. char ***attrs, LDAPControl ***serverctrls)
  1157. {
  1158. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_AD_SEARCH_CB,winsync_search_params_cb,thefunc)
  1159. (*thefunc)(cookie, agmt_dn, base, scope, filter, attrs, serverctrls);
  1160. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1161. return;
  1162. }
  1163. void
  1164. winsync_plugin_call_pre_ds_search_entry_cb(const Repl_Agmt *ra, const char *agmt_dn,
  1165. char **base, int *scope, char **filter,
  1166. char ***attrs, LDAPControl ***serverctrls)
  1167. {
  1168. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_DS_SEARCH_ENTRY_CB,winsync_search_params_cb,thefunc)
  1169. (*thefunc)(cookie, agmt_dn, base, scope, filter, attrs, serverctrls);
  1170. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1171. return;
  1172. }
  1173. void
  1174. winsync_plugin_call_pre_ds_search_all_cb(const Repl_Agmt *ra, const char *agmt_dn,
  1175. char **base, int *scope, char **filter,
  1176. char ***attrs, LDAPControl ***serverctrls)
  1177. {
  1178. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_DS_SEARCH_ALL_CB,winsync_search_params_cb,thefunc)
  1179. (*thefunc)(cookie, agmt_dn, base, scope, filter, attrs, serverctrls);
  1180. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1181. return;
  1182. }
  1183. void
  1184. winsync_plugin_call_pre_ad_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1185. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1186. Slapi_Mods *smods, int *do_modify)
  1187. {
  1188. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_AD_MOD_USER_CB,winsync_pre_mod_cb,thefunc)
  1189. (*thefunc)(cookie, rawentry, ad_entry, ds_entry, smods, do_modify);
  1190. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1191. return;
  1192. }
  1193. void
  1194. winsync_plugin_call_pre_ad_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1195. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1196. Slapi_Mods *smods, int *do_modify)
  1197. {
  1198. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_AD_MOD_GROUP_CB,winsync_pre_mod_cb,thefunc)
  1199. (*thefunc)(cookie, rawentry, ad_entry, ds_entry, smods, do_modify);
  1200. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1201. return;
  1202. }
  1203. void
  1204. winsync_plugin_call_pre_ds_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1205. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1206. Slapi_Mods *smods, int *do_modify)
  1207. {
  1208. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_DS_MOD_USER_CB,winsync_pre_mod_cb,thefunc)
  1209. (*thefunc)(cookie, rawentry, ad_entry, ds_entry, smods, do_modify);
  1210. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1211. return;
  1212. }
  1213. void
  1214. winsync_plugin_call_pre_ds_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1215. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1216. Slapi_Mods *smods, int *do_modify)
  1217. {
  1218. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_DS_MOD_GROUP_CB,winsync_pre_mod_cb,thefunc)
  1219. (*thefunc)(cookie, rawentry, ad_entry, ds_entry, smods, do_modify);
  1220. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1221. return;
  1222. }
  1223. void
  1224. winsync_plugin_call_pre_ds_add_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1225. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry)
  1226. {
  1227. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_DS_ADD_USER_CB,winsync_pre_add_cb,thefunc)
  1228. (*thefunc)(cookie, rawentry, ad_entry, ds_entry);
  1229. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1230. return;
  1231. }
  1232. void
  1233. winsync_plugin_call_pre_ds_add_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1234. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry)
  1235. {
  1236. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_DS_ADD_GROUP_CB,winsync_pre_add_cb,thefunc)
  1237. (*thefunc)(cookie, rawentry, ad_entry, ds_entry);
  1238. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1239. return;
  1240. }
  1241. void
  1242. winsync_plugin_call_get_new_ds_user_dn_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1243. Slapi_Entry *ad_entry, char **new_dn_string,
  1244. const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix)
  1245. {
  1246. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_GET_NEW_DS_USER_DN_CB,winsync_get_new_dn_cb,thefunc)
  1247. (*thefunc)(cookie, rawentry, ad_entry, new_dn_string, ds_suffix, ad_suffix);
  1248. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1249. return;
  1250. }
  1251. void
  1252. winsync_plugin_call_get_new_ds_group_dn_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1253. Slapi_Entry *ad_entry, char **new_dn_string,
  1254. const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix)
  1255. {
  1256. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_GET_NEW_DS_GROUP_DN_CB,winsync_get_new_dn_cb,thefunc)
  1257. (*thefunc)(cookie, rawentry, ad_entry, new_dn_string, ds_suffix, ad_suffix);
  1258. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1259. return;
  1260. }
  1261. void
  1262. winsync_plugin_call_pre_ad_mod_user_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1263. const Slapi_DN *local_dn,
  1264. const Slapi_Entry *ds_entry,
  1265. LDAPMod * const *origmods,
  1266. Slapi_DN *remote_dn, LDAPMod ***modstosend)
  1267. {
  1268. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_AD_MOD_USER_MODS_CB,winsync_pre_ad_mod_mods_cb,thefunc)
  1269. (*thefunc)(cookie, rawentry, local_dn, ds_entry, origmods, remote_dn, modstosend);
  1270. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1271. return;
  1272. }
  1273. void
  1274. winsync_plugin_call_pre_ad_mod_group_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1275. const Slapi_DN *local_dn,
  1276. const Slapi_Entry *ds_entry,
  1277. LDAPMod * const *origmods,
  1278. Slapi_DN *remote_dn, LDAPMod ***modstosend)
  1279. {
  1280. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_AD_MOD_GROUP_MODS_CB,winsync_pre_ad_mod_mods_cb,thefunc)
  1281. (*thefunc)(cookie, rawentry, local_dn, ds_entry, origmods, remote_dn, modstosend);
  1282. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1283. return;
  1284. }
  1285. int
  1286. winsync_plugin_call_can_add_entry_to_ad_cb(const Repl_Agmt *ra, const Slapi_Entry *local_entry,
  1287. const Slapi_DN *remote_dn)
  1288. {
  1289. int canadd = 1;
  1290. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_CAN_ADD_ENTRY_TO_AD_CB,winsync_can_add_to_ad_cb,thefunc)
  1291. if (canadd) {
  1292. canadd = (*thefunc)(cookie, local_entry, remote_dn);
  1293. }
  1294. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1295. return canadd;
  1296. }
  1297. void
  1298. winsync_plugin_call_begin_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree,
  1299. const Slapi_DN *ad_subtree, int is_total)
  1300. {
  1301. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_BEGIN_UPDATE_CB,winsync_plugin_update_cb,thefunc)
  1302. (*thefunc)(cookie, ds_subtree, ad_subtree, is_total);
  1303. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1304. return;
  1305. }
  1306. void
  1307. winsync_plugin_call_end_update_cb(const Repl_Agmt *ra, const Slapi_DN *ds_subtree,
  1308. const Slapi_DN *ad_subtree, int is_total)
  1309. {
  1310. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_END_UPDATE_CB,winsync_plugin_update_cb,thefunc)
  1311. (*thefunc)(cookie, ds_subtree, ad_subtree, is_total);
  1312. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1313. return;
  1314. }
  1315. void
  1316. winsync_plugin_call_destroy_agmt_cb(const Repl_Agmt *ra,
  1317. const Slapi_DN *ds_subtree,
  1318. const Slapi_DN *ad_subtree)
  1319. {
  1320. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_DESTROY_AGMT_CB,winsync_plugin_destroy_agmt_cb,thefunc)
  1321. (*thefunc)(cookie, ds_subtree, ad_subtree);
  1322. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1323. return;
  1324. }
  1325. void
  1326. winsync_plugin_call_post_ad_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1327. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1328. Slapi_Mods *smods, int *result)
  1329. {
  1330. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_POST_AD_MOD_USER_CB,winsync_post_mod_cb,thefunc)
  1331. (*thefunc)(cookie, rawentry, ad_entry, ds_entry, smods, result);
  1332. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1333. return;
  1334. }
  1335. void
  1336. winsync_plugin_call_post_ad_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1337. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1338. Slapi_Mods *smods, int *result)
  1339. {
  1340. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_POST_AD_MOD_GROUP_CB,winsync_post_mod_cb,thefunc)
  1341. (*thefunc)(cookie, rawentry, ad_entry, ds_entry, smods, result);
  1342. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1343. return;
  1344. }
  1345. void
  1346. winsync_plugin_call_post_ds_mod_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1347. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1348. Slapi_Mods *smods, int *result)
  1349. {
  1350. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_POST_DS_MOD_USER_CB,winsync_post_mod_cb,thefunc)
  1351. (*thefunc)(cookie, rawentry, ad_entry, ds_entry, smods, result);
  1352. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1353. return;
  1354. }
  1355. void
  1356. winsync_plugin_call_post_ds_mod_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1357. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1358. Slapi_Mods *smods, int *result)
  1359. {
  1360. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_POST_DS_MOD_GROUP_CB,winsync_post_mod_cb,thefunc)
  1361. (*thefunc)(cookie, rawentry, ad_entry, ds_entry, smods, result);
  1362. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1363. return;
  1364. }
  1365. void
  1366. winsync_plugin_call_post_ds_add_user_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1367. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result)
  1368. {
  1369. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_POST_DS_ADD_USER_CB,winsync_post_add_cb,thefunc)
  1370. (*thefunc)(cookie, rawentry, ad_entry, ds_entry, result);
  1371. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1372. return;
  1373. }
  1374. void
  1375. winsync_plugin_call_post_ds_add_group_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1376. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result)
  1377. {
  1378. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_POST_DS_ADD_GROUP_CB,winsync_post_add_cb,thefunc)
  1379. (*thefunc)(cookie, rawentry, ad_entry, ds_entry, result);
  1380. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1381. return;
  1382. }
  1383. void
  1384. winsync_plugin_call_pre_ad_add_user_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  1385. Slapi_Entry *ds_entry)
  1386. {
  1387. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_AD_ADD_USER_CB,winsync_pre_ad_add_cb,thefunc)
  1388. (*thefunc)(cookie, ad_entry, ds_entry);
  1389. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1390. return;
  1391. }
  1392. void
  1393. winsync_plugin_call_pre_ad_add_group_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  1394. Slapi_Entry *ds_entry)
  1395. {
  1396. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_PRE_AD_ADD_GROUP_CB,winsync_pre_ad_add_cb,thefunc)
  1397. (*thefunc)(cookie, ad_entry, ds_entry);
  1398. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1399. return;
  1400. }
  1401. void
  1402. winsync_plugin_call_post_ad_add_user_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  1403. Slapi_Entry *ds_entry, int *result)
  1404. {
  1405. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_POST_AD_ADD_USER_CB,winsync_post_ad_add_cb,thefunc)
  1406. (*thefunc)(cookie, ad_entry, ds_entry, result);
  1407. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1408. return;
  1409. }
  1410. void
  1411. winsync_plugin_call_post_ad_add_group_cb(const Repl_Agmt *ra, Slapi_Entry *ad_entry,
  1412. Slapi_Entry *ds_entry, int *result)
  1413. {
  1414. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_POST_AD_ADD_GROUP_CB,winsync_post_ad_add_cb,thefunc)
  1415. (*thefunc)(cookie, ad_entry, ds_entry, result);
  1416. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1417. return;
  1418. }
  1419. void
  1420. winsync_plugin_call_post_ad_mod_user_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1421. const Slapi_DN *local_dn,
  1422. const Slapi_Entry *ds_entry,
  1423. LDAPMod * const *origmods,
  1424. Slapi_DN *remote_dn, LDAPMod **modstosend, int *result)
  1425. {
  1426. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_POST_AD_MOD_USER_MODS_CB,winsync_post_ad_mod_mods_cb,thefunc)
  1427. (*thefunc)(cookie, rawentry, local_dn, ds_entry, origmods, remote_dn, modstosend, result);
  1428. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1429. return;
  1430. }
  1431. void
  1432. winsync_plugin_call_post_ad_mod_group_mods_cb(const Repl_Agmt *ra, const Slapi_Entry *rawentry,
  1433. const Slapi_DN *local_dn,
  1434. const Slapi_Entry *ds_entry,
  1435. LDAPMod * const *origmods,
  1436. Slapi_DN *remote_dn, LDAPMod **modstosend, int *result)
  1437. {
  1438. WINSYNC_PLUGIN_CALL_PLUGINS_COOKIE_BEGIN(WINSYNC_PLUGIN_POST_AD_MOD_GROUP_MODS_CB,winsync_post_ad_mod_mods_cb,thefunc)
  1439. (*thefunc)(cookie, rawentry, local_dn, ds_entry, origmods, remote_dn, modstosend, result);
  1440. WINSYNC_PLUGIN_CALL_PLUGINS_END;
  1441. return;
  1442. }
  1443. /*
  1444. The following are sample code stubs to show how to implement
  1445. a plugin which uses this api
  1446. */
  1447. #define WINSYNC_SAMPLE_CODE
  1448. #ifdef WINSYNC_SAMPLE_CODE
  1449. #include "slapi-plugin.h"
  1450. #include "winsync-plugin.h"
  1451. static char *test_winsync_plugin_name = "test_winsync_api";
  1452. static void *
  1453. test_winsync_api_init(const Slapi_DN *ds_subtree, const Slapi_DN *ad_subtree)
  1454. {
  1455. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1456. "--> test_winsync_init [%s] [%s] -- begin\n",
  1457. slapi_sdn_get_dn(ds_subtree),
  1458. slapi_sdn_get_dn(ad_subtree));
  1459. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1460. "<-- test_winsync_init -- end\n");
  1461. return NULL;
  1462. }
  1463. static void
  1464. test_winsync_dirsync_search_params_cb(void *cbdata, const char *agmt_dn,
  1465. char **base, int *scope, char **filter,
  1466. char ***attrs, LDAPControl ***serverctrls)
  1467. {
  1468. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1469. "--> test_winsync_dirsync_search_params_cb -- begin\n");
  1470. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1471. "<-- test_winsync_dirsync_search_params_cb -- end\n");
  1472. return;
  1473. }
  1474. /* called before searching for a single entry from AD - agmt_dn will be NULL */
  1475. static void
  1476. test_winsync_pre_ad_search_cb(void *cbdata, const char *agmt_dn,
  1477. char **base, int *scope, char **filter,
  1478. char ***attrs, LDAPControl ***serverctrls)
  1479. {
  1480. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1481. "--> test_winsync_pre_ad_search_cb -- begin\n");
  1482. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1483. "<-- test_winsync_pre_ad_search_cb -- end\n");
  1484. return;
  1485. }
  1486. /* called before an internal search to get a single DS entry - agmt_dn will be NULL */
  1487. static void
  1488. test_winsync_pre_ds_search_entry_cb(void *cbdata, const char *agmt_dn,
  1489. char **base, int *scope, char **filter,
  1490. char ***attrs, LDAPControl ***serverctrls)
  1491. {
  1492. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1493. "--> test_winsync_pre_ds_search_cb -- begin\n");
  1494. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1495. "<-- test_winsync_pre_ds_search_cb -- end\n");
  1496. return;
  1497. }
  1498. /* called before the total update to get all entries from the DS to sync to AD */
  1499. static void
  1500. test_winsync_pre_ds_search_all_cb(void *cbdata, const char *agmt_dn,
  1501. char **base, int *scope, char **filter,
  1502. char ***attrs, LDAPControl ***serverctrls)
  1503. {
  1504. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1505. "--> test_winsync_pre_ds_search_all_cb -- orig filter [%s] -- begin\n",
  1506. ((filter && *filter) ? *filter : "NULL"));
  1507. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1508. if (filter) {
  1509. /* We only want to grab users from the ds side - no groups */
  1510. slapi_ch_free_string(filter);
  1511. /* maybe use ntUniqueId=* - only get users that have already been
  1512. synced with AD already - ntUniqueId and ntUserDomainId are
  1513. indexed for equality only - need to add presence? */
  1514. *filter = slapi_ch_strdup("(&(objectclass=ntuser)(ntUserDomainId=*))");
  1515. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1516. "--> test_winsync_pre_ds_search_all_cb -- new filter [%s]\n",
  1517. *filter ? *filter : "NULL"));
  1518. }
  1519. #endif
  1520. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1521. "<-- test_winsync_pre_ds_search_all_cb -- end\n");
  1522. return;
  1523. }
  1524. static void
  1525. test_winsync_pre_ad_mod_user_cb(void *cbdata, const Slapi_Entry *rawentry,
  1526. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1527. Slapi_Mods *smods, int *do_modify)
  1528. {
  1529. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1530. "--> test_winsync_pre_ad_mod_user_cb -- begin\n");
  1531. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1532. "<-- test_winsync_pre_ad_mod_user_cb -- end\n");
  1533. return;
  1534. }
  1535. static void
  1536. test_winsync_pre_ad_mod_group_cb(void *cbdata, const Slapi_Entry *rawentry,
  1537. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1538. Slapi_Mods *smods, int *do_modify)
  1539. {
  1540. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1541. "--> test_winsync_pre_ad_mod_group_cb -- begin\n");
  1542. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1543. "<-- test_winsync_pre_ad_mod_group_cb -- end\n");
  1544. return;
  1545. }
  1546. static void
  1547. test_winsync_pre_ds_mod_user_cb(void *cbdata, const Slapi_Entry *rawentry,
  1548. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1549. Slapi_Mods *smods, int *do_modify)
  1550. {
  1551. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1552. "--> test_winsync_pre_ds_mod_user_cb -- begin\n");
  1553. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1554. "<-- test_winsync_pre_ds_mod_user_cb -- end\n");
  1555. return;
  1556. }
  1557. static void
  1558. test_winsync_pre_ds_mod_group_cb(void *cbdata, const Slapi_Entry *rawentry,
  1559. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
  1560. Slapi_Mods *smods, int *do_modify)
  1561. {
  1562. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1563. "--> test_winsync_pre_ds_mod_group_cb -- begin\n");
  1564. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1565. "<-- test_winsync_pre_ds_mod_group_cb -- end\n");
  1566. return;
  1567. }
  1568. static void
  1569. test_winsync_pre_ds_add_user_cb(void *cbdata, const Slapi_Entry *rawentry,
  1570. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry)
  1571. {
  1572. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1573. "--> test_winsync_pre_ds_add_user_cb -- begin\n");
  1574. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1575. "<-- test_winsync_pre_ds_add_user_cb -- end\n");
  1576. return;
  1577. }
  1578. static void
  1579. test_winsync_pre_ds_add_group_cb(void *cbdata, const Slapi_Entry *rawentry,
  1580. Slapi_Entry *ad_entry, Slapi_Entry *ds_entry)
  1581. {
  1582. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1583. "--> test_winsync_pre_ds_add_group_cb -- begin\n");
  1584. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1585. "<-- test_winsync_pre_ds_add_group_cb -- end\n");
  1586. return;
  1587. }
  1588. static void
  1589. test_winsync_get_new_ds_user_dn_cb(void *cbdata, const Slapi_Entry *rawentry,
  1590. Slapi_Entry *ad_entry, char **new_dn_string,
  1591. const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix)
  1592. {
  1593. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1594. "--> test_winsync_get_new_ds_user_dn_cb -- old dn [%s] -- begin\n",
  1595. *new_dn_string);
  1596. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1597. char **rdns = slapi_ldap_explode_dn(*new_dn_string, 0);
  1598. if (!rdns || !rdns[0]) {
  1599. slapi_ldap_value_free(rdns);
  1600. return;
  1601. }
  1602. slapi_ch_free_string(new_dn_string);
  1603. *new_dn_string = PR_smprintf("%s,%s", rdns[0], slapi_sdn_get_dn(ds_suffix));
  1604. slapi_ldap_value_free(rdns);
  1605. #endif
  1606. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1607. "<-- test_winsync_get_new_ds_user_dn_cb -- new dn [%s] -- end\n",
  1608. *new_dn_string);
  1609. return;
  1610. }
  1611. static void
  1612. test_winsync_get_new_ds_group_dn_cb(void *cbdata, const Slapi_Entry *rawentry,
  1613. Slapi_Entry *ad_entry, char **new_dn_string,
  1614. const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix)
  1615. {
  1616. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1617. "--> test_winsync_get_new_ds_group_dn_cb -- begin\n");
  1618. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1619. "<-- test_winsync_get_new_ds_group_dn_cb -- end\n");
  1620. return;
  1621. }
  1622. static void
  1623. test_winsync_pre_ad_mod_user_mods_cb(void *cbdata, const Slapi_Entry *rawentry,
  1624. const Slapi_Entry *ds_entry,
  1625. const Slapi_DN *local_dn, LDAPMod * const *origmods,
  1626. Slapi_DN *remote_dn, LDAPMod ***modstosend)
  1627. {
  1628. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1629. "--> test_winsync_pre_ad_mod_user_mods_cb -- begin\n");
  1630. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1631. "<-- test_winsync_pre_ad_mod_user_mods_cb -- end\n");
  1632. return;
  1633. }
  1634. static void
  1635. test_winsync_pre_ad_mod_group_mods_cb(void *cbdata, const Slapi_Entry *rawentry,
  1636. const Slapi_Entry *ds_entry,
  1637. const Slapi_DN *local_dn, LDAPMod * const *origmods,
  1638. Slapi_DN *remote_dn, LDAPMod ***modstosend)
  1639. {
  1640. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1641. "--> test_winsync_pre_ad_mod_group_mods_cb -- begin\n");
  1642. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1643. "<-- test_winsync_pre_ad_mod_group_mods_cb -- end\n");
  1644. return;
  1645. }
  1646. static int
  1647. test_winsync_can_add_entry_to_ad_cb(void *cbdata, const Slapi_Entry *local_entry,
  1648. const Slapi_DN *remote_dn)
  1649. {
  1650. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1651. "--> test_winsync_can_add_entry_to_ad_cb -- begin\n");
  1652. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1653. "<-- test_winsync_can_add_entry_to_ad_cb -- end\n");
  1654. /* return 0;*/ /* false - do not allow entries to be added to ad */
  1655. return 1; /* true - allow entries to be added to ad */
  1656. }
  1657. static void
  1658. test_winsync_begin_update_cb(void *cbdata, const Slapi_DN *ds_subtree,
  1659. const Slapi_DN *ad_subtree, int is_total)
  1660. {
  1661. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1662. "--> test_winsync_begin_update_cb -- begin\n");
  1663. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1664. "<-- test_winsync_begin_update_cb -- end\n");
  1665. return;
  1666. }
  1667. static void
  1668. test_winsync_end_update_cb(void *cbdata, const Slapi_DN *ds_subtree,
  1669. const Slapi_DN *ad_subtree, int is_total)
  1670. {
  1671. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1672. "--> test_winsync_end_update_cb -- begin\n");
  1673. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1674. "<-- test_winsync_end_update_cb -- end\n");
  1675. return;
  1676. }
  1677. static void
  1678. test_winsync_destroy_agmt_cb(void *cbdata, const Slapi_DN *ds_subtree,
  1679. const Slapi_DN *ad_subtree)
  1680. {
  1681. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1682. "--> test_winsync_destroy_agmt_cb -- begin\n");
  1683. /* free(cbdata); */
  1684. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1685. "<-- test_winsync_destroy_agmt_cb -- end\n");
  1686. return;
  1687. }
  1688. static void
  1689. test_winsync_post_ad_mod_user_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *result)
  1690. {
  1691. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1692. "--> test_winsync_post_ad_mod_user_cb -- begin\n");
  1693. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1694. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1695. "Result of modifying AD entry [%s] was [%d:%s]\n",
  1696. slapi_entry_get_dn(ad_entry), *result, ldap_err2string(*result));
  1697. #endif
  1698. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1699. "<-- test_winsync_post_ad_mod_user_cb -- end\n");
  1700. return;
  1701. }
  1702. static void
  1703. test_winsync_post_ad_mod_group_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *result)
  1704. {
  1705. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1706. "--> test_winsync_post_ad_mod_group_cb -- begin\n");
  1707. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1708. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1709. "Result of modifying AD entry [%s] was [%d:%s]\n",
  1710. slapi_entry_get_dn(ad_entry), *result, ldap_err2string(*result));
  1711. #endif
  1712. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1713. "<-- test_winsync_post_ad_mod_group_cb -- end\n");
  1714. return;
  1715. }
  1716. static void
  1717. test_winsync_post_ds_mod_user_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *result)
  1718. {
  1719. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1720. "--> test_winsync_post_ds_mod_user_cb -- begin\n");
  1721. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1722. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1723. "Result of modifying DS entry [%s] was [%d:%s]\n",
  1724. slapi_entry_get_dn(ds_entry), *result, ldap_err2string(*result));
  1725. #endif
  1726. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1727. "<-- test_winsync_post_ds_mod_user_cb -- end\n");
  1728. return;
  1729. }
  1730. static void
  1731. test_winsync_post_ds_mod_group_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, Slapi_Mods *smods, int *result)
  1732. {
  1733. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1734. "--> test_winsync_post_ds_mod_group_cb -- begin\n");
  1735. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1736. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1737. "Result of modifying DS entry [%s] was [%d:%s]\n",
  1738. slapi_entry_get_dn(ds_entry), *result, ldap_err2string(*result));
  1739. #endif
  1740. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1741. "<-- test_winsync_post_ds_mod_group_cb -- end\n");
  1742. return;
  1743. }
  1744. static void
  1745. test_winsync_post_ds_add_user_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result)
  1746. {
  1747. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1748. "--> test_winsync_post_ds_add_user_cb -- begin\n");
  1749. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1750. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1751. "Result of adding DS entry [%s] was [%d:%s]\n",
  1752. slapi_entry_get_dn(ds_entry), *result, ldap_err2string(*result));
  1753. #endif
  1754. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1755. "<-- test_winsync_post_ds_add_user_cb -- end\n");
  1756. return;
  1757. }
  1758. static void
  1759. test_winsync_post_ds_add_group_cb(void *cookie, const Slapi_Entry *rawentry, Slapi_Entry *ad_entry, Slapi_Entry *ds_entry, int *result)
  1760. {
  1761. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1762. "--> test_winsync_post_ds_add_group_cb -- begin\n");
  1763. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1764. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1765. "Result of adding DS entry [%s] was [%d:%s]\n",
  1766. slapi_entry_get_dn(ds_entry), *result, ldap_err2string(*result));
  1767. #endif
  1768. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1769. "<-- test_winsync_post_ds_add_group_cb -- end\n");
  1770. return;
  1771. }
  1772. static void
  1773. test_winsync_pre_ad_add_user_cb(void *cookie, Slapi_Entry *ds_entry, Slapi_Entry *ad_entry)
  1774. {
  1775. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1776. "--> test_winsync_pre_ad_add_user_cb -- begin\n");
  1777. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1778. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1779. "Adding AD entry [%s] from add of DS entry [%s]\n",
  1780. slapi_entry_get_dn(ad_entry), slapi_entry_get_dn(ds_entry));
  1781. /* make modifications to ad_entry here */
  1782. #endif
  1783. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1784. "<-- test_winsync_pre_ad_add_user_cb -- end\n");
  1785. return;
  1786. }
  1787. static void
  1788. test_winsync_pre_ad_add_group_cb(void *cookie, Slapi_Entry *ds_entry, Slapi_Entry *ad_entry)
  1789. {
  1790. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1791. "--> test_winsync_pre_ad_add_group_cb -- begin\n");
  1792. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1793. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1794. "Adding AD entry [%s] from add of DS entry [%s]\n",
  1795. slapi_entry_get_dn(ad_entry), slapi_entry_get_dn(ds_entry));
  1796. /* make modifications to ad_entry here */
  1797. #endif
  1798. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1799. "<-- test_winsync_pre_ad_add_group_cb -- end\n");
  1800. return;
  1801. }
  1802. static void
  1803. test_winsync_post_ad_add_user_cb(void *cookie, Slapi_Entry *ds_entry, Slapi_Entry *ad_entry, int *result)
  1804. {
  1805. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1806. "--> test_winsync_post_ad_add_user_cb -- begin\n");
  1807. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1808. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1809. "Result of adding AD entry [%s] was [%d:%s]\n",
  1810. slapi_entry_get_dn(ad_entry), *result, ldap_err2string(*result));
  1811. #endif
  1812. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1813. "<-- test_winsync_post_ad_add_user_cb -- end\n");
  1814. return;
  1815. }
  1816. static void
  1817. test_winsync_post_ad_add_group_cb(void *cookie, Slapi_Entry *ds_entry, Slapi_Entry *ad_entry, int *result)
  1818. {
  1819. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1820. "--> test_winsync_post_ad_add_group_cb -- begin\n");
  1821. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1822. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1823. "Result of adding AD entry [%s] was [%d:%s]\n",
  1824. slapi_entry_get_dn(ad_entry), *result, ldap_err2string(*result));
  1825. #endif
  1826. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1827. "<-- test_winsync_post_ad_add_group_cb -- end\n");
  1828. return;
  1829. }
  1830. static void
  1831. test_winsync_post_ad_mod_user_mods_cb(void *cookie, 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)
  1832. {
  1833. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1834. "--> test_winsync_post_ad_mod_user_mods_cb -- begin\n");
  1835. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1836. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1837. "Result of modifying AD entry [%s] was [%d:%s]\n",
  1838. slapi_sdn_get_dn(remote_dn), *result, ldap_err2string(*result));
  1839. #endif
  1840. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1841. "<-- test_winsync_post_ad_mod_user_mods_cb -- end\n");
  1842. return;
  1843. }
  1844. static void
  1845. test_winsync_post_ad_mod_group_mods_cb(void *cookie, 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)
  1846. {
  1847. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1848. "--> test_winsync_post_ad_mod_group_mods_cb -- begin\n");
  1849. #ifdef THIS_IS_JUST_AN_EXAMPLE
  1850. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1851. "Result of modifying AD entry [%s] was [%d:%s]\n",
  1852. slapi_sdn_get_dn(remote_dn), *result, ldap_err2string(*result));
  1853. #endif
  1854. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1855. "<-- test_winsync_post_ad_mod_group_mods_cb -- end\n");
  1856. return;
  1857. }
  1858. static int
  1859. test_winsync_precedence(void)
  1860. {
  1861. return 99;
  1862. }
  1863. /**
  1864. * Plugin identifiers
  1865. */
  1866. static Slapi_PluginDesc test_winsync_pdesc = {
  1867. "test-winsync-plugin",
  1868. VENDOR,
  1869. DS_PACKAGE_VERSION,
  1870. "test winsync plugin"
  1871. };
  1872. static Slapi_ComponentId *test_winsync_plugin_id = NULL;
  1873. #ifdef TEST_V1_WINSYNC_API
  1874. static void *test_winsync_api_v1[] = {
  1875. NULL, /* reserved for api broker use, must be zero */
  1876. test_winsync_api_init,
  1877. test_winsync_dirsync_search_params_cb,
  1878. test_winsync_pre_ad_search_cb,
  1879. test_winsync_pre_ds_search_entry_cb,
  1880. test_winsync_pre_ds_search_all_cb,
  1881. test_winsync_pre_ad_mod_user_cb,
  1882. test_winsync_pre_ad_mod_group_cb,
  1883. test_winsync_pre_ds_mod_user_cb,
  1884. test_winsync_pre_ds_mod_group_cb,
  1885. test_winsync_pre_ds_add_user_cb,
  1886. test_winsync_pre_ds_add_group_cb,
  1887. test_winsync_get_new_ds_user_dn_cb,
  1888. test_winsync_get_new_ds_group_dn_cb,
  1889. test_winsync_pre_ad_mod_user_mods_cb,
  1890. test_winsync_pre_ad_mod_group_mods_cb,
  1891. test_winsync_can_add_entry_to_ad_cb,
  1892. test_winsync_begin_update_cb,
  1893. test_winsync_end_update_cb,
  1894. test_winsync_destroy_agmt_cb
  1895. };
  1896. #endif /* TEST_V1_WINSYNC_API */
  1897. #ifdef TEST_V2_WINSYNC_API
  1898. static void *test_winsync_api_v2[] = {
  1899. NULL, /* reserved for api broker use, must be zero */
  1900. test_winsync_api_init,
  1901. test_winsync_dirsync_search_params_cb,
  1902. test_winsync_pre_ad_search_cb,
  1903. test_winsync_pre_ds_search_entry_cb,
  1904. test_winsync_pre_ds_search_all_cb,
  1905. test_winsync_pre_ad_mod_user_cb,
  1906. test_winsync_pre_ad_mod_group_cb,
  1907. test_winsync_pre_ds_mod_user_cb,
  1908. test_winsync_pre_ds_mod_group_cb,
  1909. test_winsync_pre_ds_add_user_cb,
  1910. test_winsync_pre_ds_add_group_cb,
  1911. test_winsync_get_new_ds_user_dn_cb,
  1912. test_winsync_get_new_ds_group_dn_cb,
  1913. test_winsync_pre_ad_mod_user_mods_cb,
  1914. test_winsync_pre_ad_mod_group_mods_cb,
  1915. test_winsync_can_add_entry_to_ad_cb,
  1916. test_winsync_begin_update_cb,
  1917. test_winsync_end_update_cb,
  1918. test_winsync_destroy_agmt_cb,
  1919. test_winsync_post_ad_mod_user_cb,
  1920. test_winsync_post_ad_mod_group_cb,
  1921. test_winsync_post_ds_mod_user_cb,
  1922. test_winsync_post_ds_mod_group_cb,
  1923. test_winsync_post_ds_add_user_cb,
  1924. test_winsync_post_ds_add_group_cb,
  1925. test_winsync_pre_ad_add_user_cb,
  1926. test_winsync_pre_ad_add_group_cb,
  1927. test_winsync_post_ad_add_user_cb,
  1928. test_winsync_post_ad_add_group_cb,
  1929. test_winsync_post_ad_mod_user_mods_cb,
  1930. test_winsync_post_ad_mod_group_mods_cb
  1931. };
  1932. #endif /* TEST_V2_WINSYNC_API */
  1933. static void *test_winsync_api_v3[] = {
  1934. NULL, /* reserved for api broker use, must be zero */
  1935. test_winsync_api_init,
  1936. test_winsync_dirsync_search_params_cb,
  1937. test_winsync_pre_ad_search_cb,
  1938. test_winsync_pre_ds_search_entry_cb,
  1939. test_winsync_pre_ds_search_all_cb,
  1940. test_winsync_pre_ad_mod_user_cb,
  1941. test_winsync_pre_ad_mod_group_cb,
  1942. test_winsync_pre_ds_mod_user_cb,
  1943. test_winsync_pre_ds_mod_group_cb,
  1944. test_winsync_pre_ds_add_user_cb,
  1945. test_winsync_pre_ds_add_group_cb,
  1946. test_winsync_get_new_ds_user_dn_cb,
  1947. test_winsync_get_new_ds_group_dn_cb,
  1948. test_winsync_pre_ad_mod_user_mods_cb,
  1949. test_winsync_pre_ad_mod_group_mods_cb,
  1950. test_winsync_can_add_entry_to_ad_cb,
  1951. test_winsync_begin_update_cb,
  1952. test_winsync_end_update_cb,
  1953. test_winsync_destroy_agmt_cb,
  1954. test_winsync_post_ad_mod_user_cb,
  1955. test_winsync_post_ad_mod_group_cb,
  1956. test_winsync_post_ds_mod_user_cb,
  1957. test_winsync_post_ds_mod_group_cb,
  1958. test_winsync_post_ds_add_user_cb,
  1959. test_winsync_post_ds_add_group_cb,
  1960. test_winsync_pre_ad_add_user_cb,
  1961. test_winsync_pre_ad_add_group_cb,
  1962. test_winsync_post_ad_add_user_cb,
  1963. test_winsync_post_ad_add_group_cb,
  1964. test_winsync_post_ad_mod_user_mods_cb,
  1965. test_winsync_post_ad_mod_group_mods_cb,
  1966. test_winsync_precedence
  1967. };
  1968. static int
  1969. test_winsync_plugin_start(Slapi_PBlock *pb)
  1970. {
  1971. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1972. "--> test_winsync_plugin_start -- begin\n");
  1973. if( slapi_apib_register(WINSYNC_v3_0_GUID, test_winsync_api_v3) ) {
  1974. slapi_log_error( SLAPI_LOG_FATAL, test_winsync_plugin_name,
  1975. "<-- test_winsync_plugin_start -- failed to register winsync api -- end\n");
  1976. return -1;
  1977. }
  1978. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1979. "<-- test_winsync_plugin_start -- end\n");
  1980. return 0;
  1981. }
  1982. static int
  1983. test_winsync_plugin_close(Slapi_PBlock *pb)
  1984. {
  1985. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1986. "--> test_winsync_plugin_close -- begin\n");
  1987. slapi_apib_unregister(WINSYNC_v3_0_GUID);
  1988. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1989. "<-- test_winsync_plugin_close -- end\n");
  1990. return 0;
  1991. }
  1992. /* this is the slapi plugin init function,
  1993. not the one used by the winsync api
  1994. */
  1995. int test_winsync_plugin_init(Slapi_PBlock *pb)
  1996. {
  1997. slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  1998. "--> test_winsync_plugin_init -- begin\n");
  1999. if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
  2000. SLAPI_PLUGIN_VERSION_01 ) != 0 ||
  2001. slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN,
  2002. (void *) test_winsync_plugin_start ) != 0 ||
  2003. slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN,
  2004. (void *) test_winsync_plugin_close ) != 0 ||
  2005. slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
  2006. (void *)&test_winsync_pdesc ) != 0 )
  2007. {
  2008. slapi_log_error( SLAPI_LOG_FATAL, test_winsync_plugin_name,
  2009. "<-- test_winsync_plugin_init -- failed to register plugin -- end\n");
  2010. return -1;
  2011. }
  2012. /* Retrieve and save the plugin identity to later pass to
  2013. internal operations */
  2014. if (slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &test_winsync_plugin_id) != 0) {
  2015. slapi_log_error(SLAPI_LOG_FATAL, test_winsync_plugin_name,
  2016. "<-- test_winsync_plugin_init -- failed to retrieve plugin identity -- end\n");
  2017. return -1;
  2018. }
  2019. slapi_log_error( SLAPI_LOG_PLUGIN, test_winsync_plugin_name,
  2020. "<-- test_winsync_plugin_init -- end\n");
  2021. return 0;
  2022. }
  2023. /*
  2024. dn: cn=Test Winsync API,cn=plugins,cn=config
  2025. objectclass: top
  2026. objectclass: nsSlapdPlugin
  2027. objectclass: extensibleObject
  2028. cn: Test Winsync API
  2029. nsslapd-pluginpath: libtestwinsync-plugin
  2030. nsslapd-plugininitfunc: test_winsync_plugin_init
  2031. nsslapd-plugintype: preoperation
  2032. nsslapd-pluginenabled: on
  2033. nsslapd-plugin-depends-on-type: database
  2034. nsslapd-pluginDescription: Test Winsync
  2035. nsslapd-pluginVendor: 389 project
  2036. nsslapd-pluginId: test-winsync
  2037. nsslapd-pluginVersion: 0.9
  2038. */
  2039. #endif /* WINSYNC_SAMPLE_CODE */
  2040. /* #define WINSYNC_TEST_IPA */
  2041. #ifdef WINSYNC_TEST_IPA
  2042. #include "ipa-winsync.c"
  2043. #include "ipa-winsync-config.c"
  2044. #endif