pblock.c 88 KB

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