pblock.c 87 KB

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