pblock.c 107 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
  5. * All rights reserved.
  6. *
  7. * License: GPL (version 3 or any later version).
  8. * See LICENSE for details.
  9. * END COPYRIGHT BLOCK **/
  10. #ifdef HAVE_CONFIG_H
  11. # include <config.h>
  12. #endif
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <sys/types.h>
  16. #include "slap.h"
  17. #include "cert.h"
  18. void
  19. pblock_init( Slapi_PBlock *pb )
  20. {
  21. memset( pb, '\0', sizeof(Slapi_PBlock) );
  22. }
  23. void
  24. pblock_init_common(
  25. Slapi_PBlock *pb,
  26. Slapi_Backend *be,
  27. Connection *conn,
  28. Operation *op
  29. )
  30. {
  31. PR_ASSERT( NULL != pb );
  32. memset( pb, '\0', sizeof(Slapi_PBlock) );
  33. pb->pb_backend = be;
  34. pb->pb_conn = conn;
  35. pb->pb_op = op;
  36. }
  37. void
  38. slapi_pblock_get_common(
  39. Slapi_PBlock *pb,
  40. Slapi_Backend **be,
  41. Connection **conn,
  42. Operation **op
  43. )
  44. {
  45. PR_ASSERT( NULL != pb );
  46. PR_ASSERT( NULL != be );
  47. PR_ASSERT( NULL != conn );
  48. PR_ASSERT( NULL != op );
  49. *be = pb->pb_backend;
  50. *conn = pb->pb_conn;
  51. *op = pb->pb_op;
  52. }
  53. Slapi_PBlock *
  54. slapi_pblock_new()
  55. {
  56. Slapi_PBlock *pb;
  57. pb = (Slapi_PBlock *) slapi_ch_calloc( 1, sizeof(Slapi_PBlock) );
  58. return pb;
  59. }
  60. void
  61. slapi_pblock_init( Slapi_PBlock *pb )
  62. {
  63. if(pb!=NULL)
  64. {
  65. pblock_done(pb);
  66. pblock_init(pb);
  67. }
  68. }
  69. void
  70. pblock_done( Slapi_PBlock *pb )
  71. {
  72. if(pb->pb_op!=NULL)
  73. {
  74. operation_free(&pb->pb_op,pb->pb_conn);
  75. }
  76. delete_passwdPolicy(&pb->pwdpolicy);
  77. slapi_ch_free((void**)&(pb->pb_vattr_context));
  78. slapi_ch_free((void**)&(pb->pb_result_text));
  79. }
  80. void
  81. slapi_pblock_destroy( Slapi_PBlock* pb )
  82. {
  83. if(pb!=NULL)
  84. {
  85. pblock_done(pb);
  86. slapi_ch_free((void**)&pb);
  87. }
  88. }
  89. /* JCM - when pb_o_params is used, check the operation type. */
  90. /* JCM - when pb_o_results is used, check the operation type. */
  91. #define SLAPI_PLUGIN_TYPE_CHECK(PBLOCK,TYPE) \
  92. if ( PBLOCK ->pb_plugin->plg_type != TYPE) return( -1 )
  93. /*
  94. * Macro used to safely retrieve a plugin related pblock value (if the
  95. * pb_plugin element is NULL, NULL is returned).
  96. */
  97. #define SLAPI_PBLOCK_GET_PLUGIN_RELATED_POINTER( pb, element ) \
  98. ((pb)->pb_plugin == NULL ? NULL : (pb)->pb_plugin->element)
  99. int
  100. slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
  101. {
  102. char *authtype;
  103. Slapi_Backend *be;
  104. PR_ASSERT( NULL != pblock );
  105. PR_ASSERT( NULL != value );
  106. be = pblock->pb_backend;
  107. switch ( arg ) {
  108. case SLAPI_BACKEND:
  109. (*(Slapi_Backend **)value) = be;
  110. break;
  111. case SLAPI_BACKEND_COUNT:
  112. (*(int *)value) = pblock->pb_backend_count;
  113. break;
  114. case SLAPI_BE_TYPE:
  115. if ( NULL == be ) {
  116. return( -1 );
  117. }
  118. (*(char **)value) = be->be_type;
  119. break;
  120. case SLAPI_BE_READONLY:
  121. if ( NULL == be ) {
  122. (*(int *)value) = 0; /* default value */
  123. } else {
  124. (*(int *)value) = be->be_readonly;
  125. }
  126. break;
  127. case SLAPI_BE_LASTMOD:
  128. if ( NULL == be ) {
  129. (*(int *)value) = (g_get_global_lastmod() == LDAP_ON);
  130. } else {
  131. (*(int *)value) = (be->be_lastmod == LDAP_ON || (be->be_lastmod
  132. == LDAP_UNDEFINED && g_get_global_lastmod() == LDAP_ON));
  133. }
  134. break;
  135. case SLAPI_CONNECTION:
  136. (*(Connection **)value) = pblock->pb_conn;
  137. break;
  138. case SLAPI_CONN_ID:
  139. if (pblock->pb_conn == NULL) {
  140. LDAPDebug( LDAP_DEBUG_TRACE,
  141. "Connection is NULL and hence cannot access SLAPI_CONN_ID \n", 0, 0, 0 );
  142. return (-1);
  143. }
  144. (*(PRUint64 *)value) = pblock->pb_conn->c_connid;
  145. break;
  146. case SLAPI_CONN_DN:
  147. /*
  148. * NOTE: we have to make a copy of this that the caller
  149. * is responsible for freeing. otherwise, they would get
  150. * a pointer that could be freed out from under them.
  151. */
  152. if (pblock->pb_conn == NULL) {
  153. LDAPDebug( LDAP_DEBUG_ANY,
  154. "Connection is NULL and hence cannot access SLAPI_CONN_DN \n", 0, 0, 0 );
  155. return (-1);
  156. }
  157. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  158. (*(char **)value) = (NULL == pblock->pb_conn->c_dn ? NULL :
  159. slapi_ch_strdup( pblock->pb_conn->c_dn ));
  160. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  161. break;
  162. case SLAPI_CONN_AUTHTYPE:/* deprecated */
  163. if (pblock->pb_conn == NULL) {
  164. LDAPDebug( LDAP_DEBUG_ANY,
  165. "Connection is NULL and hence cannot access SLAPI_CONN_AUTHTYPE \n", 0, 0, 0 );
  166. return (-1);
  167. }
  168. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  169. authtype = pblock->pb_conn->c_authtype;
  170. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  171. if (authtype == NULL) {
  172. (*(char **)value) = NULL;
  173. } else if (strcasecmp(authtype, SLAPD_AUTH_NONE) == 0) {
  174. (*(char **)value) = SLAPD_AUTH_NONE;
  175. } else if (strcasecmp(authtype, SLAPD_AUTH_SIMPLE) == 0) {
  176. (*(char **)value) = SLAPD_AUTH_SIMPLE;
  177. } else if (strcasecmp(authtype, SLAPD_AUTH_SSL) == 0) {
  178. (*(char **)value) = SLAPD_AUTH_SSL;
  179. } else if (strcasecmp(authtype, SLAPD_AUTH_OS) == 0) {
  180. (*(char **)value) = SLAPD_AUTH_OS;
  181. } else if (strncasecmp(authtype, SLAPD_AUTH_SASL,
  182. strlen(SLAPD_AUTH_SASL)) == 0) {
  183. (*(char **)value) = SLAPD_AUTH_SASL;
  184. } else {
  185. (*(char **)value) = "unknown";
  186. }
  187. break;
  188. case SLAPI_CONN_AUTHMETHOD:
  189. /* returns a copy */
  190. if (pblock->pb_conn == NULL) {
  191. LDAPDebug( LDAP_DEBUG_ANY,
  192. "Connection is NULL and hence cannot access SLAPI_CONN_AUTHMETHOD \n", 0, 0, 0 );
  193. return (-1);
  194. }
  195. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  196. (*(char **)value) = pblock->pb_conn->c_authtype ?
  197. slapi_ch_strdup(pblock->pb_conn->c_authtype) : NULL;
  198. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  199. break;
  200. case SLAPI_CONN_CLIENTNETADDR:
  201. if (pblock->pb_conn == NULL)
  202. {
  203. memset( value, 0, sizeof( PRNetAddr ));
  204. break;
  205. }
  206. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  207. if ( pblock->pb_conn->cin_addr == NULL ) {
  208. memset( value, 0, sizeof( PRNetAddr ));
  209. } else {
  210. (*(PRNetAddr *)value) =
  211. *(pblock->pb_conn->cin_addr);
  212. }
  213. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  214. break;
  215. case SLAPI_CONN_SERVERNETADDR:
  216. if (pblock->pb_conn == NULL)
  217. {
  218. memset( value, 0, sizeof( PRNetAddr ));
  219. break;
  220. }
  221. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  222. if ( pblock->pb_conn->cin_destaddr == NULL ) {
  223. memset( value, 0, sizeof( PRNetAddr ));
  224. } else {
  225. (*(PRNetAddr *)value) =
  226. *(pblock->pb_conn->cin_destaddr);
  227. }
  228. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  229. break;
  230. case SLAPI_CONN_CLIENTIP:
  231. if (pblock->pb_conn == NULL)
  232. {
  233. memset( value, 0, sizeof( struct in_addr ));
  234. break;
  235. }
  236. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  237. if ( pblock->pb_conn->cin_addr == NULL ) {
  238. memset( value, 0, sizeof( struct in_addr ));
  239. } else {
  240. if ( PR_IsNetAddrType(pblock->pb_conn->cin_addr,
  241. PR_IpAddrV4Mapped) ) {
  242. (*(struct in_addr *)value).s_addr =
  243. (*(pblock->pb_conn->cin_addr)).ipv6.ip.pr_s6_addr32[3];
  244. } else {
  245. memset( value, 0, sizeof( struct in_addr ));
  246. }
  247. }
  248. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  249. break;
  250. case SLAPI_CONN_SERVERIP:
  251. if (pblock->pb_conn == NULL)
  252. {
  253. memset( value, 0, sizeof( struct in_addr ));
  254. break;
  255. }
  256. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  257. if ( pblock->pb_conn->cin_destaddr == NULL ) {
  258. memset( value, 0, sizeof( PRNetAddr ));
  259. } else {
  260. if ( PR_IsNetAddrType(pblock->pb_conn->cin_destaddr,
  261. PR_IpAddrV4Mapped) ) {
  262. (*(struct in_addr *)value).s_addr =
  263. (*(pblock->pb_conn->cin_destaddr)).ipv6.ip.pr_s6_addr32[3];
  264. } else {
  265. memset( value, 0, sizeof( struct in_addr ));
  266. }
  267. }
  268. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  269. break;
  270. case SLAPI_CONN_IS_REPLICATION_SESSION:
  271. if (pblock->pb_conn == NULL) {
  272. LDAPDebug( LDAP_DEBUG_ANY,
  273. "Connection is NULL and hence cannot access SLAPI_CONN_IS_REPLICATION_SESSION \n", 0, 0, 0 );
  274. return (-1);
  275. }
  276. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  277. (*(int *)value) = pblock->pb_conn->c_isreplication_session;
  278. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  279. break;
  280. case SLAPI_CONN_IS_SSL_SESSION:
  281. if (pblock->pb_conn == NULL) {
  282. LDAPDebug( LDAP_DEBUG_ANY,
  283. "Connection is NULL and hence cannot access SLAPI_CONN_IS_SSL_SESSION \n", 0, 0, 0 );
  284. return (-1);
  285. }
  286. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  287. (*(int *)value) = pblock->pb_conn->c_flags & CONN_FLAG_SSL;
  288. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  289. break;
  290. case SLAPI_CONN_SASL_SSF:
  291. if (pblock->pb_conn == NULL) {
  292. LDAPDebug( LDAP_DEBUG_ANY,
  293. "Connection is NULL and hence cannot access SLAPI_CONN_SASL_SSF \n", 0, 0, 0 );
  294. return (-1);
  295. }
  296. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  297. (*(int *)value) = pblock->pb_conn->c_sasl_ssf;
  298. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  299. break;
  300. case SLAPI_CONN_SSL_SSF:
  301. if (pblock->pb_conn == NULL) {
  302. LDAPDebug( LDAP_DEBUG_ANY,
  303. "Connection is NULL and hence cannot access SLAPI_CONN_SSL_SSF \n", 0, 0, 0 );
  304. return (-1);
  305. }
  306. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  307. (*(int *)value) = pblock->pb_conn->c_ssl_ssf;
  308. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  309. break;
  310. case SLAPI_CONN_LOCAL_SSF:
  311. if (pblock->pb_conn == NULL) {
  312. LDAPDebug( LDAP_DEBUG_ANY,
  313. "Connection is NULL and hence cannot access SLAPI_CONN_LOCAL_SSF \n", 0, 0, 0 );
  314. return (-1);
  315. }
  316. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  317. (*(int *)value) = pblock->pb_conn->c_local_ssf;
  318. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  319. break;
  320. case SLAPI_CONN_CERT:
  321. if (pblock->pb_conn == NULL) {
  322. LDAPDebug( LDAP_DEBUG_ANY,
  323. "Connection is NULL and hence cannot access SLAPI_CONN_CERT \n", 0, 0, 0 );
  324. return (-1);
  325. }
  326. ( *(CERTCertificate **) value) = pblock->pb_conn->c_client_cert;
  327. break;
  328. case SLAPI_OPERATION:
  329. (*(Operation **)value) = pblock->pb_op;
  330. break;
  331. case SLAPI_OPERATION_TYPE:
  332. if (pblock->pb_op == NULL) {
  333. LDAPDebug( LDAP_DEBUG_ANY,
  334. "Operation is NULL and hence cannot access SLAPI_OPERATION_TYPE \n", 0, 0, 0 );
  335. return (-1);
  336. }
  337. (*(int *)value) = pblock->pb_op->o_params.operation_type;
  338. break;
  339. case SLAPI_OPINITIATED_TIME:
  340. if (pblock->pb_op == NULL) {
  341. LDAPDebug( LDAP_DEBUG_ANY,
  342. "Operation is NULL and hence cannot access SLAPI_OPINITIATED_TIME \n", 0, 0, 0 );
  343. return (-1);
  344. }
  345. (*(time_t *)value) = pblock->pb_op->o_time;
  346. break;
  347. case SLAPI_REQUESTOR_ISROOT:
  348. (*(int *)value) = pblock->pb_requestor_isroot;
  349. break;
  350. case SLAPI_SKIP_MODIFIED_ATTRS:
  351. if(pblock->pb_op==NULL)
  352. {
  353. (*(int *)value) = 0; /* No Operation -> No skip */
  354. }
  355. else
  356. {
  357. (*(int *)value) = (pblock->pb_op->o_flags & OP_FLAG_SKIP_MODIFIED_ATTRS);
  358. }
  359. break;
  360. case SLAPI_IS_REPLICATED_OPERATION:
  361. if(pblock->pb_op==NULL)
  362. {
  363. (*(int *)value) = 0; /* No Operation -> Not Replicated */
  364. }
  365. else
  366. {
  367. (*(int *)value) = (pblock->pb_op->o_flags & (OP_FLAG_REPLICATED | OP_FLAG_LEGACY_REPLICATION_DN));
  368. }
  369. break;
  370. case SLAPI_IS_MMR_REPLICATED_OPERATION:
  371. if(pblock->pb_op==NULL)
  372. {
  373. (*(int *)value) = 0; /* No Operation -> Not Replicated */
  374. }
  375. else
  376. {
  377. (*(int *)value) = (pblock->pb_op->o_flags & OP_FLAG_REPLICATED);
  378. }
  379. break;
  380. case SLAPI_IS_LEGACY_REPLICATED_OPERATION:
  381. if(pblock->pb_op==NULL)
  382. {
  383. (*(int *)value) = 0; /* No Operation -> Not Replicated */
  384. }
  385. else
  386. {
  387. (*(int *)value) = (pblock->pb_op->o_flags & OP_FLAG_LEGACY_REPLICATION_DN);
  388. }
  389. break;
  390. case SLAPI_OPERATION_PARAMETERS:
  391. if(pblock->pb_op!=NULL)
  392. {
  393. (*(struct slapi_operation_parameters **)value) = &pblock->pb_op->o_params;
  394. }
  395. break;
  396. /* stuff related to config file processing */
  397. case SLAPI_CONFIG_FILENAME:
  398. case SLAPI_CONFIG_LINENO:
  399. case SLAPI_CONFIG_ARGC:
  400. case SLAPI_CONFIG_ARGV:
  401. return (-1); /* deprecated since DS 5.0 (no longer useful) */
  402. /* pblock memory management */
  403. case SLAPI_DESTROY_CONTENT:
  404. (*(int *)value) = pblock->pb_destroy_content;
  405. break;
  406. /* stuff related to the current plugin */
  407. case SLAPI_PLUGIN:
  408. (*(struct slapdplugin **)value) = pblock->pb_plugin;
  409. break;
  410. case SLAPI_PLUGIN_PRIVATE:
  411. (*(void **)value) = pblock->pb_plugin->plg_private;
  412. break;
  413. case SLAPI_PLUGIN_TYPE:
  414. (*(int *)value) = pblock->pb_plugin->plg_type;
  415. break;
  416. case SLAPI_PLUGIN_ARGV:
  417. (*(char ***)value) = pblock->pb_plugin->plg_argv;
  418. break;
  419. case SLAPI_PLUGIN_ARGC:
  420. (*(int *)value) = pblock->pb_plugin->plg_argc;
  421. break;
  422. case SLAPI_PLUGIN_VERSION:
  423. (*(char **)value) = pblock->pb_plugin->plg_version;
  424. break;
  425. case SLAPI_PLUGIN_PRECEDENCE:
  426. (*(int *)value) = pblock->pb_plugin->plg_precedence;
  427. break;
  428. case SLAPI_PLUGIN_OPRETURN:
  429. (*(int *)value) = pblock->pb_opreturn;
  430. break;
  431. case SLAPI_PLUGIN_OBJECT:
  432. (*(void **)value) = pblock->pb_object;
  433. break;
  434. case SLAPI_PLUGIN_DESTROY_FN:
  435. (*(IFP*)value) = pblock->pb_destroy_fn;
  436. break;
  437. case SLAPI_PLUGIN_DESCRIPTION:
  438. (*(Slapi_PluginDesc *)value) = pblock->pb_plugin->plg_desc;
  439. break;
  440. case SLAPI_PLUGIN_IDENTITY:
  441. (*(void**)value) = pblock->pb_plugin_identity;
  442. break;
  443. case SLAPI_PLUGIN_CONFIG_AREA:
  444. (*(char **)value) = pblock->pb_plugin_config_area;
  445. break;
  446. case SLAPI_PLUGIN_INTOP_RESULT:
  447. (*(int *)value) = pblock->pb_internal_op_result;
  448. break;
  449. case SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES:
  450. (*(Slapi_Entry ***)value) = pblock->pb_plugin_internal_search_op_entries;
  451. break;
  452. case SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS:
  453. (*(char ***)value) = pblock->pb_plugin_internal_search_op_referrals;
  454. break;
  455. /* database plugin functions */
  456. case SLAPI_PLUGIN_DB_BIND_FN:
  457. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  458. return( -1 );
  459. }
  460. (*(IFP *)value) = pblock->pb_plugin->plg_bind;
  461. break;
  462. case SLAPI_PLUGIN_DB_UNBIND_FN:
  463. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  464. return( -1 );
  465. }
  466. (*(IFP *)value) = pblock->pb_plugin->plg_unbind;
  467. break;
  468. case SLAPI_PLUGIN_DB_SEARCH_FN:
  469. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  470. return( -1 );
  471. }
  472. (*(IFP *)value) = pblock->pb_plugin->plg_search;
  473. break;
  474. case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN:
  475. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  476. return( -1 );
  477. }
  478. (*(IFP *)value) = pblock->pb_plugin->plg_next_search_entry;
  479. break;
  480. case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN:
  481. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  482. return( -1 );
  483. }
  484. (*(IFP *)value) = pblock->pb_plugin->plg_next_search_entry_ext;
  485. break;
  486. case SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN:
  487. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  488. return( -1 );
  489. }
  490. (*(IFP *)value) = pblock->pb_plugin->plg_entry_release;
  491. break;
  492. case SLAPI_PLUGIN_DB_SEARCH_RESULTS_RELEASE_FN:
  493. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  494. return( -1 );
  495. }
  496. (*(VFPP *)value) = pblock->pb_plugin->plg_search_results_release;
  497. break;
  498. case SLAPI_PLUGIN_DB_PREV_SEARCH_RESULTS_FN:
  499. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  500. return( -1 );
  501. }
  502. (*(VFP *)value) = pblock->pb_plugin->plg_prev_search_results;
  503. break;
  504. case SLAPI_PLUGIN_DB_COMPARE_FN:
  505. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  506. return( -1 );
  507. }
  508. (*(IFP *)value) = pblock->pb_plugin->plg_compare;
  509. break;
  510. case SLAPI_PLUGIN_DB_MODIFY_FN:
  511. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  512. return( -1 );
  513. }
  514. (*(IFP *)value) = pblock->pb_plugin->plg_modify;
  515. break;
  516. case SLAPI_PLUGIN_DB_MODRDN_FN:
  517. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  518. return( -1 );
  519. }
  520. (*(IFP *)value) = pblock->pb_plugin->plg_modrdn;
  521. break;
  522. case SLAPI_PLUGIN_DB_ADD_FN:
  523. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  524. return( -1 );
  525. }
  526. (*(IFP *)value) = pblock->pb_plugin->plg_add;
  527. break;
  528. case SLAPI_PLUGIN_DB_DELETE_FN:
  529. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  530. return( -1 );
  531. }
  532. (*(IFP *)value) = pblock->pb_plugin->plg_delete;
  533. break;
  534. case SLAPI_PLUGIN_DB_ABANDON_FN:
  535. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  536. return( -1 );
  537. }
  538. (*(IFP *)value) = pblock->pb_plugin->plg_abandon;
  539. break;
  540. case SLAPI_PLUGIN_DB_CONFIG_FN:
  541. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  542. return( -1 );
  543. }
  544. (*(IFP *)value) = pblock->pb_plugin->plg_config;
  545. break;
  546. case SLAPI_PLUGIN_CLOSE_FN:
  547. (*(IFP *)value) = pblock->pb_plugin->plg_close;
  548. break;
  549. case SLAPI_PLUGIN_CLEANUP_FN:
  550. (*(IFP *)value) = pblock->pb_plugin->plg_cleanup;
  551. break;
  552. case SLAPI_PLUGIN_DB_FLUSH_FN:
  553. (*(IFP *)value) = pblock->pb_plugin->plg_flush;
  554. break;
  555. case SLAPI_PLUGIN_START_FN:
  556. (*(IFP *)value) = pblock->pb_plugin->plg_start;
  557. break;
  558. case SLAPI_PLUGIN_POSTSTART_FN:
  559. (*(IFP *)value) = pblock->pb_plugin->plg_poststart;
  560. break;
  561. case SLAPI_PLUGIN_DB_WIRE_IMPORT_FN:
  562. (*(IFP *)value) = pblock->pb_plugin->plg_wire_import;
  563. break;
  564. case SLAPI_PLUGIN_DB_ADD_SCHEMA_FN:
  565. (*(IFP *)value) = pblock->pb_plugin->plg_add_schema;
  566. break;
  567. case SLAPI_PLUGIN_DB_GET_INFO_FN:
  568. (*(IFP *)value) = pblock->pb_plugin->plg_get_info;
  569. break;
  570. case SLAPI_PLUGIN_DB_SET_INFO_FN:
  571. (*(IFP *)value) = pblock->pb_plugin->plg_set_info;
  572. break;
  573. case SLAPI_PLUGIN_DB_CTRL_INFO_FN:
  574. (*(IFP *)value) = pblock->pb_plugin->plg_ctrl_info;
  575. break;
  576. case SLAPI_PLUGIN_DB_SEQ_FN:
  577. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  578. return( -1 );
  579. }
  580. (*(IFP *)value) = pblock->pb_plugin->plg_seq;
  581. break;
  582. case SLAPI_PLUGIN_DB_ENTRY_FN:
  583. (*(IFP *)value) = SLAPI_PBLOCK_GET_PLUGIN_RELATED_POINTER( pblock,
  584. plg_entry );
  585. break;
  586. case SLAPI_PLUGIN_DB_REFERRAL_FN:
  587. (*(IFP *)value) = SLAPI_PBLOCK_GET_PLUGIN_RELATED_POINTER( pblock,
  588. plg_referral );
  589. break;
  590. case SLAPI_PLUGIN_DB_RESULT_FN:
  591. (*(IFP *)value) = SLAPI_PBLOCK_GET_PLUGIN_RELATED_POINTER( pblock,
  592. plg_result );
  593. break;
  594. case SLAPI_PLUGIN_DB_RMDB_FN:
  595. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  596. return( -1 );
  597. }
  598. (*(IFP *)value) = pblock->pb_plugin->plg_rmdb;
  599. break;
  600. case SLAPI_PLUGIN_DB_INIT_INSTANCE_FN:
  601. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  602. return( -1 );
  603. }
  604. (*(IFP *)value) = pblock->pb_plugin->plg_init_instance;
  605. break;
  606. case SLAPI_PLUGIN_DB_LDIF2DB_FN:
  607. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  608. return( -1 );
  609. }
  610. (*(IFP *)value) = pblock->pb_plugin->plg_ldif2db;
  611. break;
  612. case SLAPI_PLUGIN_DB_DB2LDIF_FN:
  613. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  614. return( -1 );
  615. }
  616. (*(IFP *)value) = pblock->pb_plugin->plg_db2ldif;
  617. break;
  618. case SLAPI_PLUGIN_DB_DB2INDEX_FN:
  619. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  620. return( -1 );
  621. }
  622. (*(IFP *)value) = pblock->pb_plugin->plg_db2index;
  623. break;
  624. case SLAPI_PLUGIN_DB_ARCHIVE2DB_FN:
  625. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  626. return( -1 );
  627. }
  628. (*(IFP *)value) = pblock->pb_plugin->plg_archive2db;
  629. break;
  630. case SLAPI_PLUGIN_DB_DB2ARCHIVE_FN:
  631. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  632. return( -1 );
  633. }
  634. (*(IFP *)value) = pblock->pb_plugin->plg_db2archive;
  635. break;
  636. case SLAPI_PLUGIN_DB_UPGRADEDB_FN:
  637. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  638. return( -1 );
  639. }
  640. (*(IFP *)value) = pblock->pb_plugin->plg_upgradedb;
  641. break;
  642. case SLAPI_PLUGIN_DB_UPGRADEDNFORMAT_FN:
  643. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  644. return( -1 );
  645. }
  646. (*(IFP *)value) = pblock->pb_plugin->plg_upgradednformat;
  647. break;
  648. case SLAPI_PLUGIN_DB_DBVERIFY_FN:
  649. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  650. return( -1 );
  651. }
  652. (*(IFP *)value) = pblock->pb_plugin->plg_dbverify;
  653. break;
  654. case SLAPI_PLUGIN_DB_BEGIN_FN:
  655. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  656. return( -1 );
  657. }
  658. (*(IFP *)value) = pblock->pb_plugin->plg_un.plg_un_db.plg_un_db_begin;
  659. break;
  660. case SLAPI_PLUGIN_DB_COMMIT_FN:
  661. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  662. return( -1 );
  663. }
  664. (*(IFP *)value) = pblock->pb_plugin->plg_un.plg_un_db.plg_un_db_commit;
  665. break;
  666. case SLAPI_PLUGIN_DB_ABORT_FN:
  667. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  668. return( -1 );
  669. }
  670. (*(IFP *)value) = pblock->pb_plugin->plg_un.plg_un_db.plg_un_db_abort;
  671. break;
  672. case SLAPI_PLUGIN_DB_SIZE_FN:
  673. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  674. return( -1 );
  675. }
  676. (*(IFP *)value) = pblock->pb_plugin->plg_un.plg_un_db.plg_un_db_dbsize;
  677. break;
  678. case SLAPI_PLUGIN_DB_TEST_FN:
  679. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  680. return( -1 );
  681. }
  682. (*(IFP *)value) = pblock->pb_plugin->plg_un.plg_un_db.plg_un_db_dbtest;
  683. break;
  684. /* database plugin-specific parameters */
  685. case SLAPI_PLUGIN_DB_NO_ACL:
  686. if ( pblock->pb_plugin && pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  687. return( -1 );
  688. }
  689. if ( NULL == be ) {
  690. (*(int *)value) = 0; /* default value */
  691. } else {
  692. (*(int *)value) = be->be_noacl;
  693. }
  694. break;
  695. /* extendedop plugin functions */
  696. case SLAPI_PLUGIN_EXT_OP_FN:
  697. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_EXTENDEDOP &&
  698. pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP ) {
  699. return( -1 );
  700. }
  701. (*(IFP *)value) = pblock->pb_plugin->plg_exhandler;
  702. break;
  703. case SLAPI_PLUGIN_EXT_OP_OIDLIST:
  704. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_EXTENDEDOP &&
  705. pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP ) {
  706. return( -1 );
  707. }
  708. (*(char ***)value) = pblock->pb_plugin->plg_exoids;
  709. break;
  710. case SLAPI_PLUGIN_EXT_OP_NAMELIST:
  711. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_EXTENDEDOP &&
  712. pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP ) {
  713. return( -1 );
  714. }
  715. (*(char ***)value) = pblock->pb_plugin->plg_exnames;
  716. break;
  717. case SLAPI_PLUGIN_EXT_OP_BACKEND_FN:
  718. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_EXTENDEDOP &&
  719. pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP ) {
  720. return( -1 );
  721. }
  722. (*(IFP *)value) = pblock->pb_plugin->plg_be_exhandler;
  723. break;
  724. /* preoperation plugin functions */
  725. case SLAPI_PLUGIN_PRE_BIND_FN:
  726. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  727. return( -1 );
  728. }
  729. (*(IFP *)value) = pblock->pb_plugin->plg_prebind;
  730. break;
  731. case SLAPI_PLUGIN_PRE_UNBIND_FN:
  732. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  733. return( -1 );
  734. }
  735. (*(IFP *)value) = pblock->pb_plugin->plg_preunbind;
  736. break;
  737. case SLAPI_PLUGIN_PRE_SEARCH_FN:
  738. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  739. return( -1 );
  740. }
  741. (*(IFP *)value) = pblock->pb_plugin->plg_presearch;
  742. break;
  743. case SLAPI_PLUGIN_PRE_COMPARE_FN:
  744. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  745. return( -1 );
  746. }
  747. (*(IFP *)value) = pblock->pb_plugin->plg_precompare;
  748. break;
  749. case SLAPI_PLUGIN_PRE_MODIFY_FN:
  750. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  751. return( -1 );
  752. }
  753. (*(IFP *)value) = pblock->pb_plugin->plg_premodify;
  754. break;
  755. case SLAPI_PLUGIN_PRE_MODRDN_FN:
  756. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  757. return( -1 );
  758. }
  759. (*(IFP *)value) = pblock->pb_plugin->plg_premodrdn;
  760. break;
  761. case SLAPI_PLUGIN_PRE_ADD_FN:
  762. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  763. return( -1 );
  764. }
  765. (*(IFP *)value) = pblock->pb_plugin->plg_preadd;
  766. break;
  767. case SLAPI_PLUGIN_PRE_DELETE_FN:
  768. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  769. return( -1 );
  770. }
  771. (*(IFP *)value) = pblock->pb_plugin->plg_predelete;
  772. break;
  773. case SLAPI_PLUGIN_PRE_ABANDON_FN:
  774. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  775. return( -1 );
  776. }
  777. (*(IFP *)value) = pblock->pb_plugin->plg_preabandon;
  778. break;
  779. case SLAPI_PLUGIN_PRE_ENTRY_FN:
  780. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  781. return( -1 );
  782. }
  783. (*(IFP *)value) = pblock->pb_plugin->plg_preentry;
  784. break;
  785. case SLAPI_PLUGIN_PRE_REFERRAL_FN:
  786. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  787. return( -1 );
  788. }
  789. (*(IFP *)value) = pblock->pb_plugin->plg_prereferral;
  790. break;
  791. case SLAPI_PLUGIN_PRE_RESULT_FN:
  792. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  793. return( -1 );
  794. }
  795. (*(IFP *)value) = pblock->pb_plugin->plg_preresult;
  796. break;
  797. /* postoperation plugin functions */
  798. case SLAPI_PLUGIN_POST_BIND_FN:
  799. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  800. return( -1 );
  801. }
  802. (*(IFP *)value) = pblock->pb_plugin->plg_postbind;
  803. break;
  804. case SLAPI_PLUGIN_POST_UNBIND_FN:
  805. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  806. return( -1 );
  807. }
  808. (*(IFP *)value) = pblock->pb_plugin->plg_postunbind;
  809. break;
  810. case SLAPI_PLUGIN_POST_SEARCH_FN:
  811. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  812. return( -1 );
  813. }
  814. (*(IFP *)value) = pblock->pb_plugin->plg_postsearch;
  815. break;
  816. case SLAPI_PLUGIN_POST_SEARCH_FAIL_FN:
  817. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  818. return( -1 );
  819. }
  820. (*(IFP *)value) = pblock->pb_plugin->plg_postsearchfail;
  821. break;
  822. case SLAPI_PLUGIN_POST_COMPARE_FN:
  823. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  824. return( -1 );
  825. }
  826. (*(IFP *)value) = pblock->pb_plugin->plg_postcompare;
  827. break;
  828. case SLAPI_PLUGIN_POST_MODIFY_FN:
  829. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  830. return( -1 );
  831. }
  832. (*(IFP *)value) = pblock->pb_plugin->plg_postmodify;
  833. break;
  834. case SLAPI_PLUGIN_POST_MODRDN_FN:
  835. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  836. return( -1 );
  837. }
  838. (*(IFP *)value) = pblock->pb_plugin->plg_postmodrdn;
  839. break;
  840. case SLAPI_PLUGIN_POST_ADD_FN:
  841. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  842. return( -1 );
  843. }
  844. (*(IFP *)value) = pblock->pb_plugin->plg_postadd;
  845. break;
  846. case SLAPI_PLUGIN_POST_DELETE_FN:
  847. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  848. return( -1 );
  849. }
  850. (*(IFP *)value) = pblock->pb_plugin->plg_postdelete;
  851. break;
  852. case SLAPI_PLUGIN_POST_ABANDON_FN:
  853. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  854. return( -1 );
  855. }
  856. (*(IFP *)value) = pblock->pb_plugin->plg_postabandon;
  857. break;
  858. case SLAPI_PLUGIN_POST_ENTRY_FN:
  859. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  860. return( -1 );
  861. }
  862. (*(IFP *)value) = pblock->pb_plugin->plg_postentry;
  863. break;
  864. case SLAPI_PLUGIN_POST_REFERRAL_FN:
  865. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  866. return( -1 );
  867. }
  868. (*(IFP *)value) = pblock->pb_plugin->plg_postreferral;
  869. break;
  870. case SLAPI_PLUGIN_POST_RESULT_FN:
  871. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  872. return( -1 );
  873. }
  874. (*(IFP *)value) = pblock->pb_plugin->plg_postresult;
  875. break;
  876. case SLAPI_ENTRY_PRE_OP:
  877. (*(Slapi_Entry **)value) = pblock->pb_pre_op_entry;
  878. break;
  879. case SLAPI_ENTRY_POST_OP:
  880. (*(Slapi_Entry **)value) = pblock->pb_post_op_entry;
  881. break;
  882. /* backend preoperation plugin */
  883. case SLAPI_PLUGIN_BE_PRE_MODIFY_FN:
  884. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  885. return( -1 );
  886. }
  887. (*(IFP *)value) = pblock->pb_plugin->plg_bepremodify;
  888. break;
  889. case SLAPI_PLUGIN_BE_PRE_MODRDN_FN:
  890. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  891. return( -1 );
  892. }
  893. (*(IFP *)value) = pblock->pb_plugin->plg_bepremodrdn;
  894. break;
  895. case SLAPI_PLUGIN_BE_PRE_ADD_FN:
  896. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  897. return( -1 );
  898. }
  899. (*(IFP *)value) = pblock->pb_plugin->plg_bepreadd;
  900. break;
  901. case SLAPI_PLUGIN_BE_PRE_DELETE_FN:
  902. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  903. return( -1 );
  904. }
  905. (*(IFP *)value) = pblock->pb_plugin->plg_bepredelete;
  906. break;
  907. case SLAPI_PLUGIN_BE_PRE_CLOSE_FN:
  908. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  909. return( -1 );
  910. }
  911. (*(IFP *)value) = pblock->pb_plugin->plg_bepreclose;
  912. break;
  913. case SLAPI_PLUGIN_BE_PRE_BACKUP_FN:
  914. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  915. return( -1 );
  916. }
  917. (*(IFP *)value) = pblock->pb_plugin->plg_beprebackup;
  918. break;
  919. /* backend postoperation plugin */
  920. case SLAPI_PLUGIN_BE_POST_MODIFY_FN:
  921. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  922. return( -1 );
  923. }
  924. (*(IFP *)value) = pblock->pb_plugin->plg_bepostmodify;
  925. break;
  926. case SLAPI_PLUGIN_BE_POST_MODRDN_FN:
  927. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  928. return( -1 );
  929. }
  930. (*(IFP *)value) = pblock->pb_plugin->plg_bepostmodrdn;
  931. break;
  932. case SLAPI_PLUGIN_BE_POST_ADD_FN:
  933. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  934. return( -1 );
  935. }
  936. (*(IFP *)value) = pblock->pb_plugin->plg_bepostadd;
  937. break;
  938. case SLAPI_PLUGIN_BE_POST_DELETE_FN:
  939. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  940. return( -1 );
  941. }
  942. (*(IFP *)value) = pblock->pb_plugin->plg_bepostdelete;
  943. break;
  944. case SLAPI_PLUGIN_BE_POST_OPEN_FN:
  945. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  946. return( -1 );
  947. }
  948. (*(IFP *)value) = pblock->pb_plugin->plg_bepostopen;
  949. break;
  950. case SLAPI_PLUGIN_BE_POST_BACKUP_FN:
  951. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  952. return( -1 );
  953. }
  954. (*(IFP *)value) = pblock->pb_plugin->plg_bepostbackup;
  955. break;
  956. /* internal preoperation plugin */
  957. case SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN:
  958. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) {
  959. return( -1 );
  960. }
  961. (*(IFP *)value) = pblock->pb_plugin->plg_internal_pre_modify;
  962. break;
  963. case SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN:
  964. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) {
  965. return( -1 );
  966. }
  967. (*(IFP *)value) = pblock->pb_plugin->plg_internal_pre_modrdn;
  968. break;
  969. case SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN:
  970. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) {
  971. return( -1 );
  972. }
  973. (*(IFP *)value) = pblock->pb_plugin->plg_internal_pre_add;
  974. break;
  975. case SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN:
  976. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) {
  977. return( -1 );
  978. }
  979. (*(IFP *)value) = pblock->pb_plugin->plg_internal_pre_delete;
  980. break;
  981. /* internal postoperation plugin */
  982. case SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN:
  983. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_POSTOPERATION) {
  984. return( -1 );
  985. }
  986. (*(IFP *)value) = pblock->pb_plugin->plg_internal_post_modify;
  987. break;
  988. case SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN:
  989. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_POSTOPERATION) {
  990. return( -1 );
  991. }
  992. (*(IFP *)value) = pblock->pb_plugin->plg_internal_post_modrdn;
  993. break;
  994. case SLAPI_PLUGIN_INTERNAL_POST_ADD_FN:
  995. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_POSTOPERATION) {
  996. return( -1 );
  997. }
  998. (*(IFP *)value) = pblock->pb_plugin->plg_internal_post_add;
  999. break;
  1000. case SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN:
  1001. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_POSTOPERATION) {
  1002. return( -1 );
  1003. }
  1004. (*(IFP *)value) = pblock->pb_plugin->plg_internal_post_delete;
  1005. break;
  1006. /* rootDN pre bind operation plugin */
  1007. case SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN:
  1008. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) {
  1009. return( -1 );
  1010. }
  1011. (*(IFP *)value) = pblock->pb_plugin->plg_internal_pre_bind;
  1012. break;
  1013. /* backend pre txn operation plugin */
  1014. case SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN:
  1015. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) {
  1016. return( -1 );
  1017. }
  1018. (*(IFP *)value) = pblock->pb_plugin->plg_betxnpremodify;
  1019. break;
  1020. case SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN:
  1021. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) {
  1022. return( -1 );
  1023. }
  1024. (*(IFP *)value) = pblock->pb_plugin->plg_betxnpremodrdn;
  1025. break;
  1026. case SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN:
  1027. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) {
  1028. return( -1 );
  1029. }
  1030. (*(IFP *)value) = pblock->pb_plugin->plg_betxnpreadd;
  1031. break;
  1032. case SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN:
  1033. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) {
  1034. return( -1 );
  1035. }
  1036. (*(IFP *)value) = pblock->pb_plugin->plg_betxnpredelete;
  1037. break;
  1038. case SLAPI_PLUGIN_BE_TXN_PRE_DELETE_TOMBSTONE_FN:
  1039. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) {
  1040. return( -1 );
  1041. }
  1042. (*(IFP *)value) = pblock->pb_plugin->plg_betxnpredeletetombstone;
  1043. break;
  1044. /* backend post txn operation plugin */
  1045. case SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN:
  1046. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPOSTOPERATION) {
  1047. return( -1 );
  1048. }
  1049. (*(IFP *)value) = pblock->pb_plugin->plg_betxnpostmodify;
  1050. break;
  1051. case SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN:
  1052. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPOSTOPERATION) {
  1053. return( -1 );
  1054. }
  1055. (*(IFP *)value) = pblock->pb_plugin->plg_betxnpostmodrdn;
  1056. break;
  1057. case SLAPI_PLUGIN_BE_TXN_POST_ADD_FN:
  1058. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPOSTOPERATION) {
  1059. return( -1 );
  1060. }
  1061. (*(IFP *)value) = pblock->pb_plugin->plg_betxnpostadd;
  1062. break;
  1063. case SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN:
  1064. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPOSTOPERATION) {
  1065. return( -1 );
  1066. }
  1067. (*(IFP *)value) = pblock->pb_plugin->plg_betxnpostdelete;
  1068. break;
  1069. /* target address & controls for all operations should be normalized */
  1070. case SLAPI_TARGET_ADDRESS:
  1071. if(pblock->pb_op!=NULL)
  1072. {
  1073. (*(entry_address **)value) = &(pblock->pb_op->o_params.target_address);
  1074. }
  1075. break;
  1076. case SLAPI_TARGET_DN: /* DEPRECATED */
  1077. /* The returned value refers SLAPI_TARGET_SDN.
  1078. * It should not be freed.*/
  1079. if(pblock->pb_op!=NULL)
  1080. {
  1081. Slapi_DN *sdn = pblock->pb_op->o_params.target_address.sdn;
  1082. if (sdn) {
  1083. (*(char **)value) = (char *)slapi_sdn_get_dn(sdn);
  1084. } else {
  1085. (*(char **)value) = NULL;
  1086. }
  1087. }
  1088. else
  1089. {
  1090. return( -1 );
  1091. }
  1092. break;
  1093. case SLAPI_TARGET_SDN:
  1094. if(pblock->pb_op!=NULL)
  1095. {
  1096. (*(Slapi_DN **)value) = pblock->pb_op->o_params.target_address.sdn;
  1097. }
  1098. else
  1099. {
  1100. return( -1 );
  1101. }
  1102. break;
  1103. case SLAPI_ORIGINAL_TARGET_DN:
  1104. if(pblock->pb_op!=NULL)
  1105. {
  1106. (*(char **)value) = pblock->pb_op->o_params.target_address.udn;
  1107. }
  1108. break;
  1109. case SLAPI_TARGET_UNIQUEID:
  1110. if(pblock->pb_op!=NULL)
  1111. {
  1112. (*(char **)value) = pblock->pb_op->o_params.target_address.uniqueid;
  1113. }
  1114. break;
  1115. case SLAPI_REQCONTROLS:
  1116. if(pblock->pb_op!=NULL)
  1117. {
  1118. (*(LDAPControl ***)value) = pblock->pb_op->o_params.request_controls;
  1119. }
  1120. break;
  1121. case SLAPI_RESCONTROLS:
  1122. if(pblock->pb_op!=NULL)
  1123. {
  1124. (*(LDAPControl ***)value) = pblock->pb_op->o_results.result_controls;
  1125. }
  1126. break;
  1127. case SLAPI_CONTROLS_ARG: /* used to pass control argument before operation is created */
  1128. (*(LDAPControl ***)value) = pblock->pb_ctrls_arg;
  1129. break;
  1130. /* notes to be added to the access log RESULT line for this op. */
  1131. case SLAPI_OPERATION_NOTES:
  1132. (*(unsigned int *)value) = pblock->pb_operation_notes;
  1133. break;
  1134. /* syntax plugin functions */
  1135. case SLAPI_PLUGIN_SYNTAX_FILTER_AVA:
  1136. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1137. return( -1 );
  1138. }
  1139. (*(IFP *)value) = pblock->pb_plugin->plg_syntax_filter_ava;
  1140. break;
  1141. case SLAPI_PLUGIN_SYNTAX_FILTER_SUB:
  1142. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1143. return( -1 );
  1144. }
  1145. (*(IFP *)value) = pblock->pb_plugin->plg_syntax_filter_sub;
  1146. break;
  1147. case SLAPI_PLUGIN_SYNTAX_VALUES2KEYS:
  1148. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1149. return( -1 );
  1150. }
  1151. (*(IFP *)value) = pblock->pb_plugin->plg_syntax_values2keys;
  1152. break;
  1153. case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA:
  1154. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1155. return( -1 );
  1156. }
  1157. (*(IFP *)value) = pblock->pb_plugin->plg_syntax_assertion2keys_ava;
  1158. break;
  1159. case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB:
  1160. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1161. return( -1 );
  1162. }
  1163. (*(IFP *)value) = pblock->pb_plugin->plg_syntax_assertion2keys_sub;
  1164. break;
  1165. case SLAPI_PLUGIN_SYNTAX_NAMES:
  1166. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1167. return( -1 );
  1168. }
  1169. (*(char ***)value) = pblock->pb_plugin->plg_syntax_names;
  1170. break;
  1171. case SLAPI_PLUGIN_SYNTAX_OID:
  1172. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1173. return( -1 );
  1174. }
  1175. (*(char **)value) = pblock->pb_plugin->plg_syntax_oid;
  1176. break;
  1177. case SLAPI_PLUGIN_SYNTAX_FLAGS:
  1178. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1179. return( -1 );
  1180. }
  1181. (*(int *)value) = pblock->pb_plugin->plg_syntax_flags;
  1182. break;
  1183. case SLAPI_PLUGIN_SYNTAX_COMPARE:
  1184. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1185. return( -1 );
  1186. }
  1187. (*(IFP *)value) = pblock->pb_plugin->plg_syntax_compare;
  1188. break;
  1189. case SLAPI_SYNTAX_SUBSTRLENS: /* aka SLAPI_MR_SUBSTRLENS */
  1190. (*(int **)value) = pblock->pb_substrlens;
  1191. break;
  1192. case SLAPI_PLUGIN_SYNTAX_VALIDATE:
  1193. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1194. return( -1 );
  1195. }
  1196. (*(IFP *)value) = pblock->pb_plugin->plg_syntax_validate;
  1197. break;
  1198. case SLAPI_PLUGIN_SYNTAX_NORMALIZE:
  1199. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  1200. return( -1 );
  1201. }
  1202. (*(VFPV *)value) = pblock->pb_plugin->plg_syntax_normalize;
  1203. break;
  1204. /* controls we know about */
  1205. case SLAPI_MANAGEDSAIT:
  1206. (*(int *)value) = pblock->pb_managedsait;
  1207. break;
  1208. case SLAPI_PWPOLICY:
  1209. (*(int *)value) = pblock->pb_pwpolicy_ctrl;
  1210. break;
  1211. /* add arguments */
  1212. case SLAPI_ADD_ENTRY:
  1213. if(pblock->pb_op!=NULL)
  1214. {
  1215. (*(Slapi_Entry **)value) = pblock->pb_op->o_params.p.p_add.target_entry;
  1216. }
  1217. break;
  1218. case SLAPI_ADD_EXISTING_DN_ENTRY:
  1219. (*(Slapi_Entry **)value) = pblock->pb_existing_dn_entry;
  1220. break;
  1221. case SLAPI_ADD_EXISTING_UNIQUEID_ENTRY:
  1222. (*(Slapi_Entry **)value) = pblock->pb_existing_uniqueid_entry;
  1223. break;
  1224. case SLAPI_ADD_PARENT_ENTRY:
  1225. (*(Slapi_Entry **)value) = pblock->pb_parent_entry;
  1226. break;
  1227. case SLAPI_ADD_PARENT_UNIQUEID:
  1228. if(pblock->pb_op!=NULL)
  1229. {
  1230. (*(char **)value) = pblock->pb_op->o_params.p.p_add.parentuniqueid;
  1231. }
  1232. break;
  1233. /* bind arguments */
  1234. case SLAPI_BIND_METHOD:
  1235. if(pblock->pb_op!=NULL)
  1236. {
  1237. (*(ber_tag_t *)value) = pblock->pb_op->o_params.p.p_bind.bind_method;
  1238. }
  1239. break;
  1240. case SLAPI_BIND_CREDENTIALS:
  1241. if(pblock->pb_op!=NULL)
  1242. {
  1243. (*(struct berval **)value) = pblock->pb_op->o_params.p.p_bind.bind_creds;
  1244. }
  1245. break;
  1246. case SLAPI_BIND_SASLMECHANISM:
  1247. if(pblock->pb_op!=NULL)
  1248. {
  1249. (*(char **)value) = pblock->pb_op->o_params.p.p_bind.bind_saslmechanism;
  1250. }
  1251. break;
  1252. /* bind return values */
  1253. case SLAPI_BIND_RET_SASLCREDS:
  1254. if(pblock->pb_op!=NULL)
  1255. {
  1256. (*(struct berval **)value) = pblock->pb_op->o_results.r.r_bind.bind_ret_saslcreds;
  1257. }
  1258. break;
  1259. /* compare arguments */
  1260. case SLAPI_COMPARE_TYPE:
  1261. if(pblock->pb_op!=NULL)
  1262. {
  1263. (*(char **)value) = pblock->pb_op->o_params.p.p_compare.compare_ava.ava_type;
  1264. }
  1265. break;
  1266. case SLAPI_COMPARE_VALUE:
  1267. if(pblock->pb_op!=NULL)
  1268. {
  1269. (*(struct berval **)value) = &pblock->pb_op->o_params.p.p_compare.compare_ava.ava_value;
  1270. }
  1271. break;
  1272. /* modify arguments */
  1273. case SLAPI_MODIFY_MODS:
  1274. PR_ASSERT(pblock->pb_op);
  1275. if(pblock->pb_op!=NULL)
  1276. {
  1277. if(pblock->pb_op->o_params.operation_type==SLAPI_OPERATION_MODIFY)
  1278. {
  1279. (*(LDAPMod ***)value) = pblock->pb_op->o_params.p.p_modify.modify_mods;
  1280. }
  1281. else if(pblock->pb_op->o_params.operation_type==SLAPI_OPERATION_MODRDN)
  1282. {
  1283. (*(LDAPMod ***)value) = pblock->pb_op->o_params.p.p_modrdn.modrdn_mods;
  1284. }
  1285. else
  1286. {
  1287. PR_ASSERT(0); /* JCM */
  1288. }
  1289. }
  1290. break;
  1291. /* modrdn arguments */
  1292. case SLAPI_MODRDN_NEWRDN:
  1293. if(pblock->pb_op!=NULL)
  1294. {
  1295. (*(char **)value) = pblock->pb_op->o_params.p.p_modrdn.modrdn_newrdn;
  1296. }
  1297. break;
  1298. case SLAPI_MODRDN_DELOLDRDN:
  1299. if(pblock->pb_op!=NULL)
  1300. {
  1301. (*(int *)value) = pblock->pb_op->o_params.p.p_modrdn.modrdn_deloldrdn;
  1302. }
  1303. break;
  1304. case SLAPI_MODRDN_NEWSUPERIOR: /* DEPRECATED */
  1305. if(pblock->pb_op!=NULL)
  1306. {
  1307. Slapi_DN *sdn =
  1308. pblock->pb_op->o_params.p.p_modrdn.modrdn_newsuperior_address.sdn;
  1309. if (sdn) {
  1310. (*(char **)value) = (char *)slapi_sdn_get_dn(sdn);
  1311. } else {
  1312. (*(char **)value) = NULL;
  1313. }
  1314. }
  1315. else
  1316. {
  1317. return -1;
  1318. }
  1319. break;
  1320. case SLAPI_MODRDN_NEWSUPERIOR_SDN:
  1321. if(pblock->pb_op!=NULL)
  1322. {
  1323. (*(Slapi_DN **)value) =
  1324. pblock->pb_op->o_params.p.p_modrdn.modrdn_newsuperior_address.sdn;
  1325. }
  1326. else
  1327. {
  1328. return -1;
  1329. }
  1330. break;
  1331. case SLAPI_MODRDN_PARENT_ENTRY:
  1332. (*(Slapi_Entry **)value) = pblock->pb_parent_entry;
  1333. break;
  1334. case SLAPI_MODRDN_NEWPARENT_ENTRY:
  1335. (*(Slapi_Entry **)value) = pblock->pb_newparent_entry;
  1336. break;
  1337. case SLAPI_MODRDN_TARGET_ENTRY:
  1338. (*(Slapi_Entry **)value) = pblock->pb_target_entry;
  1339. break;
  1340. case SLAPI_MODRDN_NEWSUPERIOR_ADDRESS:
  1341. if(pblock->pb_op!=NULL)
  1342. {
  1343. (*(entry_address **)value) = &(pblock->pb_op->o_params.p.p_modrdn.modrdn_newsuperior_address);
  1344. break;
  1345. }
  1346. /* search arguments */
  1347. case SLAPI_SEARCH_SCOPE:
  1348. if(pblock->pb_op!=NULL)
  1349. {
  1350. (*(int *)value) = pblock->pb_op->o_params.p.p_search.search_scope;
  1351. }
  1352. break;
  1353. case SLAPI_SEARCH_DEREF:
  1354. if(pblock->pb_op!=NULL)
  1355. {
  1356. (*(int *)value) = pblock->pb_op->o_params.p.p_search.search_deref;
  1357. }
  1358. break;
  1359. case SLAPI_SEARCH_SIZELIMIT:
  1360. if(pblock->pb_op!=NULL)
  1361. {
  1362. (*(int *)value) = pblock->pb_op->o_params.p.p_search.search_sizelimit;
  1363. }
  1364. break;
  1365. case SLAPI_SEARCH_TIMELIMIT:
  1366. if(pblock->pb_op!=NULL)
  1367. {
  1368. (*(int *)value) = pblock->pb_op->o_params.p.p_search.search_timelimit;
  1369. }
  1370. break;
  1371. case SLAPI_SEARCH_FILTER:
  1372. if(pblock->pb_op!=NULL)
  1373. {
  1374. (*(struct slapi_filter **)value) = pblock->pb_op->o_params.p.p_search.search_filter;
  1375. }
  1376. break;
  1377. case SLAPI_SEARCH_STRFILTER:
  1378. if(pblock->pb_op!=NULL)
  1379. {
  1380. (*(char **)value) = pblock->pb_op->o_params.p.p_search.search_strfilter;
  1381. }
  1382. break;
  1383. case SLAPI_SEARCH_ATTRS:
  1384. if(pblock->pb_op!=NULL)
  1385. {
  1386. (*(char ***)value) = pblock->pb_op->o_params.p.p_search.search_attrs;
  1387. }
  1388. break;
  1389. case SLAPI_SEARCH_GERATTRS:
  1390. if(pblock->pb_op!=NULL)
  1391. {
  1392. (*(char ***)value) = pblock->pb_op->o_params.p.p_search.search_gerattrs;
  1393. }
  1394. break;
  1395. case SLAPI_SEARCH_REQATTRS:
  1396. if(pblock->pb_op!=NULL)
  1397. {
  1398. (*(char ***)value) = pblock->pb_op->o_searchattrs;
  1399. }
  1400. break;
  1401. case SLAPI_SEARCH_ATTRSONLY:
  1402. if(pblock->pb_op!=NULL)
  1403. {
  1404. (*(int *)value) = pblock->pb_op->o_params.p.p_search.search_attrsonly;
  1405. }
  1406. break;
  1407. case SLAPI_SEARCH_IS_AND:
  1408. if(pblock->pb_op!=NULL)
  1409. {
  1410. (*(int *)value) = pblock->pb_op->o_params.p.p_search.search_is_and;
  1411. }
  1412. break;
  1413. case SLAPI_ABANDON_MSGID:
  1414. if(pblock->pb_op!=NULL)
  1415. {
  1416. (*(int *)value) = pblock->pb_op->o_params.p.p_abandon.abandon_targetmsgid;
  1417. }
  1418. break;
  1419. /* extended operation arguments */
  1420. case SLAPI_EXT_OP_REQ_OID:
  1421. if(pblock->pb_op!=NULL)
  1422. {
  1423. (*(char **) value) = pblock->pb_op->o_params.p.p_extended.exop_oid;
  1424. }
  1425. break;
  1426. case SLAPI_EXT_OP_REQ_VALUE:
  1427. if(pblock->pb_op!=NULL)
  1428. {
  1429. (*(struct berval **)value) = pblock->pb_op->o_params.p.p_extended.exop_value;
  1430. }
  1431. break;
  1432. /* extended operation return values */
  1433. case SLAPI_EXT_OP_RET_OID:
  1434. if(pblock->pb_op!=NULL)
  1435. {
  1436. (*(char **) value) = pblock->pb_op->o_results.r.r_extended.exop_ret_oid;
  1437. }
  1438. break;
  1439. case SLAPI_EXT_OP_RET_VALUE:
  1440. if(pblock->pb_op!=NULL)
  1441. {
  1442. (*(struct berval **)value) = pblock->pb_op->o_results.r.r_extended.exop_ret_value;
  1443. }
  1444. break;
  1445. /* matching rule plugin functions */
  1446. case SLAPI_PLUGIN_MR_FILTER_CREATE_FN:
  1447. SLAPI_PLUGIN_TYPE_CHECK (pblock, SLAPI_PLUGIN_MATCHINGRULE);
  1448. (*(IFP *)value) = pblock->pb_plugin->plg_mr_filter_create;
  1449. break;
  1450. case SLAPI_PLUGIN_MR_INDEXER_CREATE_FN:
  1451. SLAPI_PLUGIN_TYPE_CHECK (pblock, SLAPI_PLUGIN_MATCHINGRULE);
  1452. (*(IFP *)value) = pblock->pb_plugin->plg_mr_indexer_create;
  1453. break;
  1454. case SLAPI_PLUGIN_MR_FILTER_MATCH_FN:
  1455. (*(mrFilterMatchFn *)value) = pblock->pb_mr_filter_match_fn;
  1456. break;
  1457. case SLAPI_PLUGIN_MR_FILTER_INDEX_FN:
  1458. (*(IFP *)value) = pblock->pb_mr_filter_index_fn;
  1459. break;
  1460. case SLAPI_PLUGIN_MR_FILTER_RESET_FN:
  1461. (*(IFP *)value) = pblock->pb_mr_filter_reset_fn;
  1462. break;
  1463. case SLAPI_PLUGIN_MR_INDEX_FN:
  1464. (*(IFP *)value) = pblock->pb_mr_index_fn;
  1465. break;
  1466. case SLAPI_PLUGIN_MR_INDEX_SV_FN:
  1467. (*(IFP *)value) = pblock->pb_mr_index_sv_fn;
  1468. break;
  1469. /* matching rule plugin arguments */
  1470. case SLAPI_PLUGIN_MR_OID:
  1471. (*(char **) value) = pblock->pb_mr_oid;
  1472. break;
  1473. case SLAPI_PLUGIN_MR_TYPE:
  1474. (*(char **) value) = pblock->pb_mr_type;
  1475. break;
  1476. case SLAPI_PLUGIN_MR_VALUE:
  1477. (*(struct berval **) value) = pblock->pb_mr_value;
  1478. break;
  1479. case SLAPI_PLUGIN_MR_VALUES:
  1480. (*(struct berval ***) value) = pblock->pb_mr_values;
  1481. break;
  1482. case SLAPI_PLUGIN_MR_KEYS:
  1483. (*(struct berval ***) value) = pblock->pb_mr_keys;
  1484. break;
  1485. case SLAPI_PLUGIN_MR_FILTER_REUSABLE:
  1486. (*(unsigned int *) value) = pblock->pb_mr_filter_reusable;
  1487. break;
  1488. case SLAPI_PLUGIN_MR_QUERY_OPERATOR:
  1489. (*(int *) value) = pblock->pb_mr_query_operator;
  1490. break;
  1491. case SLAPI_PLUGIN_MR_USAGE:
  1492. (*(unsigned int *) value) = pblock->pb_mr_usage;
  1493. break;
  1494. /* new style matching rule syntax plugin functions */
  1495. case SLAPI_PLUGIN_MR_FILTER_AVA:
  1496. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  1497. return( -1 );
  1498. }
  1499. (*(IFP *)value) = pblock->pb_plugin->plg_mr_filter_ava;
  1500. break;
  1501. case SLAPI_PLUGIN_MR_FILTER_SUB:
  1502. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  1503. return( -1 );
  1504. }
  1505. (*(IFP *)value) = pblock->pb_plugin->plg_mr_filter_sub;
  1506. break;
  1507. case SLAPI_PLUGIN_MR_VALUES2KEYS:
  1508. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  1509. return( -1 );
  1510. }
  1511. (*(IFP *)value) = pblock->pb_plugin->plg_mr_values2keys;
  1512. break;
  1513. case SLAPI_PLUGIN_MR_ASSERTION2KEYS_AVA:
  1514. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  1515. return( -1 );
  1516. }
  1517. (*(IFP *)value) = pblock->pb_plugin->plg_mr_assertion2keys_ava;
  1518. break;
  1519. case SLAPI_PLUGIN_MR_ASSERTION2KEYS_SUB:
  1520. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  1521. return( -1 );
  1522. }
  1523. (*(IFP *)value) = pblock->pb_plugin->plg_mr_assertion2keys_sub;
  1524. break;
  1525. case SLAPI_PLUGIN_MR_FLAGS:
  1526. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  1527. return( -1 );
  1528. }
  1529. (*(int *)value) = pblock->pb_plugin->plg_mr_flags;
  1530. break;
  1531. case SLAPI_PLUGIN_MR_NAMES:
  1532. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  1533. return( -1 );
  1534. }
  1535. (*(char ***)value) = pblock->pb_plugin->plg_mr_names;
  1536. break;
  1537. case SLAPI_PLUGIN_MR_COMPARE:
  1538. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  1539. return( -1 );
  1540. }
  1541. (*(IFP *)value) = pblock->pb_plugin->plg_mr_compare;
  1542. break;
  1543. case SLAPI_PLUGIN_MR_NORMALIZE:
  1544. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  1545. return( -1 );
  1546. }
  1547. (*(VFPV *)value) = pblock->pb_plugin->plg_mr_normalize;
  1548. break;
  1549. /* seq arguments */
  1550. case SLAPI_SEQ_TYPE:
  1551. (*(int *)value) = pblock->pb_seq_type;
  1552. break;
  1553. case SLAPI_SEQ_ATTRNAME:
  1554. (*(char **)value) = pblock->pb_seq_attrname;
  1555. break;
  1556. case SLAPI_SEQ_VAL:
  1557. (*(char **)value) = pblock->pb_seq_val;
  1558. break;
  1559. /* ldif2db arguments */
  1560. case SLAPI_LDIF2DB_FILE:
  1561. (*(char ***)value) = pblock->pb_ldif_files;
  1562. break;
  1563. case SLAPI_LDIF2DB_REMOVEDUPVALS:
  1564. (*(int *)value) = pblock->pb_removedupvals;
  1565. break;
  1566. case SLAPI_DB2INDEX_ATTRS:
  1567. (*(char ***)value) = pblock->pb_db2index_attrs;
  1568. break;
  1569. case SLAPI_LDIF2DB_NOATTRINDEXES:
  1570. (*(int *)value) = pblock->pb_ldif2db_noattrindexes;
  1571. break;
  1572. case SLAPI_LDIF2DB_INCLUDE:
  1573. (*(char ***)value) = pblock->pb_ldif_include;
  1574. break;
  1575. case SLAPI_LDIF2DB_EXCLUDE:
  1576. (*(char ***)value) = pblock->pb_ldif_exclude;
  1577. break;
  1578. case SLAPI_LDIF2DB_GENERATE_UNIQUEID:
  1579. (*(int *)value) = pblock->pb_ldif_generate_uniqueid;
  1580. break;
  1581. case SLAPI_LDIF2DB_ENCRYPT:
  1582. case SLAPI_DB2LDIF_DECRYPT:
  1583. (*(int *)value) = pblock->pb_ldif_encrypt;
  1584. break;
  1585. case SLAPI_LDIF2DB_NAMESPACEID:
  1586. (*(char **)value) = pblock->pb_ldif_namespaceid;
  1587. break;
  1588. /* db2ldif arguments */
  1589. case SLAPI_DB2LDIF_PRINTKEY:
  1590. (*(int *)value) = pblock->pb_ldif_printkey;
  1591. break;
  1592. case SLAPI_DB2LDIF_DUMP_UNIQUEID:
  1593. (*(int *)value) = pblock->pb_ldif_dump_uniqueid;
  1594. break;
  1595. case SLAPI_DB2LDIF_FILE:
  1596. (*(char **)value) = pblock->pb_ldif_file;
  1597. break;
  1598. /* db2ldif/ldif2db/db2bak/bak2db arguments */
  1599. case SLAPI_BACKEND_INSTANCE_NAME:
  1600. (*(char **)value) = pblock->pb_instance_name;
  1601. break;
  1602. case SLAPI_BACKEND_TASK:
  1603. (*(Slapi_Task **)value) = pblock->pb_task;
  1604. break;
  1605. case SLAPI_TASK_FLAGS:
  1606. (*(int *)value) = pblock->pb_task_flags;
  1607. break;
  1608. case SLAPI_DB2LDIF_SERVER_RUNNING:
  1609. (*(int *)value) = pblock->pb_server_running;
  1610. break;
  1611. case SLAPI_BULK_IMPORT_ENTRY:
  1612. (*(Slapi_Entry **)value) = pblock->pb_import_entry;
  1613. break;
  1614. case SLAPI_BULK_IMPORT_STATE:
  1615. (*(int *)value) = pblock->pb_import_state;
  1616. break;
  1617. /* transaction arguments */
  1618. case SLAPI_PARENT_TXN:
  1619. (*(void **)value) = pblock->pb_parent_txn;
  1620. break;
  1621. case SLAPI_TXN:
  1622. (*(void **)value) = pblock->pb_txn;
  1623. break;
  1624. case SLAPI_TXN_RUV_MODS_FN:
  1625. (*(IFP*)value) = pblock->pb_txn_ruv_mods_fn;
  1626. break;
  1627. /* dbverify */
  1628. case SLAPI_DBVERIFY_DBDIR:
  1629. (*(char **)value) = pblock->pb_dbverify_dbdir;
  1630. break;
  1631. /* Search results set */
  1632. case SLAPI_SEARCH_RESULT_SET:
  1633. if(pblock->pb_op!=NULL)
  1634. {
  1635. (*(void **)value) = pblock->pb_op->o_results.r.r_search.search_result_set;
  1636. }
  1637. break;
  1638. /* estimated search result set size */
  1639. case SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE:
  1640. if(pblock->pb_op!=NULL)
  1641. {
  1642. (*(int *)value) = pblock->pb_op->o_results.r.r_search.estimate;
  1643. }
  1644. break;
  1645. /* Entry returned from iterating over results set */
  1646. case SLAPI_SEARCH_RESULT_ENTRY:
  1647. if(pblock->pb_op!=NULL)
  1648. {
  1649. (*(void **)value) = pblock->pb_op->o_results.r.r_search.search_result_entry;
  1650. }
  1651. break;
  1652. case SLAPI_SEARCH_RESULT_ENTRY_EXT:
  1653. if(pblock->pb_op!=NULL)
  1654. {
  1655. (*(void **)value) = pblock->pb_op->o_results.r.r_search.opaque_backend_ptr;
  1656. }
  1657. break;
  1658. /* Number of entries returned from search */
  1659. case SLAPI_NENTRIES:
  1660. if(pblock->pb_op!=NULL)
  1661. {
  1662. (*(int *)value) = pblock->pb_op->o_results.r.r_search.nentries;
  1663. }
  1664. break;
  1665. /* Referrals encountered while iterating over result set */
  1666. case SLAPI_SEARCH_REFERRALS:
  1667. if(pblock->pb_op!=NULL)
  1668. {
  1669. (*(struct berval ***)value) = pblock->pb_op->o_results.r.r_search.search_referrals;
  1670. }
  1671. break;
  1672. case SLAPI_RESULT_CODE:
  1673. if (pblock->pb_op != NULL)
  1674. * ((int *) value) = pblock->pb_op->o_results.result_code;
  1675. break;
  1676. case SLAPI_RESULT_MATCHED:
  1677. if (pblock->pb_op != NULL)
  1678. * ((char **) value) = pblock->pb_op->o_results.result_matched;
  1679. break;
  1680. case SLAPI_RESULT_TEXT:
  1681. if (pblock->pb_op != NULL)
  1682. * ((char **) value) = pblock->pb_op->o_results.result_text;
  1683. break;
  1684. case SLAPI_PB_RESULT_TEXT:
  1685. * ((char **) value) = pblock->pb_result_text;
  1686. break;
  1687. /* Size of the database, in kb */
  1688. case SLAPI_DBSIZE:
  1689. (*(unsigned int *)value) = pblock->pb_dbsize;
  1690. break;
  1691. /* ACL Plugin */
  1692. case SLAPI_PLUGIN_ACL_INIT:
  1693. (*(IFP *)value) = pblock->pb_plugin->plg_acl_init;
  1694. break;
  1695. case SLAPI_PLUGIN_ACL_SYNTAX_CHECK:
  1696. (*(IFP *)value) = pblock->pb_plugin->plg_acl_syntax_check;
  1697. break;
  1698. case SLAPI_PLUGIN_ACL_ALLOW_ACCESS:
  1699. (*(IFP *)value) = pblock->pb_plugin->plg_acl_access_allowed;
  1700. break;
  1701. case SLAPI_PLUGIN_ACL_MODS_ALLOWED:
  1702. (*(IFP *)value) = pblock->pb_plugin->plg_acl_mods_allowed;
  1703. break;
  1704. case SLAPI_PLUGIN_ACL_MODS_UPDATE:
  1705. (*(IFP *)value) = pblock->pb_plugin->plg_acl_mods_update;
  1706. break;
  1707. case SLAPI_REQUESTOR_DN:
  1708. /* NOTE: It's not a copy of the DN */
  1709. if (pblock->pb_op != NULL)
  1710. {
  1711. char *dn= (char*)slapi_sdn_get_dn(&pblock->pb_op->o_sdn);
  1712. if(dn==NULL)
  1713. (*( char **)value ) = "";
  1714. else
  1715. (*( char **)value ) = dn;
  1716. }
  1717. break;
  1718. case SLAPI_REQUESTOR_SDN:
  1719. if(pblock->pb_op != NULL){
  1720. (*(Slapi_DN **)value) = &pblock->pb_op->o_sdn;
  1721. }
  1722. break;
  1723. case SLAPI_REQUESTOR_NDN:
  1724. /* NOTE: It's not a copy of the DN */
  1725. if (pblock->pb_op != NULL)
  1726. {
  1727. char *ndn = (char*)slapi_sdn_get_ndn(&pblock->pb_op->o_sdn);
  1728. if(ndn == NULL)
  1729. (*( char **)value ) = "";
  1730. else
  1731. (*( char **)value ) = ndn;
  1732. }
  1733. break;
  1734. case SLAPI_OPERATION_AUTHTYPE:
  1735. if (pblock->pb_op != NULL)
  1736. {
  1737. if(pblock->pb_op->o_authtype==NULL)
  1738. (*( char **)value ) = "";
  1739. else
  1740. (*( char **)value ) = pblock->pb_op->o_authtype;
  1741. }
  1742. break;
  1743. case SLAPI_OPERATION_SSF:
  1744. if (pblock->pb_op!=NULL) {
  1745. * ((int *) value) = pblock->pb_op->o_ssf;
  1746. }
  1747. break;
  1748. case SLAPI_CLIENT_DNS:
  1749. if (pblock->pb_conn == NULL) {
  1750. LDAPDebug( LDAP_DEBUG_ANY,
  1751. "Connection is NULL and hence cannot access SLAPI_CLIENT_DNS \n", 0, 0, 0 );
  1752. return (-1);
  1753. }
  1754. (*(struct berval ***)value ) = pblock->pb_conn->c_domain;
  1755. break;
  1756. case SLAPI_BE_MAXNESTLEVEL:
  1757. if ( NULL == be ) {
  1758. return( -1 );
  1759. }
  1760. (*(int *)value ) = be->be_maxnestlevel;
  1761. break;
  1762. case SLAPI_OPERATION_ID:
  1763. if (pblock->pb_op != NULL) {
  1764. (*(int *)value ) = pblock->pb_op->o_opid;
  1765. }
  1766. break;
  1767. /* Command line arguments */
  1768. case SLAPI_ARGC:
  1769. (*(int *)value) = pblock->pb_slapd_argc;
  1770. break;
  1771. case SLAPI_ARGV:
  1772. (*(char ***)value) = pblock->pb_slapd_argv;
  1773. break;
  1774. /* Config file directory */
  1775. case SLAPI_CONFIG_DIRECTORY:
  1776. (*(char **)value) = pblock->pb_slapd_configdir;
  1777. break;
  1778. /* password storage scheme (kexcoff */
  1779. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME:
  1780. (*(char **)value) = pblock->pb_plugin->plg_pwdstorageschemename;
  1781. break;
  1782. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_USER_PWD:
  1783. (*(char **)value) = pblock->pb_pwd_storage_scheme_user_passwd;
  1784. break;
  1785. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DB_PWD:
  1786. (*(char **)value) = pblock->pb_pwd_storage_scheme_db_passwd;
  1787. break;
  1788. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN:
  1789. (*(CFP *)value) = pblock->pb_plugin->plg_pwdstorageschemeenc;
  1790. break;
  1791. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DEC_FN:
  1792. (*(IFP *)value) = pblock->pb_plugin->plg_pwdstorageschemedec;
  1793. break;
  1794. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN:
  1795. (*(IFP *)value) = pblock->pb_plugin->plg_pwdstorageschemecmp;
  1796. break;
  1797. /* entry fetch/store plugin */
  1798. case SLAPI_PLUGIN_ENTRY_FETCH_FUNC:
  1799. (*(IFP *)value) = pblock->pb_plugin->plg_entryfetchfunc;
  1800. break;
  1801. case SLAPI_PLUGIN_ENTRY_STORE_FUNC:
  1802. (*(IFP *)value) = pblock->pb_plugin->plg_entrystorefunc;
  1803. break;
  1804. case SLAPI_PLUGIN_ENABLED:
  1805. *((int *)value) = pblock->pb_plugin_enabled;
  1806. break;
  1807. /* DSE add parameters */
  1808. case SLAPI_DSE_DONT_WRITE_WHEN_ADDING:
  1809. (*(int *)value) = pblock->pb_dse_dont_add_write;
  1810. break;
  1811. /* DSE add parameters */
  1812. case SLAPI_DSE_MERGE_WHEN_ADDING:
  1813. (*(int *)value) = pblock->pb_dse_add_merge;
  1814. break;
  1815. /* DSE add parameters */
  1816. case SLAPI_DSE_DONT_CHECK_DUPS:
  1817. (*(int *)value) = pblock->pb_dse_dont_check_dups;
  1818. break;
  1819. /* DSE modify parameters */
  1820. case SLAPI_DSE_REAPPLY_MODS:
  1821. (*(int *)value) = pblock->pb_dse_reapply_mods;
  1822. break;
  1823. /* DSE read parameters */
  1824. case SLAPI_DSE_IS_PRIMARY_FILE:
  1825. (*(int *)value) = pblock->pb_dse_is_primary_file;
  1826. break;
  1827. /* used internally by schema code (schema.c) */
  1828. case SLAPI_SCHEMA_FLAGS:
  1829. (*(int *)value) = pblock->pb_schema_flags;
  1830. break;
  1831. case SLAPI_URP_NAMING_COLLISION_DN:
  1832. (*(char **)value) = pblock->pb_urp_naming_collision_dn;
  1833. break;
  1834. case SLAPI_URP_TOMBSTONE_UNIQUEID:
  1835. (*(char **)value) = pblock->pb_urp_tombstone_uniqueid;
  1836. break;
  1837. case SLAPI_SEARCH_CTRLS:
  1838. (*(LDAPControl ***)value) = pblock->pb_search_ctrls;
  1839. break;
  1840. case SLAPI_PLUGIN_SYNTAX_FILTER_NORMALIZED:
  1841. (*(int *)value) = pblock->pb_syntax_filter_normalized;
  1842. break;
  1843. case SLAPI_PLUGIN_SYNTAX_FILTER_DATA:
  1844. (*(void **)value) = pblock->pb_syntax_filter_data;
  1845. break;
  1846. case SLAPI_PAGED_RESULTS_INDEX:
  1847. if (op_is_pagedresults(pblock->pb_op)) {
  1848. /* search req is simple paged results */
  1849. (*(int *)value) = pblock->pb_paged_results_index;
  1850. } else {
  1851. (*(int *)value) = -1;
  1852. }
  1853. break;
  1854. /* ACI Target Check */
  1855. case SLAPI_ACI_TARGET_CHECK:
  1856. (*(int *)value) = pblock->pb_aci_target_check;
  1857. break;
  1858. default:
  1859. LDAPDebug( LDAP_DEBUG_ANY,
  1860. "Unknown parameter block argument %d\n", arg, 0, 0 );
  1861. return( -1 );
  1862. }
  1863. return( 0 );
  1864. }
  1865. int
  1866. slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value )
  1867. {
  1868. char *authtype;
  1869. PR_ASSERT( NULL != pblock );
  1870. switch ( arg ) {
  1871. case SLAPI_BACKEND:
  1872. pblock->pb_backend = (Slapi_Backend *) value;
  1873. if (pblock->pb_backend && (NULL == pblock->pb_plugin)) {
  1874. /* newly allocated pblock may not have backend plugin set. */
  1875. pblock->pb_plugin =
  1876. (struct slapdplugin *)pblock->pb_backend->be_database;
  1877. }
  1878. break;
  1879. case SLAPI_BACKEND_COUNT:
  1880. pblock->pb_backend_count = *((int *) value);
  1881. break;
  1882. case SLAPI_CONNECTION:
  1883. pblock->pb_conn = (Connection *) value;
  1884. break;
  1885. case SLAPI_OPERATION:
  1886. pblock->pb_op = (Operation *) value;
  1887. break;
  1888. case SLAPI_OPINITIATED_TIME:
  1889. if (pblock->pb_op != NULL) {
  1890. pblock->pb_op->o_time = *((time_t *) value);
  1891. }
  1892. break;
  1893. case SLAPI_REQUESTOR_ISROOT:
  1894. pblock->pb_requestor_isroot = *((int *) value);
  1895. break;
  1896. case SLAPI_IS_REPLICATED_OPERATION:
  1897. PR_ASSERT(0);
  1898. break;
  1899. case SLAPI_OPERATION_PARAMETERS:
  1900. PR_ASSERT(0);
  1901. break;
  1902. case SLAPI_CONN_ID:
  1903. if (pblock->pb_conn == NULL) {
  1904. LDAPDebug( LDAP_DEBUG_ANY,
  1905. "Connection is NULL and hence cannot access SLAPI_CONN_ID \n", 0, 0, 0 );
  1906. return (-1);
  1907. }
  1908. pblock->pb_conn->c_connid = *((PRUint64 *) value);
  1909. break;
  1910. case SLAPI_CONN_DN:
  1911. /*
  1912. * Slightly crazy but we must pass a copy of the current
  1913. * authtype into bind_credentials_set() since it will
  1914. * free the current authtype.
  1915. */
  1916. if (pblock->pb_conn == NULL) {
  1917. LDAPDebug( LDAP_DEBUG_ANY,
  1918. "Connection is NULL and hence cannot access SLAPI_CONN_DN \n", 0, 0, 0 );
  1919. return (-1);
  1920. }
  1921. slapi_pblock_get(pblock, SLAPI_CONN_AUTHMETHOD, &authtype);
  1922. bind_credentials_set( pblock->pb_conn, authtype,
  1923. (char *)value, NULL, NULL, NULL , NULL);
  1924. slapi_ch_free((void**)&authtype);
  1925. break;
  1926. case SLAPI_CONN_AUTHTYPE: /* deprecated */
  1927. case SLAPI_CONN_AUTHMETHOD:
  1928. if (pblock->pb_conn == NULL) {
  1929. LDAPDebug( LDAP_DEBUG_ANY,
  1930. "Connection is NULL and hence cannot access SLAPI_CONN_AUTHMETHOD \n", 0, 0, 0 );
  1931. return (-1);
  1932. }
  1933. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  1934. slapi_ch_free((void**)&pblock->pb_conn->c_authtype);
  1935. pblock->pb_conn->c_authtype = slapi_ch_strdup((char *) value);
  1936. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  1937. break;
  1938. case SLAPI_CONN_IS_REPLICATION_SESSION:
  1939. if (pblock->pb_conn == NULL) {
  1940. LDAPDebug( LDAP_DEBUG_ANY,
  1941. "Connection is NULL and hence cannot access SLAPI_CONN_IS_REPLICATION_SESSION \n", 0, 0, 0 );
  1942. return (-1);
  1943. }
  1944. PR_EnterMonitor(pblock->pb_conn->c_mutex);
  1945. pblock->pb_conn->c_isreplication_session = *((int *) value);
  1946. PR_ExitMonitor(pblock->pb_conn->c_mutex);
  1947. break;
  1948. /* stuff related to config file processing */
  1949. case SLAPI_CONFIG_FILENAME:
  1950. case SLAPI_CONFIG_LINENO:
  1951. case SLAPI_CONFIG_ARGC:
  1952. case SLAPI_CONFIG_ARGV:
  1953. return (-1); /* deprecated since DS 5.0 (no longer useful) */
  1954. /* pblock memory management */
  1955. case SLAPI_DESTROY_CONTENT:
  1956. pblock->pb_destroy_content = *((int *) value);
  1957. break;
  1958. /* stuff related to the current plugin */
  1959. case SLAPI_PLUGIN:
  1960. pblock->pb_plugin = (struct slapdplugin *) value;
  1961. break;
  1962. case SLAPI_PLUGIN_PRIVATE:
  1963. pblock->pb_plugin->plg_private = (void *) value;
  1964. break;
  1965. case SLAPI_PLUGIN_TYPE:
  1966. pblock->pb_plugin->plg_type = *((int *) value);
  1967. break;
  1968. case SLAPI_PLUGIN_ARGV:
  1969. pblock->pb_plugin->plg_argv = (char **) value;
  1970. break;
  1971. case SLAPI_PLUGIN_ARGC:
  1972. pblock->pb_plugin->plg_argc = *((int *) value);
  1973. break;
  1974. case SLAPI_PLUGIN_VERSION:
  1975. pblock->pb_plugin->plg_version = (char *) value;
  1976. break;
  1977. case SLAPI_PLUGIN_PRECEDENCE:
  1978. pblock->pb_plugin->plg_precedence = *((int *) value);
  1979. break;
  1980. case SLAPI_PLUGIN_OPRETURN:
  1981. pblock->pb_opreturn = *((int *) value);
  1982. break;
  1983. case SLAPI_PLUGIN_OBJECT:
  1984. pblock->pb_object = (void *) value;
  1985. break;
  1986. case SLAPI_PLUGIN_IDENTITY:
  1987. pblock->pb_plugin_identity = (void*)value;
  1988. break;
  1989. case SLAPI_PLUGIN_CONFIG_AREA:
  1990. pblock->pb_plugin_config_area = (char *) value;
  1991. break;
  1992. case SLAPI_PLUGIN_DESTROY_FN:
  1993. pblock->pb_destroy_fn = (IFP) value;
  1994. break;
  1995. case SLAPI_PLUGIN_DESCRIPTION:
  1996. pblock->pb_plugin->plg_desc = *((Slapi_PluginDesc *)value);
  1997. break;
  1998. case SLAPI_PLUGIN_INTOP_RESULT:
  1999. pblock->pb_internal_op_result = *((int *) value);
  2000. break;
  2001. case SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES:
  2002. pblock->pb_plugin_internal_search_op_entries = (Slapi_Entry **) value;
  2003. break;
  2004. case SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS:
  2005. pblock->pb_plugin_internal_search_op_referrals = (char **) value;
  2006. break;
  2007. case SLAPI_REQUESTOR_DN:
  2008. if(pblock->pb_op == NULL){
  2009. return (-1);
  2010. }
  2011. slapi_sdn_set_dn_byval((&pblock->pb_op->o_sdn),(char *)value);
  2012. break;
  2013. case SLAPI_REQUESTOR_SDN:
  2014. if(pblock->pb_op == NULL){
  2015. return (-1);
  2016. }
  2017. slapi_sdn_set_dn_byval((&pblock->pb_op->o_sdn),slapi_sdn_get_dn((Slapi_DN *)value));
  2018. break;
  2019. /* database plugin functions */
  2020. case SLAPI_PLUGIN_DB_BIND_FN:
  2021. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2022. return( -1 );
  2023. }
  2024. pblock->pb_plugin->plg_bind = (IFP) value;
  2025. break;
  2026. case SLAPI_PLUGIN_DB_UNBIND_FN:
  2027. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2028. return( -1 );
  2029. }
  2030. pblock->pb_plugin->plg_unbind = (IFP) value;
  2031. break;
  2032. case SLAPI_PLUGIN_DB_SEARCH_FN:
  2033. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2034. return( -1 );
  2035. }
  2036. pblock->pb_plugin->plg_search = (IFP) value;
  2037. break;
  2038. case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN:
  2039. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2040. return( -1 );
  2041. }
  2042. pblock->pb_plugin->plg_next_search_entry = (IFP) value;
  2043. break;
  2044. case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN:
  2045. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2046. return( -1 );
  2047. }
  2048. pblock->pb_plugin->plg_next_search_entry_ext = (IFP) value;
  2049. break;
  2050. case SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN:
  2051. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2052. return( -1 );
  2053. }
  2054. pblock->pb_plugin->plg_entry_release = (IFP) value;
  2055. break;
  2056. case SLAPI_PLUGIN_DB_SEARCH_RESULTS_RELEASE_FN:
  2057. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2058. return( -1 );
  2059. }
  2060. pblock->pb_plugin->plg_search_results_release = (VFPP) value;
  2061. break;
  2062. case SLAPI_PLUGIN_DB_PREV_SEARCH_RESULTS_FN:
  2063. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2064. return( -1 );
  2065. }
  2066. pblock->pb_plugin->plg_prev_search_results = (VFP) value;
  2067. break;
  2068. case SLAPI_PLUGIN_DB_COMPARE_FN:
  2069. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2070. return( -1 );
  2071. }
  2072. pblock->pb_plugin->plg_compare = (IFP) value;
  2073. break;
  2074. case SLAPI_PLUGIN_DB_MODIFY_FN:
  2075. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2076. return( -1 );
  2077. }
  2078. pblock->pb_plugin->plg_modify = (IFP) value;
  2079. break;
  2080. case SLAPI_PLUGIN_DB_MODRDN_FN:
  2081. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2082. return( -1 );
  2083. }
  2084. pblock->pb_plugin->plg_modrdn = (IFP) value;
  2085. break;
  2086. case SLAPI_PLUGIN_DB_ADD_FN:
  2087. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2088. return( -1 );
  2089. }
  2090. pblock->pb_plugin->plg_add = (IFP) value;
  2091. break;
  2092. case SLAPI_PLUGIN_DB_DELETE_FN:
  2093. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2094. return( -1 );
  2095. }
  2096. pblock->pb_plugin->plg_delete = (IFP) value;
  2097. break;
  2098. case SLAPI_PLUGIN_DB_ABANDON_FN:
  2099. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2100. return( -1 );
  2101. }
  2102. pblock->pb_plugin->plg_abandon = (IFP) value;
  2103. break;
  2104. case SLAPI_PLUGIN_DB_CONFIG_FN:
  2105. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2106. return( -1 );
  2107. }
  2108. pblock->pb_plugin->plg_config = (IFP) value;
  2109. break;
  2110. case SLAPI_PLUGIN_CLOSE_FN:
  2111. pblock->pb_plugin->plg_close = (IFP) value;
  2112. break;
  2113. case SLAPI_PLUGIN_CLEANUP_FN:
  2114. pblock->pb_plugin->plg_cleanup = (IFP) value;
  2115. break;
  2116. case SLAPI_PLUGIN_DB_FLUSH_FN:
  2117. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2118. return( -1 );
  2119. }
  2120. pblock->pb_plugin->plg_flush = (IFP) value;
  2121. break;
  2122. case SLAPI_PLUGIN_START_FN:
  2123. pblock->pb_plugin->plg_start = (IFP) value;
  2124. break;
  2125. case SLAPI_PLUGIN_POSTSTART_FN:
  2126. pblock->pb_plugin->plg_poststart = (IFP) value;
  2127. break;
  2128. case SLAPI_PLUGIN_DB_WIRE_IMPORT_FN:
  2129. pblock->pb_plugin->plg_wire_import = (IFP) value;
  2130. break;
  2131. case SLAPI_PLUGIN_DB_ADD_SCHEMA_FN:
  2132. pblock->pb_plugin->plg_add_schema = (IFP) value;
  2133. break;
  2134. case SLAPI_PLUGIN_DB_GET_INFO_FN:
  2135. pblock->pb_plugin->plg_get_info = (IFP) value;
  2136. break;
  2137. case SLAPI_PLUGIN_DB_SET_INFO_FN:
  2138. pblock->pb_plugin->plg_set_info = (IFP) value;
  2139. break;
  2140. case SLAPI_PLUGIN_DB_CTRL_INFO_FN:
  2141. pblock->pb_plugin->plg_ctrl_info = (IFP) value;
  2142. break;
  2143. case SLAPI_PLUGIN_DB_SEQ_FN:
  2144. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2145. return( -1 );
  2146. }
  2147. pblock->pb_plugin->plg_seq = (IFP) value;
  2148. break;
  2149. case SLAPI_PLUGIN_DB_ENTRY_FN:
  2150. pblock->pb_plugin->plg_entry = (IFP) value;
  2151. break;
  2152. case SLAPI_PLUGIN_DB_REFERRAL_FN:
  2153. pblock->pb_plugin->plg_referral = (IFP) value;
  2154. break;
  2155. case SLAPI_PLUGIN_DB_RESULT_FN:
  2156. pblock->pb_plugin->plg_result = (IFP) value;
  2157. break;
  2158. case SLAPI_PLUGIN_DB_RMDB_FN:
  2159. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2160. return( -1 );
  2161. }
  2162. pblock->pb_plugin->plg_rmdb = (IFP) value;
  2163. break;
  2164. case SLAPI_PLUGIN_DB_INIT_INSTANCE_FN:
  2165. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2166. return( -1 );
  2167. }
  2168. pblock->pb_plugin->plg_init_instance = (IFP) value;
  2169. break;
  2170. case SLAPI_PLUGIN_DB_LDIF2DB_FN:
  2171. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2172. return( -1 );
  2173. }
  2174. pblock->pb_plugin->plg_ldif2db = (IFP) value;
  2175. break;
  2176. case SLAPI_PLUGIN_DB_DB2LDIF_FN:
  2177. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2178. return( -1 );
  2179. }
  2180. pblock->pb_plugin->plg_db2ldif = (IFP) value;
  2181. break;
  2182. case SLAPI_PLUGIN_DB_DB2INDEX_FN:
  2183. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2184. return( -1 );
  2185. }
  2186. pblock->pb_plugin->plg_db2index = (IFP) value;
  2187. break;
  2188. case SLAPI_PLUGIN_DB_ARCHIVE2DB_FN:
  2189. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2190. return( -1 );
  2191. }
  2192. pblock->pb_plugin->plg_archive2db = (IFP) value;
  2193. break;
  2194. case SLAPI_PLUGIN_DB_DB2ARCHIVE_FN:
  2195. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2196. return( -1 );
  2197. }
  2198. pblock->pb_plugin->plg_db2archive = (IFP) value;
  2199. break;
  2200. case SLAPI_PLUGIN_DB_UPGRADEDB_FN:
  2201. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2202. return( -1 );
  2203. }
  2204. pblock->pb_plugin->plg_upgradedb = (IFP) value;
  2205. break;
  2206. case SLAPI_PLUGIN_DB_UPGRADEDNFORMAT_FN:
  2207. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2208. return( -1 );
  2209. }
  2210. pblock->pb_plugin->plg_upgradednformat = (IFP) value;
  2211. break;
  2212. case SLAPI_PLUGIN_DB_DBVERIFY_FN:
  2213. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2214. return( -1 );
  2215. }
  2216. pblock->pb_plugin->plg_dbverify = (IFP) value;
  2217. break;
  2218. case SLAPI_PLUGIN_DB_BEGIN_FN:
  2219. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2220. return( -1 );
  2221. }
  2222. pblock->pb_plugin->plg_un.plg_un_db.plg_un_db_begin = (IFP) value;
  2223. break;
  2224. case SLAPI_PLUGIN_DB_COMMIT_FN:
  2225. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2226. return( -1 );
  2227. }
  2228. pblock->pb_plugin->plg_un.plg_un_db.plg_un_db_commit = (IFP) value;
  2229. break;
  2230. case SLAPI_PLUGIN_DB_ABORT_FN:
  2231. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2232. return( -1 );
  2233. }
  2234. pblock->pb_plugin->plg_un.plg_un_db.plg_un_db_abort = (IFP) value;
  2235. break;
  2236. case SLAPI_PLUGIN_DB_SIZE_FN:
  2237. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2238. return( -1 );
  2239. }
  2240. pblock->pb_plugin->plg_un.plg_un_db.plg_un_db_dbsize = (IFP) value;
  2241. break;
  2242. case SLAPI_PLUGIN_DB_TEST_FN:
  2243. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2244. return( -1 );
  2245. }
  2246. pblock->pb_plugin->plg_un.plg_un_db.plg_un_db_dbtest = (IFP) value;
  2247. break;
  2248. /* database plugin-specific parameters */
  2249. case SLAPI_PLUGIN_DB_NO_ACL:
  2250. if ( pblock->pb_plugin && pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
  2251. return( -1 );
  2252. }
  2253. if ( NULL == pblock->pb_backend ) {
  2254. return( -1 );
  2255. }
  2256. pblock->pb_backend->be_noacl = *((int *)value);
  2257. break;
  2258. /* extendedop plugin functions */
  2259. case SLAPI_PLUGIN_EXT_OP_FN:
  2260. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_EXTENDEDOP &&
  2261. pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP ) {
  2262. return( -1 );
  2263. }
  2264. pblock->pb_plugin->plg_exhandler = (IFP) value;
  2265. break;
  2266. case SLAPI_PLUGIN_EXT_OP_OIDLIST:
  2267. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_EXTENDEDOP &&
  2268. pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP ) {
  2269. return( -1 );
  2270. }
  2271. pblock->pb_plugin->plg_exoids = (char **) value;
  2272. ldapi_register_extended_op( (char **)value );
  2273. break;
  2274. case SLAPI_PLUGIN_EXT_OP_NAMELIST:
  2275. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_EXTENDEDOP &&
  2276. pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP ) {
  2277. return( -1 );
  2278. }
  2279. pblock->pb_plugin->plg_exnames = (char **) value;
  2280. break;
  2281. case SLAPI_PLUGIN_EXT_OP_BACKEND_FN:
  2282. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_EXTENDEDOP &&
  2283. pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNEXTENDEDOP ) {
  2284. return( -1 );
  2285. }
  2286. pblock->pb_plugin->plg_be_exhandler = (IFP) value;
  2287. break;
  2288. /* preoperation plugin functions */
  2289. case SLAPI_PLUGIN_PRE_BIND_FN:
  2290. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2291. return( -1 );
  2292. }
  2293. pblock->pb_plugin->plg_prebind = (IFP) value;
  2294. break;
  2295. case SLAPI_PLUGIN_PRE_UNBIND_FN:
  2296. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2297. return( -1 );
  2298. }
  2299. pblock->pb_plugin->plg_preunbind = (IFP) value;
  2300. break;
  2301. case SLAPI_PLUGIN_PRE_SEARCH_FN:
  2302. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2303. return( -1 );
  2304. }
  2305. pblock->pb_plugin->plg_presearch = (IFP) value;
  2306. break;
  2307. case SLAPI_PLUGIN_PRE_COMPARE_FN:
  2308. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2309. return( -1 );
  2310. }
  2311. pblock->pb_plugin->plg_precompare = (IFP) value;
  2312. break;
  2313. case SLAPI_PLUGIN_PRE_MODIFY_FN:
  2314. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2315. return( -1 );
  2316. }
  2317. pblock->pb_plugin->plg_premodify = (IFP) value;
  2318. break;
  2319. case SLAPI_PLUGIN_PRE_MODRDN_FN:
  2320. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2321. return( -1 );
  2322. }
  2323. pblock->pb_plugin->plg_premodrdn = (IFP) value;
  2324. break;
  2325. case SLAPI_PLUGIN_PRE_ADD_FN:
  2326. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2327. return( -1 );
  2328. }
  2329. pblock->pb_plugin->plg_preadd = (IFP) value;
  2330. break;
  2331. case SLAPI_PLUGIN_PRE_DELETE_FN:
  2332. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2333. return( -1 );
  2334. }
  2335. pblock->pb_plugin->plg_predelete = (IFP) value;
  2336. break;
  2337. case SLAPI_PLUGIN_PRE_ABANDON_FN:
  2338. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2339. return( -1 );
  2340. }
  2341. pblock->pb_plugin->plg_preabandon = (IFP) value;
  2342. break;
  2343. case SLAPI_PLUGIN_PRE_ENTRY_FN:
  2344. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2345. return( -1 );
  2346. }
  2347. pblock->pb_plugin->plg_preentry = (IFP) value;
  2348. break;
  2349. case SLAPI_PLUGIN_PRE_REFERRAL_FN:
  2350. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2351. return( -1 );
  2352. }
  2353. pblock->pb_plugin->plg_prereferral = (IFP) value;
  2354. break;
  2355. case SLAPI_PLUGIN_PRE_RESULT_FN:
  2356. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_PREOPERATION) {
  2357. return( -1 );
  2358. }
  2359. pblock->pb_plugin->plg_preresult = (IFP) value;
  2360. break;
  2361. /* postoperation plugin functions */
  2362. case SLAPI_PLUGIN_POST_BIND_FN:
  2363. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2364. return( -1 );
  2365. }
  2366. pblock->pb_plugin->plg_postbind = (IFP) value;
  2367. break;
  2368. case SLAPI_PLUGIN_POST_UNBIND_FN:
  2369. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2370. return( -1 );
  2371. }
  2372. pblock->pb_plugin->plg_postunbind = (IFP) value;
  2373. break;
  2374. case SLAPI_PLUGIN_POST_SEARCH_FN:
  2375. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2376. return( -1 );
  2377. }
  2378. pblock->pb_plugin->plg_postsearch = (IFP) value;
  2379. break;
  2380. case SLAPI_PLUGIN_POST_SEARCH_FAIL_FN:
  2381. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2382. return( -1 );
  2383. }
  2384. pblock->pb_plugin->plg_postsearchfail = (IFP) value;
  2385. break;
  2386. case SLAPI_PLUGIN_POST_COMPARE_FN:
  2387. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2388. return( -1 );
  2389. }
  2390. pblock->pb_plugin->plg_postcompare = (IFP) value;
  2391. break;
  2392. case SLAPI_PLUGIN_POST_MODIFY_FN:
  2393. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2394. return( -1 );
  2395. }
  2396. pblock->pb_plugin->plg_postmodify = (IFP) value;
  2397. break;
  2398. case SLAPI_PLUGIN_POST_MODRDN_FN:
  2399. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2400. return( -1 );
  2401. }
  2402. pblock->pb_plugin->plg_postmodrdn = (IFP) value;
  2403. break;
  2404. case SLAPI_PLUGIN_POST_ADD_FN:
  2405. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2406. return( -1 );
  2407. }
  2408. pblock->pb_plugin->plg_postadd = (IFP) value;
  2409. break;
  2410. case SLAPI_PLUGIN_POST_DELETE_FN:
  2411. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2412. return( -1 );
  2413. }
  2414. pblock->pb_plugin->plg_postdelete = (IFP) value;
  2415. break;
  2416. case SLAPI_PLUGIN_POST_ABANDON_FN:
  2417. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2418. return( -1 );
  2419. }
  2420. pblock->pb_plugin->plg_postabandon = (IFP) value;
  2421. break;
  2422. case SLAPI_PLUGIN_POST_ENTRY_FN:
  2423. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2424. return( -1 );
  2425. }
  2426. pblock->pb_plugin->plg_postentry = (IFP) value;
  2427. break;
  2428. case SLAPI_PLUGIN_POST_REFERRAL_FN:
  2429. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2430. return( -1 );
  2431. }
  2432. pblock->pb_plugin->plg_postreferral = (IFP) value;
  2433. break;
  2434. case SLAPI_PLUGIN_POST_RESULT_FN:
  2435. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_POSTOPERATION) {
  2436. return( -1 );
  2437. }
  2438. pblock->pb_plugin->plg_postresult = (IFP) value;
  2439. break;
  2440. /* backend preoperation plugin */
  2441. case SLAPI_PLUGIN_BE_PRE_MODIFY_FN:
  2442. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  2443. return( -1 );
  2444. }
  2445. pblock->pb_plugin->plg_bepremodify = (IFP) value;
  2446. break;
  2447. case SLAPI_PLUGIN_BE_PRE_MODRDN_FN:
  2448. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  2449. return( -1 );
  2450. }
  2451. pblock->pb_plugin->plg_bepremodrdn = (IFP) value;
  2452. break;
  2453. case SLAPI_PLUGIN_BE_PRE_ADD_FN:
  2454. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  2455. return( -1 );
  2456. }
  2457. pblock->pb_plugin->plg_bepreadd = (IFP) value;
  2458. break;
  2459. case SLAPI_PLUGIN_BE_PRE_DELETE_FN:
  2460. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  2461. return( -1 );
  2462. }
  2463. pblock->pb_plugin->plg_bepredelete = (IFP) value;
  2464. break;
  2465. case SLAPI_PLUGIN_BE_PRE_CLOSE_FN:
  2466. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  2467. return( -1 );
  2468. }
  2469. pblock->pb_plugin->plg_bepreclose = (IFP) value;
  2470. break;
  2471. case SLAPI_PLUGIN_BE_PRE_BACKUP_FN:
  2472. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPREOPERATION) {
  2473. return( -1 );
  2474. }
  2475. pblock->pb_plugin->plg_beprebackup = (IFP) value;
  2476. break;
  2477. /* backend postoperation plugin */
  2478. case SLAPI_PLUGIN_BE_POST_MODIFY_FN:
  2479. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  2480. return( -1 );
  2481. }
  2482. pblock->pb_plugin->plg_bepostmodify = (IFP) value;
  2483. break;
  2484. case SLAPI_PLUGIN_BE_POST_MODRDN_FN:
  2485. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  2486. return( -1 );
  2487. }
  2488. pblock->pb_plugin->plg_bepostmodrdn = (IFP) value;
  2489. break;
  2490. case SLAPI_PLUGIN_BE_POST_ADD_FN:
  2491. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  2492. return( -1 );
  2493. }
  2494. pblock->pb_plugin->plg_bepostadd = (IFP) value;
  2495. break;
  2496. case SLAPI_PLUGIN_BE_POST_DELETE_FN:
  2497. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  2498. return( -1 );
  2499. }
  2500. pblock->pb_plugin->plg_bepostdelete = (IFP) value;
  2501. break;
  2502. case SLAPI_PLUGIN_BE_POST_OPEN_FN:
  2503. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  2504. return( -1 );
  2505. }
  2506. pblock->pb_plugin->plg_bepostopen = (IFP) value;
  2507. break;
  2508. case SLAPI_PLUGIN_BE_POST_BACKUP_FN:
  2509. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BEPOSTOPERATION) {
  2510. return( -1 );
  2511. }
  2512. pblock->pb_plugin->plg_bepostbackup = (IFP) value;
  2513. break;
  2514. /* internal preoperation plugin */
  2515. case SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN:
  2516. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) {
  2517. return( -1 );
  2518. }
  2519. pblock->pb_plugin->plg_internal_pre_modify = (IFP) value;
  2520. break;
  2521. case SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN:
  2522. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) {
  2523. return( -1 );
  2524. }
  2525. pblock->pb_plugin->plg_internal_pre_modrdn = (IFP) value;
  2526. break;
  2527. case SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN:
  2528. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) {
  2529. return( -1 );
  2530. }
  2531. pblock->pb_plugin->plg_internal_pre_add = (IFP) value;
  2532. break;
  2533. case SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN:
  2534. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) {
  2535. return( -1 );
  2536. }
  2537. pblock->pb_plugin->plg_internal_pre_delete = (IFP) value;
  2538. break;
  2539. case SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN:
  2540. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_PREOPERATION) {
  2541. return( -1 );
  2542. }
  2543. pblock->pb_plugin->plg_internal_pre_bind = (IFP) value;
  2544. break;
  2545. /* internal postoperation plugin */
  2546. case SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN:
  2547. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_POSTOPERATION) {
  2548. return( -1 );
  2549. }
  2550. pblock->pb_plugin->plg_internal_post_modify = (IFP) value;
  2551. break;
  2552. case SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN:
  2553. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_POSTOPERATION) {
  2554. return( -1 );
  2555. }
  2556. pblock->pb_plugin->plg_internal_post_modrdn = (IFP) value;
  2557. break;
  2558. case SLAPI_PLUGIN_INTERNAL_POST_ADD_FN:
  2559. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_POSTOPERATION) {
  2560. return( -1 );
  2561. }
  2562. pblock->pb_plugin->plg_internal_post_add = (IFP) value;
  2563. break;
  2564. case SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN:
  2565. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_INTERNAL_POSTOPERATION) {
  2566. return( -1 );
  2567. }
  2568. pblock->pb_plugin->plg_internal_post_delete = (IFP) value;
  2569. break;
  2570. /* backend preoperation plugin - called just after creating transaction */
  2571. case SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN:
  2572. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) {
  2573. return( -1 );
  2574. }
  2575. pblock->pb_plugin->plg_betxnpremodify = (IFP) value;
  2576. break;
  2577. case SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN:
  2578. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) {
  2579. return( -1 );
  2580. }
  2581. pblock->pb_plugin->plg_betxnpremodrdn = (IFP) value;
  2582. break;
  2583. case SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN:
  2584. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) {
  2585. return( -1 );
  2586. }
  2587. pblock->pb_plugin->plg_betxnpreadd = (IFP) value;
  2588. break;
  2589. case SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN:
  2590. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) {
  2591. return( -1 );
  2592. }
  2593. pblock->pb_plugin->plg_betxnpredelete = (IFP) value;
  2594. break;
  2595. case SLAPI_PLUGIN_BE_TXN_PRE_DELETE_TOMBSTONE_FN:
  2596. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPREOPERATION) {
  2597. return( -1 );
  2598. }
  2599. pblock->pb_plugin->plg_betxnpredeletetombstone = (IFP) value;
  2600. break;
  2601. /* backend postoperation plugin - called just before committing transaction */
  2602. case SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN:
  2603. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPOSTOPERATION) {
  2604. return( -1 );
  2605. }
  2606. pblock->pb_plugin->plg_betxnpostmodify = (IFP) value;
  2607. break;
  2608. case SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN:
  2609. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPOSTOPERATION) {
  2610. return( -1 );
  2611. }
  2612. pblock->pb_plugin->plg_betxnpostmodrdn = (IFP) value;
  2613. break;
  2614. case SLAPI_PLUGIN_BE_TXN_POST_ADD_FN:
  2615. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPOSTOPERATION) {
  2616. return( -1 );
  2617. }
  2618. pblock->pb_plugin->plg_betxnpostadd = (IFP) value;
  2619. break;
  2620. case SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN:
  2621. if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_BETXNPOSTOPERATION) {
  2622. return( -1 );
  2623. }
  2624. pblock->pb_plugin->plg_betxnpostdelete = (IFP) value;
  2625. break;
  2626. /* syntax plugin functions */
  2627. case SLAPI_PLUGIN_SYNTAX_FILTER_AVA:
  2628. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2629. return( -1 );
  2630. }
  2631. pblock->pb_plugin->plg_syntax_filter_ava = (IFP) value;
  2632. break;
  2633. case SLAPI_PLUGIN_SYNTAX_FILTER_SUB:
  2634. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2635. return( -1 );
  2636. }
  2637. pblock->pb_plugin->plg_syntax_filter_sub = (IFP) value;
  2638. break;
  2639. case SLAPI_PLUGIN_SYNTAX_VALUES2KEYS:
  2640. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2641. return( -1 );
  2642. }
  2643. pblock->pb_plugin->plg_syntax_values2keys = (IFP) value;
  2644. break;
  2645. case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA:
  2646. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2647. return( -1 );
  2648. }
  2649. pblock->pb_plugin->plg_syntax_assertion2keys_ava = (IFP) value;
  2650. break;
  2651. case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB:
  2652. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2653. return( -1 );
  2654. }
  2655. pblock->pb_plugin->plg_syntax_assertion2keys_sub = (IFP) value;
  2656. break;
  2657. case SLAPI_PLUGIN_SYNTAX_NAMES:
  2658. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2659. return( -1 );
  2660. }
  2661. pblock->pb_plugin->plg_syntax_names = (char **) value;
  2662. break;
  2663. case SLAPI_PLUGIN_SYNTAX_OID:
  2664. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2665. return( -1 );
  2666. }
  2667. pblock->pb_plugin->plg_syntax_oid = (char *) value;
  2668. break;
  2669. case SLAPI_PLUGIN_SYNTAX_FLAGS:
  2670. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2671. return( -1 );
  2672. }
  2673. pblock->pb_plugin->plg_syntax_flags = *((int *) value);
  2674. break;
  2675. case SLAPI_PLUGIN_SYNTAX_COMPARE:
  2676. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2677. return( -1 );
  2678. }
  2679. pblock->pb_plugin->plg_syntax_compare = (IFP) value;
  2680. break;
  2681. case SLAPI_SYNTAX_SUBSTRLENS: /* aka SLAPI_MR_SUBSTRLENS */
  2682. pblock->pb_substrlens = (int *) value;
  2683. break;
  2684. case SLAPI_PLUGIN_SYNTAX_VALIDATE:
  2685. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2686. return( -1 );
  2687. }
  2688. pblock->pb_plugin->plg_syntax_validate = (IFP) value;
  2689. break;
  2690. case SLAPI_PLUGIN_SYNTAX_NORMALIZE:
  2691. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_SYNTAX ) {
  2692. return( -1 );
  2693. }
  2694. pblock->pb_plugin->plg_syntax_normalize = (VFPV) value;
  2695. break;
  2696. case SLAPI_ENTRY_PRE_OP:
  2697. pblock->pb_pre_op_entry = (Slapi_Entry *) value;
  2698. break;
  2699. case SLAPI_ENTRY_POST_OP:
  2700. pblock->pb_post_op_entry = (Slapi_Entry *) value;
  2701. break;
  2702. /* target address for all operations */
  2703. case SLAPI_TARGET_ADDRESS:
  2704. PR_ASSERT (PR_FALSE); /* can't do this */
  2705. break;
  2706. case SLAPI_TARGET_DN: /* DEPRECATED */
  2707. /* slapi_pblock_set(pb, SLAPI_TARGET_DN, val) automatically
  2708. * replaces SLAPI_TARGET_SDN. Caller should not free the
  2709. * original SLAPI_TARGET_SDN, but the reset one here by getting
  2710. * the address using slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn). */
  2711. if(pblock->pb_op!=NULL)
  2712. {
  2713. Slapi_DN *sdn = pblock->pb_op->o_params.target_address.sdn;
  2714. slapi_sdn_free(&sdn);
  2715. pblock->pb_op->o_params.target_address.sdn =
  2716. slapi_sdn_new_dn_byval((char *)value);
  2717. }
  2718. else
  2719. {
  2720. return( -1 );
  2721. }
  2722. break;
  2723. case SLAPI_TARGET_SDN:
  2724. if(pblock->pb_op!=NULL)
  2725. {
  2726. pblock->pb_op->o_params.target_address.sdn = (Slapi_DN *)value;
  2727. }
  2728. else
  2729. {
  2730. return( -1 );
  2731. }
  2732. break;
  2733. case SLAPI_ORIGINAL_TARGET_DN:
  2734. if(pblock->pb_op!=NULL)
  2735. {
  2736. pblock->pb_op->o_params.target_address.udn = (char *)value;
  2737. }
  2738. break;
  2739. case SLAPI_TARGET_UNIQUEID:
  2740. if(pblock->pb_op!=NULL)
  2741. {
  2742. pblock->pb_op->o_params.target_address.uniqueid = (char *) value;
  2743. }
  2744. break;
  2745. case SLAPI_REQCONTROLS:
  2746. if(pblock->pb_op!=NULL)
  2747. {
  2748. pblock->pb_op->o_params.request_controls = (LDAPControl **) value;
  2749. }
  2750. break;
  2751. case SLAPI_RESCONTROLS:
  2752. if(pblock->pb_op!=NULL)
  2753. {
  2754. pblock->pb_op->o_results.result_controls = (LDAPControl **) value;
  2755. }
  2756. break;
  2757. case SLAPI_CONTROLS_ARG: /* used to pass control argument before operation is created */
  2758. pblock->pb_ctrls_arg = (LDAPControl **) value;
  2759. break;
  2760. case SLAPI_ADD_RESCONTROL:
  2761. if(pblock->pb_op!=NULL)
  2762. {
  2763. add_control( &pblock->pb_op->o_results.result_controls, (LDAPControl *)value );
  2764. }
  2765. break;
  2766. /* notes to be added to the access log RESULT line for this op. */
  2767. case SLAPI_OPERATION_NOTES:
  2768. if ( value == NULL ) {
  2769. pblock->pb_operation_notes = 0; /* cleared */
  2770. } else {
  2771. pblock->pb_operation_notes |= *((unsigned int *)value );
  2772. }
  2773. break;
  2774. case SLAPI_SKIP_MODIFIED_ATTRS:
  2775. if(pblock->pb_op == NULL)
  2776. break;
  2777. if(value == 0){
  2778. pblock->pb_op->o_flags &= ~OP_FLAG_SKIP_MODIFIED_ATTRS;
  2779. } else {
  2780. pblock->pb_op->o_flags |= OP_FLAG_SKIP_MODIFIED_ATTRS;
  2781. }
  2782. break;
  2783. /* controls we know about */
  2784. case SLAPI_MANAGEDSAIT:
  2785. pblock->pb_managedsait = *((int *) value);
  2786. break;
  2787. case SLAPI_PWPOLICY:
  2788. pblock->pb_pwpolicy_ctrl = *((int *) value);
  2789. break;
  2790. /* add arguments */
  2791. case SLAPI_ADD_ENTRY:
  2792. if(pblock->pb_op!=NULL)
  2793. {
  2794. pblock->pb_op->o_params.p.p_add.target_entry = (Slapi_Entry *) value;
  2795. }
  2796. break;
  2797. case SLAPI_ADD_EXISTING_DN_ENTRY:
  2798. pblock->pb_existing_dn_entry = (Slapi_Entry *) value;
  2799. break;
  2800. case SLAPI_ADD_EXISTING_UNIQUEID_ENTRY:
  2801. pblock->pb_existing_uniqueid_entry = (Slapi_Entry *) value;
  2802. break;
  2803. case SLAPI_ADD_PARENT_ENTRY:
  2804. pblock->pb_parent_entry = (Slapi_Entry *) value;
  2805. break;
  2806. case SLAPI_ADD_PARENT_UNIQUEID:
  2807. if(pblock->pb_op!=NULL)
  2808. {
  2809. pblock->pb_op->o_params.p.p_add.parentuniqueid = (char *) value;
  2810. }
  2811. break;
  2812. /* bind arguments */
  2813. case SLAPI_BIND_METHOD:
  2814. if(pblock->pb_op!=NULL)
  2815. {
  2816. pblock->pb_op->o_params.p.p_bind.bind_method = *((ber_tag_t *) value);
  2817. }
  2818. break;
  2819. case SLAPI_BIND_CREDENTIALS:
  2820. if(pblock->pb_op!=NULL)
  2821. {
  2822. pblock->pb_op->o_params.p.p_bind.bind_creds = (struct berval *) value;
  2823. }
  2824. break;
  2825. case SLAPI_BIND_SASLMECHANISM:
  2826. if(pblock->pb_op!=NULL)
  2827. {
  2828. pblock->pb_op->o_params.p.p_bind.bind_saslmechanism = (char *) value;
  2829. }
  2830. break;
  2831. /* bind return values */
  2832. case SLAPI_BIND_RET_SASLCREDS:
  2833. if(pblock->pb_op!=NULL)
  2834. {
  2835. pblock->pb_op->o_results.r.r_bind.bind_ret_saslcreds = (struct berval *) value;
  2836. }
  2837. break;
  2838. /* compare arguments */
  2839. case SLAPI_COMPARE_TYPE:
  2840. if(pblock->pb_op!=NULL)
  2841. {
  2842. pblock->pb_op->o_params.p.p_compare.compare_ava.ava_type = (char *) value;
  2843. }
  2844. break;
  2845. case SLAPI_COMPARE_VALUE:
  2846. if(pblock->pb_op!=NULL)
  2847. {
  2848. pblock->pb_op->o_params.p.p_compare.compare_ava.ava_value = *((struct berval *) value);
  2849. }
  2850. break;
  2851. /* modify arguments */
  2852. case SLAPI_MODIFY_MODS:
  2853. PR_ASSERT(pblock->pb_op);
  2854. if(pblock->pb_op!=NULL)
  2855. {
  2856. if(pblock->pb_op->o_params.operation_type==SLAPI_OPERATION_MODIFY)
  2857. {
  2858. pblock->pb_op->o_params.p.p_modify.modify_mods = (LDAPMod **) value;
  2859. }
  2860. else if(pblock->pb_op->o_params.operation_type==SLAPI_OPERATION_MODRDN)
  2861. {
  2862. pblock->pb_op->o_params.p.p_modrdn.modrdn_mods = (LDAPMod **) value;
  2863. }
  2864. else
  2865. {
  2866. PR_ASSERT(0);
  2867. }
  2868. }
  2869. break;
  2870. /* modrdn arguments */
  2871. case SLAPI_MODRDN_NEWRDN:
  2872. if(pblock->pb_op!=NULL)
  2873. {
  2874. pblock->pb_op->o_params.p.p_modrdn.modrdn_newrdn = (char *) value;
  2875. }
  2876. break;
  2877. case SLAPI_MODRDN_DELOLDRDN:
  2878. if(pblock->pb_op!=NULL)
  2879. {
  2880. pblock->pb_op->o_params.p.p_modrdn.modrdn_deloldrdn = *((int *) value);
  2881. }
  2882. break;
  2883. case SLAPI_MODRDN_NEWSUPERIOR: /* DEPRECATED */
  2884. if(pblock->pb_op!=NULL)
  2885. {
  2886. Slapi_DN *sdn =
  2887. pblock->pb_op->o_params.p.p_modrdn.modrdn_newsuperior_address.sdn;
  2888. slapi_sdn_free(&sdn);
  2889. pblock->pb_op->o_params.p.p_modrdn.modrdn_newsuperior_address.sdn =
  2890. slapi_sdn_new_dn_byval((char *)value);
  2891. }
  2892. else
  2893. {
  2894. return -1;
  2895. }
  2896. break;
  2897. case SLAPI_MODRDN_NEWSUPERIOR_SDN:
  2898. if(pblock->pb_op!=NULL)
  2899. {
  2900. pblock->pb_op->o_params.p.p_modrdn.modrdn_newsuperior_address.sdn =
  2901. (Slapi_DN *) value;
  2902. }
  2903. else
  2904. {
  2905. return -1;
  2906. }
  2907. break;
  2908. case SLAPI_MODRDN_PARENT_ENTRY:
  2909. pblock->pb_parent_entry = (Slapi_Entry *) value;
  2910. break;
  2911. case SLAPI_MODRDN_NEWPARENT_ENTRY:
  2912. pblock->pb_newparent_entry = (Slapi_Entry *) value;
  2913. break;
  2914. case SLAPI_MODRDN_TARGET_ENTRY:
  2915. pblock->pb_target_entry = (Slapi_Entry *) value;
  2916. break;
  2917. case SLAPI_MODRDN_NEWSUPERIOR_ADDRESS:
  2918. PR_ASSERT (PR_FALSE); /* can't do this */
  2919. /* search arguments */
  2920. case SLAPI_SEARCH_SCOPE:
  2921. if(pblock->pb_op!=NULL)
  2922. {
  2923. pblock->pb_op->o_params.p.p_search.search_scope = *((int *) value);
  2924. }
  2925. break;
  2926. case SLAPI_SEARCH_DEREF:
  2927. if(pblock->pb_op!=NULL)
  2928. {
  2929. pblock->pb_op->o_params.p.p_search.search_deref = *((int *) value);
  2930. }
  2931. break;
  2932. case SLAPI_SEARCH_SIZELIMIT:
  2933. if(pblock->pb_op!=NULL)
  2934. {
  2935. pblock->pb_op->o_params.p.p_search.search_sizelimit = *((int *) value);
  2936. }
  2937. break;
  2938. case SLAPI_SEARCH_TIMELIMIT:
  2939. if(pblock->pb_op!=NULL)
  2940. {
  2941. pblock->pb_op->o_params.p.p_search.search_timelimit = *((int *) value);
  2942. }
  2943. break;
  2944. case SLAPI_SEARCH_FILTER:
  2945. if(pblock->pb_op!=NULL)
  2946. {
  2947. pblock->pb_op->o_params.p.p_search.search_filter = (struct slapi_filter *) value;
  2948. }
  2949. break;
  2950. case SLAPI_SEARCH_STRFILTER:
  2951. if(pblock->pb_op!=NULL)
  2952. {
  2953. pblock->pb_op->o_params.p.p_search.search_strfilter = (char *) value;
  2954. }
  2955. break;
  2956. case SLAPI_SEARCH_ATTRS:
  2957. if(pblock->pb_op!=NULL)
  2958. {
  2959. #if defined(USE_OLD_UNHASHED)
  2960. char **attrs;
  2961. for (attrs = (char **)value; attrs && *attrs; attrs++) {
  2962. /* Get rid of forbidden attr, e.g.,
  2963. * PSEUDO_ATTR_UNHASHEDUSERPASSWORD,
  2964. * which never be returned. */
  2965. if (is_type_forbidden(*attrs)) {
  2966. char **ptr;
  2967. for (ptr = attrs; ptr && *ptr; ptr++) {
  2968. if (ptr == attrs) {
  2969. slapi_ch_free_string(ptr); /* free unhashed type */
  2970. }
  2971. *ptr = *(ptr + 1); /* attrs is NULL terminated;
  2972. the NULL is copied here. */
  2973. }
  2974. }
  2975. }
  2976. #endif
  2977. pblock->pb_op->o_params.p.p_search.search_attrs = (char **) value;
  2978. }
  2979. break;
  2980. case SLAPI_SEARCH_GERATTRS:
  2981. if(pblock->pb_op!=NULL)
  2982. {
  2983. pblock->pb_op->o_params.p.p_search.search_gerattrs = (char **) value;
  2984. }
  2985. break;
  2986. case SLAPI_SEARCH_REQATTRS:
  2987. if(pblock->pb_op!=NULL)
  2988. {
  2989. pblock->pb_op->o_searchattrs = (char **) value;
  2990. }
  2991. break;
  2992. case SLAPI_SEARCH_ATTRSONLY:
  2993. if(pblock->pb_op!=NULL)
  2994. {
  2995. pblock->pb_op->o_params.p.p_search.search_attrsonly = *((int *) value);
  2996. }
  2997. break;
  2998. case SLAPI_SEARCH_IS_AND:
  2999. if(pblock->pb_op!=NULL)
  3000. {
  3001. pblock->pb_op->o_params.p.p_search.search_is_and = *((int *) value);
  3002. }
  3003. break;
  3004. /* abandon operation arguments */
  3005. case SLAPI_ABANDON_MSGID:
  3006. if(pblock->pb_op!=NULL)
  3007. {
  3008. pblock->pb_op->o_params.p.p_abandon.abandon_targetmsgid = *((int *) value);
  3009. }
  3010. break;
  3011. /* extended operation arguments */
  3012. case SLAPI_EXT_OP_REQ_OID:
  3013. if(pblock->pb_op!=NULL)
  3014. {
  3015. pblock->pb_op->o_params.p.p_extended.exop_oid = (char *) value;
  3016. }
  3017. break;
  3018. case SLAPI_EXT_OP_REQ_VALUE:
  3019. if(pblock->pb_op!=NULL)
  3020. {
  3021. pblock->pb_op->o_params.p.p_extended.exop_value = (struct berval *) value;
  3022. }
  3023. break;
  3024. /* extended operation return values */
  3025. case SLAPI_EXT_OP_RET_OID:
  3026. if(pblock->pb_op!=NULL)
  3027. {
  3028. pblock->pb_op->o_results.r.r_extended.exop_ret_oid = (char *) value;
  3029. }
  3030. break;
  3031. case SLAPI_EXT_OP_RET_VALUE:
  3032. if(pblock->pb_op!=NULL)
  3033. {
  3034. pblock->pb_op->o_results.r.r_extended.exop_ret_value = (struct berval *) value;
  3035. }
  3036. break;
  3037. /* matching rule plugin functions */
  3038. case SLAPI_PLUGIN_MR_FILTER_CREATE_FN:
  3039. SLAPI_PLUGIN_TYPE_CHECK (pblock, SLAPI_PLUGIN_MATCHINGRULE);
  3040. pblock->pb_plugin->plg_mr_filter_create = (IFP) value;
  3041. break;
  3042. case SLAPI_PLUGIN_MR_INDEXER_CREATE_FN:
  3043. SLAPI_PLUGIN_TYPE_CHECK (pblock, SLAPI_PLUGIN_MATCHINGRULE);
  3044. pblock->pb_plugin->plg_mr_indexer_create = (IFP) value;
  3045. break;
  3046. case SLAPI_PLUGIN_MR_FILTER_MATCH_FN:
  3047. pblock->pb_mr_filter_match_fn = (mrFilterMatchFn) value;
  3048. break;
  3049. case SLAPI_PLUGIN_MR_FILTER_INDEX_FN:
  3050. pblock->pb_mr_filter_index_fn = (IFP) value;
  3051. break;
  3052. case SLAPI_PLUGIN_MR_FILTER_RESET_FN:
  3053. pblock->pb_mr_filter_reset_fn = (IFP) value;
  3054. break;
  3055. case SLAPI_PLUGIN_MR_INDEX_FN:
  3056. pblock->pb_mr_index_fn = (IFP) value;
  3057. break;
  3058. case SLAPI_PLUGIN_MR_INDEX_SV_FN:
  3059. pblock->pb_mr_index_sv_fn = (IFP) value;
  3060. break;
  3061. /* matching rule plugin arguments */
  3062. case SLAPI_PLUGIN_MR_OID:
  3063. pblock->pb_mr_oid = (char *) value;
  3064. break;
  3065. case SLAPI_PLUGIN_MR_TYPE:
  3066. pblock->pb_mr_type = (char *) value;
  3067. break;
  3068. case SLAPI_PLUGIN_MR_VALUE:
  3069. pblock->pb_mr_value = (struct berval *) value;
  3070. break;
  3071. case SLAPI_PLUGIN_MR_VALUES:
  3072. pblock->pb_mr_values = (struct berval **) value;
  3073. break;
  3074. case SLAPI_PLUGIN_MR_KEYS:
  3075. pblock->pb_mr_keys = (struct berval **) value;
  3076. break;
  3077. case SLAPI_PLUGIN_MR_FILTER_REUSABLE:
  3078. pblock->pb_mr_filter_reusable = *(unsigned int *) value;
  3079. break;
  3080. case SLAPI_PLUGIN_MR_QUERY_OPERATOR:
  3081. pblock->pb_mr_query_operator = *(int *) value;
  3082. break;
  3083. case SLAPI_PLUGIN_MR_USAGE:
  3084. pblock->pb_mr_usage = *(unsigned int *) value;
  3085. break;
  3086. /* new style matching rule syntax plugin functions */
  3087. case SLAPI_PLUGIN_MR_FILTER_AVA:
  3088. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  3089. return( -1 );
  3090. }
  3091. pblock->pb_plugin->plg_mr_filter_ava = (IFP) value;
  3092. break;
  3093. case SLAPI_PLUGIN_MR_FILTER_SUB:
  3094. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  3095. return( -1 );
  3096. }
  3097. pblock->pb_plugin->plg_mr_filter_sub = (IFP) value;
  3098. break;
  3099. case SLAPI_PLUGIN_MR_VALUES2KEYS:
  3100. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  3101. return( -1 );
  3102. }
  3103. pblock->pb_plugin->plg_mr_values2keys = (IFP) value;
  3104. break;
  3105. case SLAPI_PLUGIN_MR_ASSERTION2KEYS_AVA:
  3106. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  3107. return( -1 );
  3108. }
  3109. pblock->pb_plugin->plg_mr_assertion2keys_ava = (IFP) value;
  3110. break;
  3111. case SLAPI_PLUGIN_MR_ASSERTION2KEYS_SUB:
  3112. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  3113. return( -1 );
  3114. }
  3115. pblock->pb_plugin->plg_mr_assertion2keys_sub = (IFP) value;
  3116. break;
  3117. case SLAPI_PLUGIN_MR_FLAGS:
  3118. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  3119. return( -1 );
  3120. }
  3121. pblock->pb_plugin->plg_mr_flags = *((int *) value);
  3122. break;
  3123. case SLAPI_PLUGIN_MR_NAMES:
  3124. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  3125. return( -1 );
  3126. }
  3127. pblock->pb_plugin->plg_mr_names = (char **) value;
  3128. break;
  3129. case SLAPI_PLUGIN_MR_COMPARE:
  3130. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  3131. return( -1 );
  3132. }
  3133. pblock->pb_plugin->plg_mr_compare = (IFP) value;
  3134. break;
  3135. case SLAPI_PLUGIN_MR_NORMALIZE:
  3136. if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_MATCHINGRULE ) {
  3137. return( -1 );
  3138. }
  3139. pblock->pb_plugin->plg_mr_normalize = (VFPV) value;
  3140. break;
  3141. /* seq arguments */
  3142. case SLAPI_SEQ_TYPE:
  3143. pblock->pb_seq_type = *((int *)value);
  3144. break;
  3145. case SLAPI_SEQ_ATTRNAME:
  3146. pblock->pb_seq_attrname = (char *) value;
  3147. break;
  3148. case SLAPI_SEQ_VAL:
  3149. pblock->pb_seq_val = (char *) value;
  3150. break;
  3151. /* ldif2db arguments */
  3152. case SLAPI_LDIF2DB_FILE:
  3153. pblock->pb_ldif_file = (char *) value;
  3154. break;
  3155. case SLAPI_LDIF2DB_REMOVEDUPVALS:
  3156. pblock->pb_removedupvals = *((int *)value);
  3157. break;
  3158. case SLAPI_DB2INDEX_ATTRS:
  3159. pblock->pb_db2index_attrs = (char **) value;
  3160. break;
  3161. case SLAPI_LDIF2DB_NOATTRINDEXES:
  3162. pblock->pb_ldif2db_noattrindexes = *((int *)value);
  3163. break;
  3164. case SLAPI_LDIF2DB_GENERATE_UNIQUEID:
  3165. pblock->pb_ldif_generate_uniqueid = *((int *)value);
  3166. break;
  3167. case SLAPI_LDIF2DB_NAMESPACEID:
  3168. pblock->pb_ldif_namespaceid = (char *)value;
  3169. break;
  3170. /* db2ldif arguments */
  3171. case SLAPI_DB2LDIF_PRINTKEY:
  3172. pblock->pb_ldif_printkey = *((int *)value);
  3173. break;
  3174. case SLAPI_DB2LDIF_DUMP_UNIQUEID:
  3175. pblock->pb_ldif_dump_uniqueid = *((int *)value);
  3176. break;
  3177. /* db2ldif/ldif2db/db2bak/bak2db arguments */
  3178. case SLAPI_BACKEND_INSTANCE_NAME:
  3179. pblock->pb_instance_name = (char *) value;
  3180. break;
  3181. case SLAPI_BACKEND_TASK:
  3182. pblock->pb_task = (Slapi_Task *)value;
  3183. break;
  3184. case SLAPI_TASK_FLAGS:
  3185. pblock->pb_task_flags = *((int *)value);
  3186. break;
  3187. case SLAPI_DB2LDIF_SERVER_RUNNING:
  3188. pblock->pb_server_running = *((int *)value);
  3189. break;
  3190. case SLAPI_BULK_IMPORT_ENTRY:
  3191. pblock->pb_import_entry = (Slapi_Entry *)value;
  3192. break;
  3193. case SLAPI_BULK_IMPORT_STATE:
  3194. pblock->pb_import_state = *((int *)value);
  3195. break;
  3196. /* transaction arguments */
  3197. case SLAPI_PARENT_TXN:
  3198. pblock->pb_parent_txn = (void *)value;
  3199. break;
  3200. case SLAPI_TXN:
  3201. pblock->pb_txn = (void *)value;
  3202. break;
  3203. case SLAPI_TXN_RUV_MODS_FN:
  3204. pblock->pb_txn_ruv_mods_fn = (IFP) value;
  3205. break;
  3206. /* Search results set */
  3207. case SLAPI_SEARCH_RESULT_SET:
  3208. if(pblock->pb_op!=NULL)
  3209. {
  3210. pblock->pb_op->o_results.r.r_search.search_result_set = (void *)value;
  3211. }
  3212. break;
  3213. /* estimated search result set size */
  3214. case SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE:
  3215. if(pblock->pb_op!=NULL)
  3216. {
  3217. pblock->pb_op->o_results.r.r_search.estimate = *(int *)value;
  3218. }
  3219. break;
  3220. /* Search result - entry returned from iterating over result set */
  3221. case SLAPI_SEARCH_RESULT_ENTRY:
  3222. if(pblock->pb_op!=NULL)
  3223. {
  3224. pblock->pb_op->o_results.r.r_search.search_result_entry = (void *)value;
  3225. }
  3226. break;
  3227. case SLAPI_SEARCH_RESULT_ENTRY_EXT:
  3228. if(pblock->pb_op!=NULL)
  3229. {
  3230. pblock->pb_op->o_results.r.r_search.opaque_backend_ptr = (void *)value;
  3231. }
  3232. break;
  3233. /* Number of entries returned from search */
  3234. case SLAPI_NENTRIES:
  3235. if(pblock->pb_op!=NULL)
  3236. {
  3237. pblock->pb_op->o_results.r.r_search.nentries = *((int *)value);
  3238. }
  3239. break;
  3240. /* Referrals encountered while iterating over the result set */
  3241. case SLAPI_SEARCH_REFERRALS:
  3242. if(pblock->pb_op!=NULL)
  3243. {
  3244. pblock->pb_op->o_results.r.r_search.search_referrals = (struct berval **)value;
  3245. }
  3246. break;
  3247. case SLAPI_RESULT_CODE:
  3248. if (pblock->pb_op != NULL)
  3249. pblock->pb_op->o_results.result_code = (* (int *) value);
  3250. break;
  3251. case SLAPI_RESULT_MATCHED:
  3252. if (pblock->pb_op != NULL)
  3253. pblock->pb_op->o_results.result_matched = (char *) value;
  3254. break;
  3255. case SLAPI_RESULT_TEXT:
  3256. if (pblock->pb_op != NULL)
  3257. pblock->pb_op->o_results.result_text = (char *) value;
  3258. break;
  3259. case SLAPI_PB_RESULT_TEXT:
  3260. slapi_ch_free((void**)&(pblock->pb_result_text));
  3261. pblock->pb_result_text = slapi_ch_strdup ((char *) value);
  3262. break;
  3263. /* Size of the database, in kb */
  3264. case SLAPI_DBSIZE:
  3265. pblock->pb_dbsize = *((unsigned int *)value);
  3266. break;
  3267. /* ACL Plugin */
  3268. case SLAPI_PLUGIN_ACL_INIT:
  3269. pblock->pb_plugin->plg_acl_init = (IFP) value;
  3270. break;
  3271. case SLAPI_PLUGIN_ACL_SYNTAX_CHECK:
  3272. pblock->pb_plugin->plg_acl_syntax_check = (IFP) value;
  3273. break;
  3274. case SLAPI_PLUGIN_ACL_ALLOW_ACCESS:
  3275. pblock->pb_plugin->plg_acl_access_allowed = (IFP) value;
  3276. break;
  3277. case SLAPI_PLUGIN_ACL_MODS_ALLOWED:
  3278. pblock->pb_plugin->plg_acl_mods_allowed = (IFP) value;
  3279. break;
  3280. case SLAPI_PLUGIN_ACL_MODS_UPDATE:
  3281. pblock->pb_plugin->plg_acl_mods_update = (IFP) value;
  3282. break;
  3283. case SLAPI_CLIENT_DNS:
  3284. if (pblock->pb_conn == NULL) {
  3285. LDAPDebug( LDAP_DEBUG_ANY,
  3286. "Connection is NULL and hence cannot access SLAPI_CLIENT_DNS \n", 0, 0, 0 );
  3287. return (-1);
  3288. }
  3289. pblock->pb_conn->c_domain = *((struct berval ***) value );
  3290. break;
  3291. /* Command line arguments */
  3292. case SLAPI_ARGC:
  3293. pblock->pb_slapd_argc= *((int *)value);
  3294. break;
  3295. case SLAPI_ARGV:
  3296. pblock->pb_slapd_argv = *((char***)value);
  3297. break;
  3298. /* Config file directory */
  3299. case SLAPI_CONFIG_DIRECTORY:
  3300. pblock->pb_slapd_configdir = (char *)value;
  3301. break;
  3302. /* password storage scheme (kexcoff) */
  3303. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME:
  3304. pblock->pb_plugin->plg_pwdstorageschemename = (char *)value;
  3305. break;
  3306. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_USER_PWD:
  3307. pblock->pb_pwd_storage_scheme_user_passwd = (char *)value;
  3308. break;
  3309. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DB_PWD:
  3310. pblock->pb_pwd_storage_scheme_db_passwd = (char *)value;
  3311. break;
  3312. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN:
  3313. pblock->pb_plugin->plg_pwdstorageschemeenc = (CFP)value;
  3314. break;
  3315. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DEC_FN:
  3316. pblock->pb_plugin->plg_pwdstorageschemedec = (IFP)value;
  3317. break;
  3318. case SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN:
  3319. /* must provide a comparison function */
  3320. if ( value == NULL )
  3321. {
  3322. return(-1);
  3323. }
  3324. pblock->pb_plugin->plg_pwdstorageschemecmp = (IFP)value;
  3325. break;
  3326. /* entry fetch store */
  3327. case SLAPI_PLUGIN_ENTRY_FETCH_FUNC:
  3328. pblock->pb_plugin->plg_entryfetchfunc = (IFP) value;
  3329. break;
  3330. case SLAPI_PLUGIN_ENTRY_STORE_FUNC:
  3331. pblock->pb_plugin->plg_entrystorefunc = (IFP) value;
  3332. break;
  3333. case SLAPI_PLUGIN_ENABLED:
  3334. pblock->pb_plugin_enabled = *((int *)value);
  3335. break;
  3336. /* DSE add parameters */
  3337. case SLAPI_DSE_DONT_WRITE_WHEN_ADDING:
  3338. pblock->pb_dse_dont_add_write = *((int *)value);
  3339. break;
  3340. /* DSE add parameters */
  3341. case SLAPI_DSE_MERGE_WHEN_ADDING:
  3342. pblock->pb_dse_add_merge = *((int *)value);
  3343. break;
  3344. /* DSE add parameters */
  3345. case SLAPI_DSE_DONT_CHECK_DUPS:
  3346. pblock->pb_dse_dont_check_dups = *((int *)value);
  3347. break;
  3348. /* DSE modify parameters */
  3349. case SLAPI_DSE_REAPPLY_MODS:
  3350. pblock->pb_dse_reapply_mods = *((int *)value);
  3351. break;
  3352. /* DSE read parameters */
  3353. case SLAPI_DSE_IS_PRIMARY_FILE:
  3354. pblock->pb_dse_is_primary_file = *((int *)value);
  3355. break;
  3356. /* used internally by schema code (schema.c) */
  3357. case SLAPI_SCHEMA_FLAGS:
  3358. pblock->pb_schema_flags = *((int *)value);
  3359. break;
  3360. case SLAPI_URP_NAMING_COLLISION_DN:
  3361. pblock->pb_urp_naming_collision_dn = (char *)value;
  3362. break;
  3363. case SLAPI_URP_TOMBSTONE_UNIQUEID:
  3364. pblock->pb_urp_tombstone_uniqueid = (char *)value;
  3365. break;
  3366. case SLAPI_LDIF2DB_ENCRYPT:
  3367. case SLAPI_DB2LDIF_DECRYPT:
  3368. pblock->pb_ldif_encrypt = *((int *)value);
  3369. break;
  3370. case SLAPI_SEARCH_CTRLS:
  3371. pblock->pb_search_ctrls = (LDAPControl **) value;
  3372. break;
  3373. case SLAPI_PLUGIN_SYNTAX_FILTER_NORMALIZED:
  3374. pblock->pb_syntax_filter_normalized = *((int *)value);
  3375. break;
  3376. case SLAPI_PLUGIN_SYNTAX_FILTER_DATA:
  3377. pblock->pb_syntax_filter_data = (void *)value;
  3378. break;
  3379. case SLAPI_PAGED_RESULTS_INDEX:
  3380. pblock->pb_paged_results_index = *(int *)value;
  3381. break;
  3382. /* ACI Target Check */
  3383. case SLAPI_ACI_TARGET_CHECK:
  3384. pblock->pb_aci_target_check = *((int *) value);
  3385. break;
  3386. /* dbverify */
  3387. case SLAPI_DBVERIFY_DBDIR:
  3388. pblock->pb_dbverify_dbdir = (char *) value;
  3389. break;
  3390. default:
  3391. LDAPDebug( LDAP_DEBUG_ANY,
  3392. "Unknown parameter block argument %d\n", arg, 0, 0 );
  3393. return( -1 );
  3394. }
  3395. return( 0 );
  3396. }
  3397. int
  3398. slapi_is_ldapi_conn(Slapi_PBlock *pb)
  3399. {
  3400. if(pb && pb->pb_conn){
  3401. return pb->pb_conn->c_unix_local;
  3402. } else {
  3403. return 0;
  3404. }
  3405. }
  3406. /*
  3407. * Clears (and free's as appropriate) the bind DN and related credentials
  3408. * for the connection `conn'.
  3409. *
  3410. * If `lock_conn' is true, 'conn' is locked before touching it; otherwise
  3411. * this function assumes that conn->c_mutex is ALREADY locked.
  3412. *
  3413. * If `clear_externalcreds' is true, the external DN, external authtype,
  3414. * and client certificate are also cleared and free'd.
  3415. *
  3416. * Connection structure members that are potentially changed by this function:
  3417. * c_dn, c_isroot, c_authtype
  3418. * c_external_dn, c_external_authtype, c_client_cert
  3419. *
  3420. * This function might better belong on bind.c or perhaps connection.c but
  3421. * it needs to be in libslapd because FE code and libslapd code calls it.
  3422. */
  3423. void
  3424. bind_credentials_clear( Connection *conn, PRBool lock_conn,
  3425. PRBool clear_externalcreds )
  3426. {
  3427. if ( lock_conn ) {
  3428. PR_EnterMonitor(conn->c_mutex);
  3429. }
  3430. if ( conn->c_dn != NULL ) { /* a non-anonymous bind has occurred */
  3431. reslimit_update_from_entry( conn, NULL ); /* clear resource limits */
  3432. if ( conn->c_dn != conn->c_external_dn ) {
  3433. slapi_ch_free((void**)&conn->c_dn);
  3434. }
  3435. conn->c_dn = NULL;
  3436. }
  3437. slapi_ch_free((void**)&conn->c_authtype);
  3438. conn->c_isroot = 0;
  3439. conn->c_authtype = slapi_ch_strdup(SLAPD_AUTH_NONE);
  3440. if ( clear_externalcreds ) {
  3441. slapi_ch_free( (void**)&conn->c_external_dn );
  3442. conn->c_external_dn = NULL;
  3443. conn->c_external_authtype = SLAPD_AUTH_NONE;
  3444. if ( conn->c_client_cert ) {
  3445. CERT_DestroyCertificate (conn->c_client_cert);
  3446. conn->c_client_cert = NULL;
  3447. }
  3448. }
  3449. if ( lock_conn ) {
  3450. PR_ExitMonitor(conn->c_mutex);
  3451. }
  3452. }
  3453. /*
  3454. * Clear and then set the bind DN and related credentials for the
  3455. * connection `conn'.
  3456. *
  3457. * `authtype' should be one of the SLAPD_AUTH_... constants defined in
  3458. * slapu-plugin.h or NULL.
  3459. *
  3460. * `normdn' must be a normalized DN and it must be malloc'd memory (it
  3461. * is consumed by this function). If there is an existing DN value
  3462. * associated with the connection, it is free'd. Pass NULL for `normdn'
  3463. * to clear the DN.
  3464. *
  3465. * If `extauthtype' is non-NULL we also clear and then set the
  3466. * external (e.g., SSL) credentials from the `externaldn' and `clientcert'.
  3467. * Note that it is okay for `externaldn' and 'normdn' to have the same
  3468. * (pointer) value. This code and that in bind_credentials_clear()
  3469. * is smart enough to know to only free the memory once. Like `normdn',
  3470. * `externaldn' and `clientcert' should be NULL or point to malloc'd memory
  3471. * as they are both consumed by this function.
  3472. *
  3473. * We also:
  3474. *
  3475. * 1) Test to see if the DN is the root DN and set the c_isroot flag
  3476. * appropriately.
  3477. * And
  3478. *
  3479. * 2) Call the binder-based resource limits subsystem so it can
  3480. * update the per-connection resource limit data it maintains.
  3481. *
  3482. * Note that this function should ALWAYS be used instead of manipulating
  3483. * conn->c_dn directly; otherwise, subsystems like the binder-based resource
  3484. * limits (see resourcelimit.c) won't be called.
  3485. *
  3486. * It is also acceptable to set the DN via a call slapi_pblock_set(), e.g.,
  3487. *
  3488. * slapi_pblock_set( pb, SLAPI_CONN_DN, ndn );
  3489. *
  3490. * because it calls this function.
  3491. *
  3492. * Connection structure members that are potentially changed by this function:
  3493. * c_dn, c_isroot, c_authtype
  3494. * c_external_dn, c_external_authtype, c_client_cert
  3495. *
  3496. * This function might better belong on bind.c or perhaps connection.c but
  3497. * it needs to be in libslapd because FE code and libslapd code calls it.
  3498. */
  3499. void
  3500. bind_credentials_set( Connection *conn, char *authtype, char *normdn,
  3501. char *extauthtype, char *externaldn, CERTCertificate *clientcert, Slapi_Entry * bind_target_entry )
  3502. {
  3503. PR_EnterMonitor(conn->c_mutex);
  3504. bind_credentials_set_nolock(conn, authtype, normdn,
  3505. extauthtype, externaldn, clientcert, bind_target_entry);
  3506. PR_ExitMonitor(conn->c_mutex);
  3507. }
  3508. void
  3509. bind_credentials_set_nolock( Connection *conn, char *authtype, char *normdn,
  3510. char *extauthtype, char *externaldn, CERTCertificate *clientcert, Slapi_Entry * bind_target_entry )
  3511. {
  3512. slapdFrontendConfig_t *fecfg = getFrontendConfig();
  3513. int idletimeout = 0;
  3514. /* clear credentials */
  3515. bind_credentials_clear( conn, PR_FALSE /* conn is already locked */,
  3516. ( extauthtype != NULL ) /* clear external creds. if requested */ );
  3517. /* set primary credentials */
  3518. slapi_ch_free((void**)&conn->c_authtype);
  3519. conn->c_authtype = slapi_ch_strdup(authtype);
  3520. conn->c_dn = normdn;
  3521. conn->c_isroot = slapi_dn_isroot( normdn );
  3522. /* Set the thread data with the normalized dn */
  3523. slapi_td_set_dn(slapi_ch_strdup(normdn));
  3524. /* set external credentials if requested */
  3525. if ( extauthtype != NULL ) {
  3526. conn->c_external_authtype = extauthtype;
  3527. conn->c_external_dn = externaldn;
  3528. conn->c_client_cert = clientcert;
  3529. }
  3530. /* notify binder-based resource limit subsystem about the change in DN */
  3531. if ( !conn->c_isroot )
  3532. {
  3533. if ( conn->c_dn != NULL ) {
  3534. if ( bind_target_entry == NULL )
  3535. {
  3536. Slapi_DN *sdn = slapi_sdn_new_normdn_byref( conn->c_dn );
  3537. reslimit_update_from_dn( conn, sdn );
  3538. slapi_sdn_free( &sdn );
  3539. } else {
  3540. reslimit_update_from_entry( conn, bind_target_entry );
  3541. }
  3542. } else {
  3543. char *anon_dn = config_get_anon_limits_dn();
  3544. /* If an anonymous limits dn is set, use it to set the limits. */
  3545. if (anon_dn && (strlen(anon_dn) > 0)) {
  3546. Slapi_DN *anon_sdn = slapi_sdn_new_normdn_byref( anon_dn );
  3547. reslimit_update_from_dn( conn, anon_sdn );
  3548. slapi_sdn_free( &anon_sdn );
  3549. }
  3550. slapi_ch_free_string( &anon_dn );
  3551. }
  3552. if (slapi_reslimit_get_integer_limit(conn, conn->c_idletimeout_handle,
  3553. &idletimeout)
  3554. != SLAPI_RESLIMIT_STATUS_SUCCESS)
  3555. {
  3556. conn->c_idletimeout = fecfg->idletimeout;
  3557. } else {
  3558. conn->c_idletimeout = idletimeout;
  3559. }
  3560. } else {
  3561. /* For root dn clear about the resource limits */
  3562. reslimit_update_from_entry( conn, NULL );
  3563. conn->c_idletimeout = 0;
  3564. }
  3565. }