pblock.c 107 KB

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