pblock.c 107 KB

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