slapi-plugin.h 140 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669
  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. /*! \file slapi-plugin.h
  42. * \brief Public Directory Server plugin interface.
  43. *
  44. * The SLAPI plugin interface allows complex plugins to be created
  45. * for Directory Server.
  46. */
  47. #ifndef _SLAPIPLUGIN
  48. #define _SLAPIPLUGIN
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52. #include "prtypes.h"
  53. #include "ldap.h"
  54. #include "prprf.h"
  55. NSPR_API(PRUint32) PR_snprintf(char *out, PRUint32 outlen, const char *fmt, ...)
  56. #ifdef __GNUC__
  57. __attribute__ ((format (printf, 3, 4)));
  58. #else
  59. ;
  60. #endif
  61. NSPR_API(char*) PR_smprintf(const char *fmt, ...)
  62. #ifdef __GNUC__
  63. __attribute__ ((format (printf, 1, 2)));
  64. #else
  65. ;
  66. #endif
  67. NSPR_API(char*) PR_sprintf_append(char *last, const char *fmt, ...)
  68. #ifdef __GNUC__
  69. __attribute__ ((format (printf, 2, 3)));
  70. #else
  71. ;
  72. #endif
  73. NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...)
  74. #ifdef __GNUC__
  75. __attribute__ ((format (printf, 2, 3)));
  76. #else
  77. ;
  78. #endif
  79. /* NSPR uses the print macros a bit differently than ANSI C. We
  80. * need to use ll for a 64-bit integer, even when a long is 64-bit.
  81. */
  82. #define NSPRIu64 "llu"
  83. #define NSPRI64 "ll"
  84. /*
  85. * The slapi_attr_get_flags() routine returns a bitmap that contains one or
  86. * more of these values.
  87. *
  88. * Note that the flag values 0x0010, 0x0020, 0x4000, and 0x8000 are reserved.
  89. */
  90. #define SLAPI_ATTR_FLAG_SINGLE 0x0001 /* single-valued attribute */
  91. #define SLAPI_ATTR_FLAG_OPATTR 0x0002 /* operational attribute */
  92. #define SLAPI_ATTR_FLAG_READONLY 0x0004 /* read from shipped config file */
  93. #define SLAPI_ATTR_FLAG_STD_ATTR SLAPI_ATTR_FLAG_READONLY /* alias for read only */
  94. #define SLAPI_ATTR_FLAG_OBSOLETE 0x0040 /* an outdated definition */
  95. #define SLAPI_ATTR_FLAG_COLLECTIVE 0x0080 /* collective (not supported) */
  96. #define SLAPI_ATTR_FLAG_NOUSERMOD 0x0100 /* can't be modified over LDAP */
  97. #define SLAPI_ATTR_FLAG_NORMALIZED 0x0200 /* the attr value is normalized */
  98. /* operation flags */
  99. #define SLAPI_OP_FLAG_INTERNAL 0x00020 /* An operation generated by the core server or a plugin. */
  100. #define SLAPI_OP_FLAG_NEVER_CHAIN 0x00800 /* Do not chain the operation */
  101. #define SLAPI_OP_FLAG_NO_ACCESS_CHECK 0x10000 /* Do not check for access control - bypass them */
  102. #define SLAPI_OC_FLAG_REQUIRED 0x0001
  103. #define SLAPI_OC_FLAG_ALLOWED 0x0002
  104. /*
  105. * access control levels
  106. */
  107. #define SLAPI_ACL_COMPARE 0x01
  108. #define SLAPI_ACL_SEARCH 0x02
  109. #define SLAPI_ACL_READ 0x04
  110. #define SLAPI_ACL_WRITE 0x08
  111. #define SLAPI_ACL_DELETE 0x10
  112. #define SLAPI_ACL_ADD 0x20
  113. #define SLAPI_ACL_SELF 0x40
  114. #define SLAPI_ACL_PROXY 0x80
  115. #define SLAPI_ACL_ALL 0x7f
  116. /*
  117. * filter types
  118. * openldap defines these, but not mozldap
  119. */
  120. #ifndef LDAP_FILTER_AND
  121. #define LDAP_FILTER_AND 0xa0L
  122. #endif
  123. #ifndef LDAP_FILTER_OR
  124. #define LDAP_FILTER_OR 0xa1L
  125. #endif
  126. #ifndef LDAP_FILTER_NOT
  127. #define LDAP_FILTER_NOT 0xa2L
  128. #endif
  129. #ifndef LDAP_FILTER_EQUALITY
  130. #define LDAP_FILTER_EQUALITY 0xa3L
  131. #endif
  132. #ifndef LDAP_FILTER_SUBSTRINGS
  133. #define LDAP_FILTER_SUBSTRINGS 0xa4L
  134. #endif
  135. #ifndef LDAP_FILTER_GE
  136. #define LDAP_FILTER_GE 0xa5L
  137. #endif
  138. #ifndef LDAP_FILTER_LE
  139. #define LDAP_FILTER_LE 0xa6L
  140. #endif
  141. #ifndef LDAP_FILTER_PRESENT
  142. #define LDAP_FILTER_PRESENT 0x87L
  143. #endif
  144. #ifndef LDAP_FILTER_APPROX
  145. #define LDAP_FILTER_APPROX 0xa8L
  146. #endif
  147. #ifndef LDAP_FILTER_EXTENDED
  148. #ifdef LDAP_FILTER_EXT
  149. #define LDAP_FILTER_EXTENDED LDAP_FILTER_EXT
  150. #else
  151. #define LDAP_FILTER_EXTENDED 0xa9L
  152. #endif
  153. #endif
  154. #ifndef LBER_END_OF_SEQORSET
  155. #define LBER_END_OF_SEQORSET ((ber_tag_t) -2) /* 0xfffffffeU */
  156. #endif
  157. #ifndef LDAP_CHANGETYPE_ADD
  158. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_ADD
  159. #define LDAP_CHANGETYPE_ADD LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_ADD
  160. #else
  161. #define LDAP_CHANGETYPE_ADD 1
  162. #endif
  163. #endif
  164. #ifndef LDAP_CHANGETYPE_DELETE
  165. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_DELETE
  166. #define LDAP_CHANGETYPE_DELETE LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_DELETE
  167. #else
  168. #define LDAP_CHANGETYPE_DELETE 2
  169. #endif
  170. #endif
  171. #ifndef LDAP_CHANGETYPE_MODIFY
  172. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_MODIFY
  173. #define LDAP_CHANGETYPE_MODIFY LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_MODIFY
  174. #else
  175. #define LDAP_CHANGETYPE_MODIFY 4
  176. #endif
  177. #endif
  178. #ifndef LDAP_CHANGETYPE_MODDN
  179. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_RENAME
  180. #define LDAP_CHANGETYPE_MODDN LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_RENAME
  181. #else
  182. #define LDAP_CHANGETYPE_MODDN 8
  183. #endif
  184. #endif
  185. #ifndef LDAP_CHANGETYPE_ANY
  186. #define LDAP_CHANGETYPE_ANY (1|2|4|8)
  187. #endif
  188. #ifndef LDAP_CONTROL_PERSISTENTSEARCH
  189. #ifdef LDAP_CONTROL_PERSIST_REQUEST
  190. #define LDAP_CONTROL_PERSISTENTSEARCH LDAP_CONTROL_PERSIST_REQUEST
  191. #else
  192. #define LDAP_CONTROL_PERSISTENTSEARCH "2.16.840.1.113730.3.4.3"
  193. #endif
  194. #endif
  195. #ifndef LDAP_CONTROL_ENTRYCHANGE
  196. #ifdef LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE
  197. #define LDAP_CONTROL_ENTRYCHANGE LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE
  198. #else
  199. #define LDAP_CONTROL_ENTRYCHANGE "2.16.840.1.113730.3.4.7"
  200. #endif
  201. #endif
  202. #ifndef LDAP_CONTROL_PWEXPIRED
  203. #define LDAP_CONTROL_PWEXPIRED "2.16.840.1.113730.3.4.4"
  204. #endif
  205. #ifndef LDAP_CONTROL_PWEXPIRING
  206. #define LDAP_CONTROL_PWEXPIRING "2.16.840.1.113730.3.4.5"
  207. #endif
  208. #ifndef LDAP_X_CONTROL_PWPOLICY_REQUEST
  209. #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
  210. #define LDAP_X_CONTROL_PWPOLICY_REQUEST LDAP_CONTROL_PASSWORDPOLICYREQUEST
  211. #else
  212. #define LDAP_X_CONTROL_PWPOLICY_REQUEST "1.3.6.1.4.1.42.2.27.8.5.1"
  213. #endif
  214. #endif
  215. #ifndef LDAP_X_CONTROL_PWPOLICY_RESPONSE
  216. #ifdef LDAP_CONTROL_PASSWORDPOLICYRESPONSE
  217. #define LDAP_X_CONTROL_PWPOLICY_RESPONSE LDAP_CONTROL_PASSWORDPOLICYRESPONSE
  218. #else
  219. #define LDAP_X_CONTROL_PWPOLICY_RESPONSE "1.3.6.1.4.1.42.2.27.8.5.1"
  220. #endif
  221. #endif
  222. #ifndef LDAP_CONTROL_PROXYAUTH
  223. #define LDAP_CONTROL_PROXYAUTH "2.16.840.1.113730.3.4.12" /* version 1 */
  224. #endif
  225. #ifndef LDAP_CONTROL_PROXIEDAUTH
  226. #ifdef LDAP_CONTROL_PROXY_AUTHZ
  227. #define LDAP_CONTROL_PROXIEDAUTH LDAP_CONTROL_PROXY_AUTHZ
  228. #else
  229. #define LDAP_CONTROL_PROXIEDAUTH "2.16.840.1.113730.3.4.18" /* version 2 */
  230. #endif
  231. #endif
  232. #ifndef LDAP_CONTROL_AUTH_REQUEST
  233. #define LDAP_CONTROL_AUTH_REQUEST "2.16.840.1.113730.3.4.16"
  234. #endif
  235. #ifndef LDAP_SORT_CONTROL_MISSING
  236. #define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 (server side sort extn) */
  237. #endif
  238. #ifndef LDAP_INDEX_RANGE_ERROR
  239. #define LDAP_INDEX_RANGE_ERROR 0x3D /* 61 (VLV extn) */
  240. #endif
  241. /* openldap does not use this */
  242. #ifndef LBER_OVERFLOW
  243. #define LBER_OVERFLOW ((ber_tag_t) -3) /* 0xfffffffdU */
  244. #endif
  245. /*
  246. * Sequential access types
  247. */
  248. #define SLAPI_SEQ_FIRST 1
  249. #define SLAPI_SEQ_LAST 2
  250. #define SLAPI_SEQ_PREV 3
  251. #define SLAPI_SEQ_NEXT 4
  252. /*
  253. * return codes from a backend API call
  254. */
  255. #define SLAPI_FAIL_GENERAL -1
  256. #define SLAPI_FAIL_DISKFULL -2
  257. /*
  258. * return codes used by BIND functions
  259. */
  260. #define SLAPI_BIND_SUCCESS 0 /* front end will send result */
  261. #define SLAPI_BIND_FAIL 2 /* back end should send result */
  262. #define SLAPI_BIND_ANONYMOUS 3 /* front end will send result */
  263. /* commonly used attributes names */
  264. #define SLAPI_ATTR_UNIQUEID "nsuniqueid"
  265. #define SLAPI_ATTR_OBJECTCLASS "objectclass"
  266. #define SLAPI_ATTR_VALUE_TOMBSTONE "nsTombstone"
  267. #define SLAPI_ATTR_VALUE_PARENT_UNIQUEID "nsParentUniqueID"
  268. #define SLAPI_ATTR_NSCP_ENTRYDN "nscpEntryDN"
  269. #define SLAPI_ATTR_ENTRYUSN "entryusn"
  270. #define SLAPI_ATTR_ENTRYUSN_PREV "preventryusn"
  271. /* opaque structures */
  272. /**
  273. * Contains name-value pairs, known as parameter blocks, that you can get or set for
  274. * each LDAP operation.
  275. *
  276. * #Slapi_PBlock contains name-value pairs that you can use to retrieve information
  277. * from the server and set information to be used by the server.
  278. *
  279. * For most types of plug-in functions, the server passes in a #Slapi_PBlock
  280. * structure that typically includes data relevant to the operation being processed.
  281. * You can get the value of a parameter by calling the slapi_pblock_get() function.
  282. *
  283. * For example, when the plug-in function for an LDAP bind operation is called, the
  284. * server puts the DN and credentials in the #SLAPI_BIND_TARGET and
  285. * #SLAPI_BIND_CREDENTIALS parameters of the Slapi_PBlock structure. You can
  286. * call slapi_pblock_get() to get the DN and credentials of the client requesting
  287. * authentication.
  288. *
  289. * For plug-in initialization functions, you can use the #Slapi_PBlock structure to
  290. * pass information to the server, such as the description of your plug-in and the
  291. * names of your plug-in functions. You can set the value of a parameter by calling
  292. * the slapi_pblock_set() function.
  293. *
  294. * For example, in order to register a pre-operation bind plug-in function, you need to
  295. * call slapi_pblock_set() to set the version number, description, and name of the
  296. * plug-in function as the #SLAPI_PLUGIN_VERSION, #SLAPI_PLUGIN_DESCRIPTION,
  297. * and #SLAPI_PLUGIN_PRE_BIND_FN parameters.
  298. *
  299. * The available parameters that you can use depends on the type of plug-in function
  300. * you are writing.
  301. */
  302. typedef struct slapi_pblock Slapi_PBlock;
  303. /**
  304. * Represents an entry in the directory.
  305. *
  306. * #Slapi_Entry is the data type for an opaque structure that represents an entry in
  307. * the directory. In certain cases, your server plug-in may need to work with an entry
  308. * in the directory.
  309. */
  310. typedef struct slapi_entry Slapi_Entry;
  311. /**
  312. * Represents an attribute in an entry.
  313. *
  314. * #Slapi_Attr is the data type for an opaque structure that represents an attribute
  315. * in a directory entry. In certain cases, your server plug-in may need to work with
  316. * an entry’s attributes.
  317. */
  318. typedef struct slapi_attr Slapi_Attr;
  319. /**
  320. * Represents the value of the attribute in a directory entry.
  321. *
  322. * #Slapi_Value is the data type for an opaque structure that represents the value of
  323. * an attribute in a directory entry.
  324. */
  325. typedef struct slapi_value Slapi_Value;
  326. /**
  327. * Represents a set of Slapi_Value (or a list of Slapi_Value).
  328. *
  329. * #Slapi_ValueSet is the data type for an opaque structure that represents set of
  330. * #Slapi_Value (or a list of #Slapi_Value).
  331. */
  332. typedef struct slapi_value_set Slapi_ValueSet;
  333. /**
  334. * Represents a search filter.
  335. *
  336. * #Slapi_Filter is the data type for an opaque structure that represents an search
  337. * filter.
  338. */
  339. typedef struct slapi_filter Slapi_Filter;
  340. /**
  341. * Represents a backend operation in the server plug-in.
  342. *
  343. * #Slapi_Backend is the data type for an opaque structure that represents a backend
  344. * operation.
  345. */
  346. typedef struct backend Slapi_Backend;
  347. /**
  348. * Represents the unique identifier of a directory entry.
  349. *
  350. * #Slapi_UniqueID is the data type for an opaque structure that represents the
  351. * unique identifier of a directory entry. All directory entries contain a unique
  352. * identifier. Unlike the distinguished name (DN), the unique identifier of an entry
  353. * never changes, providing a good way to refer unambiguously to an entry in a
  354. * distributed/replicated environment.
  355. */
  356. typedef struct _guid_t Slapi_UniqueID;
  357. /**
  358. * Represents an operation pending from an LDAP client.
  359. *
  360. * #Slapi_Operation is the data type for an opaque structure that represents an
  361. * operation pending from an LDAP client.
  362. */
  363. typedef struct op Slapi_Operation;
  364. /**
  365. * Represents a connection.
  366. *
  367. * #Slapi_Connection is the data type for an opaque structure that represents a
  368. * connection.
  369. */
  370. typedef struct conn Slapi_Connection;
  371. /**
  372. * Represents a distinguished name in a directory entry.
  373. *
  374. * #Slapi_DN is the data type for an opaque structure that represents a distinguished
  375. * name in the server plug-in.
  376. */
  377. typedef struct slapi_dn Slapi_DN;
  378. /**
  379. * Represents a relative distinguished name in a directory entry.
  380. *
  381. * #Slapi_RDN is the data type for an opaque structure that represents a relative
  382. * distinguished name in the server plug-in.
  383. */
  384. typedef struct slapi_rdn Slapi_RDN;
  385. /**
  386. * Represents a single LDAP modification to a directory entry.
  387. *
  388. * #Slapi_Mod is the data type for an opaque structure that represents LDAPMod
  389. * modifications to an attribute in a directory entry.
  390. */
  391. typedef struct slapi_mod Slapi_Mod;
  392. /**
  393. * Represents two or more LDAP modifications to a directory entry
  394. *
  395. * #Slapi_Mods is the data type for an opaque structure that represents LDAPMod
  396. * manipulations that can be made to a directory entry.
  397. */
  398. typedef struct slapi_mods Slapi_Mods;
  399. /**
  400. * Represents a the component ID in a directory entry.
  401. *
  402. * #Slapi_ComponentId is the data type for an opaque structure that represents the
  403. * component ID in a directory entry.
  404. */
  405. typedef struct slapi_componentid Slapi_ComponentId;
  406. /**
  407. * Represents an integral counter.
  408. *
  409. * Provides 64-bit integers with support for atomic operations, even on 32-bit
  410. * systems. This lets your plug-in have global integers that can be updated by
  411. * multiple worker threads in a thread-safe manner.
  412. *
  413. * The #Slapi_Counter structure is a wrapper around the actual counter value
  414. */
  415. typedef struct slapi_counter Slapi_Counter;
  416. /* Online tasks interface (to support import, export, etc) */
  417. #define SLAPI_TASK_PUBLIC 1 /* tell old plugins that the task api is now public */
  418. /**
  419. * An opaque structure that represents a task that has been initiated.
  420. *
  421. * Common Directory Server tasks, including importing, exporting, and indexing
  422. * databases, can be initiated through a special task configuration entry in
  423. * cn=tasks,cn=config. These task operations are managed using the #Slapi_Task
  424. * structure.
  425. */
  426. typedef struct slapi_task Slapi_Task;
  427. /**
  428. * Defines a callback used specifically by Slapi_Task structure cancel and
  429. * destructor functions.
  430. *
  431. * \param task The task that is being cancelled or destroyed.
  432. */
  433. typedef void (*TaskCallbackFn)(Slapi_Task *task);
  434. /*
  435. * The default thread stacksize for nspr21 is 64k (except on IRIX! It's 32k!).
  436. * For OSF, we require a larger stacksize as actual storage allocation is
  437. * higher i.e pointers are allocated 8 bytes but lower 4 bytes are used.
  438. * The value 0 means use the default stacksize.
  439. *
  440. * larger stacksize (256KB) is needed on IRIX due to its 4KB BUFSIZ.
  441. * (@ pthread IRIX porting -- 01/11/99)
  442. *
  443. * Don't know why HP was defined as follows up until DS6.1x. HP BUFSIZ is 1KB
  444. #elif ( defined( hpux ))
  445. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  446. */
  447. #if ( defined( irix ))
  448. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  449. #elif ( defined ( OSF1 ))
  450. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  451. #elif ( defined ( AIX ))
  452. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  453. /* All other platforms use the default stack size */
  454. #else
  455. #define SLAPD_DEFAULT_THREAD_STACKSIZE 0
  456. #endif
  457. /*---------------------------
  458. * parameter block routines
  459. *--------------------------*/
  460. /**
  461. * Creates a new parameter block.
  462. *
  463. * \return This function returns a pointer to the new parameter block.
  464. * \warning The pblock pointer allocated with this function must always be freed by
  465. * slapi_pblock_destroy(). The use of other memory deallocators (for example,
  466. * <tt>free()</tt>) is not supported and may lead to crashes or memory leaks.
  467. * \see slapi_pblock_destroy()
  468. */
  469. Slapi_PBlock *slapi_pblock_new( void ); /* allocate and initialize */
  470. /**
  471. * Initializes an existing parameter block for re-use.
  472. *
  473. * \param pb The parameter block to initialize.
  474. * \warning The parameter block that you wish to free must have been created using
  475. * slapi_pblock_new(). When you are finished with the parameter block, you
  476. * must free it using the slapi_pblock_destroy() function.
  477. *
  478. * \warning Note that search results will not be freed from the parameter block by
  479. * slapi_pblock_init(). You must free any internal search results with the
  480. * slapi_free_search_results_internal() function prior to calling
  481. * slapi_pblock_init(), otherwise the search results will be leaked.
  482. * \see slapi_pblock_new()
  483. * \see slapi_pblock_destroy()
  484. * \see slapi_free_search_results_internal()
  485. */
  486. void slapi_pblock_init( Slapi_PBlock *pb ); /* clear out for re-use */
  487. /**
  488. * Gets the value of a name-value pair from a parameter block.
  489. *
  490. * \param pb Parameter block.
  491. * \param arg ID of the name-value pair that you want to get.
  492. * \param value Pointer to the value retrieved from the parameter block.
  493. * \return \c 0 if successful.
  494. * \return \c -1 if an error occurs (for example, if an invalid ID is specified).
  495. * \todo Document valid values for the ID.
  496. * \warning The <tt>void *value</tt> argument should always be a pointer to the
  497. * type of value you are retrieving:
  498. * \code
  499. * int connid = 0;
  500. * ...
  501. * retval = slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
  502. * \endcode
  503. *
  504. * \warning #SLAPI_CONN_ID is an integer value, so you will pass in a pointer
  505. * to/address of an integer to get the value. Similarly, for a
  506. * <tt>char *</tt> value (a string), pass in a pointer to/address of the value.
  507. * For example:
  508. * \code
  509. * char *binddn = NULL;
  510. * ...
  511. * retval = slapi_pblock_get(pb, SLAPI_CONN_DN, &binddn);
  512. * \endcode
  513. *
  514. * \warning With certain compilers on some platforms, you may have to cast the
  515. * value to <tt>(void *)</tt>.
  516. *
  517. * \warning We recommend that you set the value to \c 0 or \c NULL before calling
  518. * slapi_pblock_get() to avoid reading from uninitialized memory, in
  519. * case the call to slapi_pblock_get() fails.
  520. *
  521. * \warning In most instances, the caller should not free the returned value.
  522. * The value will usually be freed internally or through the call to
  523. * slapi_pblock_destroy(). The exception is if the value is explicitly
  524. * set by the caller through slapi_pblock_set(). In this case, the caller
  525. * is responsible for memory management. If the value is freed, it is
  526. * strongly recommended that the free is followed by a call to
  527. * slapi_pblock_set() with a value of \c NULL. For example:
  528. * \code
  529. * char *someparam = NULL;
  530. * ...
  531. * someparam = slapi_ch_strdup(somestring);
  532. * slapi_pblock_set(pb, SOME_PARAM, someparam);
  533. * someparam = NULL;
  534. * ...
  535. * slapi_pblock_get(pb, SOME_PARAM, &someparam);
  536. * slapi_pblock_set(pb, SOME_PARAM, NULL);
  537. * slapi_ch_free_string(&someparam);
  538. * ...
  539. * \endcode
  540. *
  541. * \warning Some internal functions may change the value passed in, so it is
  542. * recommended to use slapi_pblock_get() to retrieve the value again,
  543. * rather than relying on a potential dangling pointer. This is shown
  544. * in the example above, which sets someparam to \c NULL after setting
  545. * it in the pblock.
  546. *
  547. * \see slapi_pblock_destroy()
  548. * \see slapi_pblock_set()
  549. */
  550. int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value );
  551. /**
  552. * Sets the value of a name-value pair in a parameter block.
  553. *
  554. * \param pb Parameter block.
  555. * \param arg ID of the name-value pair that you want to get.
  556. * \param value Pointer to the value you want to set in the parameter block.
  557. * \return \c 0 if successful.
  558. * \return \c -1 if an error occurs (for example, if an invalid ID is specified).
  559. * \warning The value to be passed in must always be a pointer, even for integer
  560. * arguments. For example, if you wanted to do a search with the
  561. * \c ManageDSAIT control:
  562. * \code
  563. * int managedsait = 1;
  564. * ...
  565. * slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, &managedsait);
  566. * \endcode
  567. *
  568. * \warning A call similar to the following example will cause a crash:
  569. * \code
  570. * slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, 1);
  571. * \endcode
  572. *
  573. * \warning However, for values which are already pointers, (<tt>char * string</tt>,
  574. * <tt>char **arrays</tt>, <tt>#Slapi_Backend *</tt>, etc.), you can pass
  575. * in the value directly. For example:
  576. * \code
  577. * char *target_dn = slapi_ch_strdup(some_dn);
  578. * slapi_pblock_set(pb, SLAPI_TARGET_DN, target_dn);
  579. * \endcode
  580. *
  581. * \warning or
  582. * \code
  583. * slapi_pblock_set(pb, SLAPI_TARGET_DN, NULL);
  584. * \endcode
  585. *
  586. * \warning With some compilers, you will have to cast the value argument to
  587. * <tt>(void *)</tt>. If the caller allocates the memory passed in, the
  588. * caller is responsible for freeing that memory. Also, it is recommended
  589. * to use slapi_pblock_get() to retrieve the value to free, rather than
  590. * relying on a potentially dangling pointer. See the slapi_pblock_get()
  591. * example for more details.
  592. *
  593. * \warning When setting parameters to register a plug-in, the plug-in type must
  594. * always be set first, since many of the plug-in parameters depend on
  595. * the type. For example, set the #SLAPI_PLUGIN_TYPE to extended
  596. * operation before setting the list of extended operation OIDs for
  597. * the plug-in.
  598. *
  599. * \see slapi_pblock_get()
  600. */
  601. int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value );
  602. /**
  603. * Frees the specified parameter block from memory.
  604. *
  605. * \param pb Parameter block you want to free.
  606. * \warning The parameter block that you wish to free must have been created
  607. * using slapi_pblock_new(). Use of this function with parameter
  608. * blocks allocated on the stack (for example, <tt>#Slapi_PBlock pb;</tt>)
  609. * or using another memory allocator is not supported and may lead to
  610. * memory errors and memory leaks. For example:
  611. * \code
  612. * Slapi_PBlock *pb = malloc(sizeof(Slapi_PBlock));
  613. * \endcode
  614. *
  615. * \warning After calling this function, you should set the parameter block
  616. * pointer to \c NULL to avoid reusing freed memory in your function
  617. * context, as in the following:
  618. * \code
  619. * slapi_pblock_destroy(pb);
  620. * pb =NULL;
  621. * \endcode
  622. *
  623. * \warning If you reuse the pointer in this way, it makes it easier to
  624. * identify a Segmentation Fault, rather than using some difficult
  625. * method to detect memory leaks or other abnormal behavior.
  626. *
  627. * \warning It is safe to call this function with a \c NULL pointer. For
  628. * example:
  629. * \code
  630. * Slapi_PBlock *pb = NULL;
  631. * slapi_pblock_destroy(pb);
  632. * \endcode
  633. *
  634. * \warning This saves the trouble of checking for \c NULL before calling
  635. * slapi_pblock_destroy().
  636. *
  637. * \see slapi_pblock_new()
  638. */
  639. void slapi_pblock_destroy( Slapi_PBlock *pb );
  640. /*----------------
  641. * entry routines
  642. *---------------*/
  643. /**
  644. * Converts an LDIF description of a directory entry (a string value) into
  645. * an entry of the #Slapi_Entry type.
  646. *
  647. * A directory entry can be described by a string in LDIF format. Calling
  648. * the slapi_str2entry() function converts a string description in this
  649. * format to a #Slapi_Entry structure, which you can pass to other API
  650. * functions.
  651. *
  652. * \param s Description of an entry that you want to convert to a #Slapi_Entry.
  653. * \param flags One or more flags specifying how the entry should be generated.
  654. * The valid values of the \c flags argument are:
  655. * \arg #SLAPI_STR2ENTRY_REMOVEDUPVALS
  656. * \arg #SLAPI_STR2ENTRY_ADDRDNVALS
  657. * \arg #SLAPI_STR2ENTRY_BIGENTRY
  658. * \arg #SLAPI_STR2ENTRY_TOMBSTONE_CHECK
  659. * \arg #SLAPI_STR2ENTRY_IGNORE_STATE
  660. * \arg #SLAPI_STR2ENTRY_INCLUDE_VERSION_STR
  661. * \arg #SLAPI_STR2ENTRY_EXPAND_OBJECTCLASSES
  662. * \arg #SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF
  663. * \arg #SLAPI_STR2ENTRY_NO_SCHEMA_LOCK
  664. * \return A pointer to the #Slapi_Entry structure representing the entry.
  665. * \return \c NULL if the string cannot be converted; for example, if no DN is
  666. * specified in the string.
  667. * \warning This function modifies the string argument s. If you still need to
  668. * use this string value, you should make a copy of this string before
  669. * calling slapi_str2entry().
  670. *
  671. * \warning When you are done working with the entry, you should call the
  672. * slapi_entry_free() function.
  673. *
  674. * \note To convert an entry to a string description, call the slapi_entry2str()
  675. * function.
  676. *
  677. * \see slapi_entry_free()
  678. * \see slapi_entry2str()
  679. */
  680. Slapi_Entry *slapi_str2entry( char *s, int flags );
  681. /*-----------------------------
  682. * Flags for slapi_str2entry()
  683. *----------------------------*/
  684. /**
  685. * Removes any duplicate values in the attributes of the entry.
  686. *
  687. * \see slapi_str2entry()
  688. */
  689. #define SLAPI_STR2ENTRY_REMOVEDUPVALS 1
  690. /**
  691. * Adds the relative distinguished name (RDN) components (for example,
  692. * \c uid=bjensen) as attributes of the entry.
  693. *
  694. * \see slapi_str2entry()
  695. */
  696. #define SLAPI_STR2ENTRY_ADDRDNVALS 2
  697. /**
  698. * Provide a hint that the entry is large. This enables some optimizations
  699. * related to large entries.
  700. *
  701. * \see slapi_str2entry()
  702. */
  703. #define SLAPI_STR2ENTRY_BIGENTRY 4
  704. /**
  705. * Check to see if the entry is a tombstone. If so, set the tombstone flag
  706. * (#SLAPI_ENTRY_FLAG_TOMBSTONE).
  707. *
  708. * \see slapi_str2entry()
  709. */
  710. #define SLAPI_STR2ENTRY_TOMBSTONE_CHECK 8
  711. /**
  712. * Ignore entry state information if present.
  713. *
  714. * \see slapi_str2entry()
  715. */
  716. #define SLAPI_STR2ENTRY_IGNORE_STATE 16
  717. /**
  718. * Return entries that have a <tt>version: 1</tt> line as part of the LDIF
  719. * representation.
  720. *
  721. * \see slapi_str2entry()
  722. */
  723. #define SLAPI_STR2ENTRY_INCLUDE_VERSION_STR 32
  724. /**
  725. * Add any missing ancestor values based on the object class hierarchy.
  726. *
  727. * \see slapi_str2entry()
  728. */
  729. #define SLAPI_STR2ENTRY_EXPAND_OBJECTCLASSES 64
  730. /**
  731. * Inform slapi_str2entry() that the LDIF input is not well formed.
  732. *
  733. * Well formed LDIF has no duplicate attribute values, already has the RDN
  734. * as an attribute of the entry, and has all values for a given attribute
  735. * type listed contiguously.
  736. *
  737. * \see slapi_str2entry()
  738. */
  739. #define SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF 128
  740. /**
  741. * Don't acquire the schema lock.
  742. *
  743. * You should use this flag if you are sure that the lock is already held,
  744. * or if the server has not started it's threads yet during startup.
  745. *
  746. * \see slapi_str2entry()
  747. */
  748. #define SLAPI_STR2ENTRY_NO_SCHEMA_LOCK 256
  749. /**
  750. * Generates a description of an entry as an LDIF string.
  751. *
  752. * This function behaves much like slapi_entry2str(); however, you can specify
  753. * output options with this function.
  754. *
  755. * This function generates an LDIF string value conforming to the following syntax:
  756. * \code
  757. * dn: dn\n
  758. * [attr: value\n]*
  759. * \endcode
  760. *
  761. * For example:
  762. * \code
  763. * dn: uid=jdoe, ou=People, dc=example,dc=com
  764. * cn: Jane Doe
  765. * sn: Doe
  766. * ...
  767. * \endcode
  768. *
  769. * To convert an entry described in LDIF string format to an LDAP entry using
  770. * the #Slapi_Entry data type, call the slapi_str2entry() function.
  771. *
  772. * \param e Entry that you want to convert into an LDIF string.
  773. * \param len Length of the LDIF string returned by this function.
  774. * \param options An option set that specifies how you want the string
  775. * converted. You can \c OR together any of the following options
  776. * when you call this function:
  777. * \arg #SLAPI_DUMP_STATEINFO
  778. * \arg #SLAPI_DUMP_UNIQUEID
  779. * \arg #SLAPI_DUMP_NOOPATTRS
  780. * \arg #SLAPI_DUMP_NOWRAP
  781. * \arg #SLAPI_DUMP_MINIMAL_ENCODING
  782. * \return The LDIF string representation of the entry you specify.
  783. * \return \c NULL if an error occurs.
  784. * \warning When you no longer need to use the string, you should free it
  785. * from memory by calling the slapi_ch_free_string() function.
  786. *
  787. * \see slapi_entry2str()
  788. * \see slapi_str2entry()
  789. */
  790. char *slapi_entry2str_with_options( Slapi_Entry *e, int *len, int options );
  791. /*---------------------------------------------
  792. * Options for slapi_entry2str_with_options()
  793. *--------------------------------------------*/
  794. /**
  795. * Output entry with replication state info.
  796. *
  797. * This allows access to the internal data used by multi-master replication.
  798. *
  799. * \see slapi_entry2str_with_options()
  800. */
  801. #define SLAPI_DUMP_STATEINFO 1 /* replication state */
  802. /**
  803. * Output entry with uniqueid.
  804. *
  805. * This option is used when creating an LDIF file to be used to initialize
  806. * a replica. Each entry will contain the nsuniqueID operational attribute.
  807. *
  808. * \see slapi_entry2str_with_options()
  809. */
  810. #define SLAPI_DUMP_UNIQUEID 2 /* unique ID */
  811. /**
  812. * Output entry without operational attributes.
  813. *
  814. * By default, certain operational attributes (such as \c creatorsName,
  815. * \c modifiersName, \c createTimestamp, \c modifyTimestamp) may be
  816. * included in the output. With this option, no operational attributes
  817. * will be included.
  818. *
  819. * \see slapi_entry2str_with_options()
  820. */
  821. #define SLAPI_DUMP_NOOPATTRS 4 /* suppress operational attrs */
  822. /**
  823. * Output entry without LDIF line wrapping.
  824. *
  825. * By default, lines will be wrapped as defined in the LDIF specification.
  826. * With this option, line wrapping is disabled.
  827. *
  828. * \see slapi_entry2str_with_options()
  829. */
  830. #define SLAPI_DUMP_NOWRAP 8 /* no line breaks */
  831. /**
  832. * Output entry with less base64 encoding.
  833. *
  834. * Uses as little base64 encoding as possible in the output.
  835. *
  836. * \see slapi_entry2str_with_options()
  837. */
  838. #define SLAPI_DUMP_MINIMAL_ENCODING 16 /* use less base64 encoding */
  839. /**
  840. * Generates an LDIF string description of an LDAP entry.
  841. *
  842. * This function generates an LDIF string value conforming to the following syntax:
  843. * \code
  844. * dn: dn\n
  845. * [attr: value\n]*
  846. * \endcode
  847. *
  848. * For example:
  849. * \code
  850. * dn: uid=jdoe, ou=People, dc=example,dc=com
  851. * cn: Jane Doe
  852. * sn: Doe
  853. * ...
  854. * \endcode
  855. *
  856. * To convert an entry described in LDIF string format to an LDAP entry using
  857. * the #Slapi_Entry data type, call the slapi_str2entry() function.
  858. *
  859. * \param e Entry that you want to convert into an LDIF string.
  860. * \param len Length of the LDIF string returned by this function.
  861. * \return The LDIF string representation of the entry you specify.
  862. * \return \c NULL if an error occurs.
  863. * \warning When you no longer need to use the string, you should free it
  864. * from memory by calling the slapi_ch_free_string() function.
  865. *
  866. * \see slapi_entry2str_with_options()
  867. * \see slapi_str2entry()
  868. */
  869. char *slapi_entry2str( Slapi_Entry *e, int *len );
  870. /**
  871. * Allocates memory for a new entry of the data type #Slapi_Entry.
  872. *
  873. * This function returns an empty #Slapi_Entry structure. You can call other
  874. * front-end functions to set the DN and attributes of this entry.
  875. *
  876. * When you are no longer using the entry, you should free it from memory by
  877. * calling the slapi_entry_free() function.
  878. *
  879. * \return This function returns a pointer to the newly allocated entry of the
  880. * data type #Slapi_Entry. If space cannot be allocated, e.g., no more
  881. * virtual memory exists, the \c ns-slapd program terminates.
  882. * \warning When you no longer use the entry, free it from memory by calling the
  883. * slapi_entry_free() function.
  884. *
  885. * \see slapi_entry_dup()
  886. * \see slapi_entry_free()
  887. */
  888. Slapi_Entry *slapi_entry_alloc(void);
  889. /**
  890. * Initializes the values of an entry with the DN and attribute value pairs you
  891. * supply.
  892. *
  893. * This function initializes the attributes and the corresponding attribute values
  894. * of an entry. Also, during the course of processing, the unique ID of the entry
  895. * is set to \c NULL, and the flag value is set to \c 0.
  896. *
  897. * Use this function to initialize a #Slapi_Entry pointer.
  898. *
  899. * \param e The entry you want to initialize.
  900. * \param dn The DN of the entry you are initializing.
  901. * \param a Initialization list of attribute value pairs, supplied as a
  902. * #Slapi_Attr data value.
  903. * \warning This function should always be used after slapi_entry_alloc() and
  904. * never otherwise. For example:
  905. * \code
  906. * Slapi_Entry *e = slapi_entry_alloc();
  907. * slapi_entry_init(e, NULL, NULL);
  908. * \endcode
  909. *
  910. * \warning To set the DN in the entry:
  911. * \code
  912. * slapi_sdn_set_dn_passin(slapi_entry_get_sdn(e), dn);
  913. * \endcode
  914. *
  915. * \warning In this case, the dn argument is not copied but is consumed by the
  916. * function. To copy the argument, see the following example:
  917. * \code
  918. * char *dn = slapi_ch_strdup(some_dn);
  919. * Slapi_Entry *e = slapi_entry_alloc();
  920. * slapi_entry_init(e, dn, NULL);
  921. * \endcode
  922. *
  923. * \warning The \c dn argument is not freed in this context but will eventually
  924. * be freed when slapi_entry_free() is called.
  925. *
  926. * \see slapi_entry_free()
  927. * \see slapi_entry_alloc()
  928. */
  929. void slapi_entry_init(Slapi_Entry *e, char *dn, Slapi_Attr *a);
  930. /**
  931. * Frees an entry, its DN, and its attributes from memory.
  932. *
  933. * Call this function to free an entry that you have allocated by using the
  934. * slapi_entry_alloc() function or the slapi_entry_dup() function.
  935. *
  936. * \param e Entry that you want to free. If \c NULL, no action occurs.
  937. * \warning To free entries, always use this function instead of using
  938. * slapi_ch_free() or free().
  939. *
  940. * \see slapi_entry_alloc()
  941. * \see slapi_entry_dup()
  942. */
  943. void slapi_entry_free( Slapi_Entry *e );
  944. /**
  945. * Makes a copy of an entry, its DN, and its attributes.
  946. *
  947. * This function returns a copy of an existing #Slapi_Entry structure. You can
  948. * call other front-end functions to change the DN and attributes of this entry.
  949. *
  950. * \param e Entry that you want to copy.
  951. * \return This function returns the new copy of the entry. If the structure
  952. * cannot be duplicated, for example, if no more virtual memory exists,
  953. * the \c ns-slapd program terminates.
  954. * \warning When you are no longer using the entry, free it from memory by
  955. * calling the slapi_entry_free() function.
  956. * \see slapi_entry_alloc()
  957. * \see slapi_entry_free()
  958. */
  959. Slapi_Entry *slapi_entry_dup( const Slapi_Entry *e );
  960. /**
  961. * Gets the distinguished name (DN) of the specified entry.
  962. *
  963. * \param e Entry from which you want to get the DN.
  964. * \return This function returns the DN of the entry. This returns a pointer
  965. * to the actual DN in the entry, not a copy of the DN. You should not
  966. * free the DN unless you plan to replace it by calling slapi_entry_set_dn().
  967. * \warning Use slapi_ch_free_string() if you are replacing the DN with
  968. * slapi_entry_set_dn().
  969. * \see slapi_ch_free_string()
  970. * \see slapi_entry_set_dn()
  971. */
  972. char *slapi_entry_get_dn( Slapi_Entry *e );
  973. /**
  974. * Returns the normalized DN from the entry that you specify.
  975. *
  976. * \param e Entry from which you want to obtain the normalized DN.
  977. * \return This function returns the normalized DN from the entry that you
  978. * specify. If the entry you specify does not contain a normalized DN,
  979. * one is created through the processing of this function.
  980. * \warning Never free the returned value.
  981. * \see slapi_entry_get_dn()
  982. */
  983. char *slapi_entry_get_ndn( Slapi_Entry *e );
  984. /**
  985. * Returns as a \c const the value of the #Slapi_DN object from the entry
  986. * that you specify.
  987. *
  988. * \param e Entry from which you want to get the #Slapi_DN object.
  989. * \return Returns as a \c const the #Slapi_DN object from the entry that you
  990. * specify.
  991. * \warning Never free the returned value. If you need a copy, use
  992. * slapi_sdn_dup().
  993. * \see slapi_sdn_dup()
  994. * \see slapi_entry_get_sdn()
  995. */
  996. const Slapi_DN *slapi_entry_get_sdn_const( const Slapi_Entry *e );
  997. /**
  998. * Returns the #Slapi_DN object from the entry that you specify.
  999. *
  1000. * \param e Entry from which you want to get the #Slapi_DN object.
  1001. * \return Returns the #Slapi_DN object from the entry that you specify.
  1002. * \warning Never free the returned value. If you need a copy, use
  1003. * slapi_sdn_dup().
  1004. * \see slapi_entry_get_sdn_const()
  1005. * \see slapi_sdn_dup()
  1006. */
  1007. Slapi_DN *slapi_entry_get_sdn( Slapi_Entry *e );
  1008. /**
  1009. * Returns as a \c const the DN value of the entry that you specify.
  1010. *
  1011. * \param e Entry from which you want to get the DN as a constant.
  1012. * \return This function returns one of the following values:
  1013. * \arg The DN of the entry that you specify. The DN is returned
  1014. * as a const; you are not able to modify the DN value.
  1015. * \arg The NDN value of Slapi_DN if the DN of the Slapi_DN object is NULL.
  1016. * \warning Never free the returned value.
  1017. * \see slapi_entry_set_sdn()
  1018. */
  1019. const char *slapi_entry_get_dn_const( const Slapi_Entry *e );
  1020. /**
  1021. * Sets the distinguished name (DN) of an entry.
  1022. *
  1023. * This function sets the DN pointer in the specified entry to the DN that you supply.
  1024. *
  1025. * \param e Entry to which you want to assign the DN.
  1026. * \param dn Distinguished name you want assigned to the entry.
  1027. * \warning The dn will be freed eventually when slapi_entry_free() is called.
  1028. * \warning A copy of dn should be passed. For example:
  1029. * \code
  1030. * char *dn = slapi_ch_strdup(some_dn):
  1031. * slapi_entry_set_dn(e, dn);
  1032. * \endcode
  1033. *
  1034. * \warning The old dn will be freed as a result of this call. Do not pass in
  1035. * a \c NULL value.
  1036. * \see slapi_entry_free()
  1037. * \see slapi_entry_get_dn()
  1038. */
  1039. void slapi_entry_set_dn( Slapi_Entry *e, char *dn );
  1040. /**
  1041. * Sets the Slapi_DN value in an entry.
  1042. *
  1043. * This function sets the value for the #Slapi_DN object in the entry you specify.
  1044. *
  1045. * \param e Entry to which you want to set the value of the #Slapi_DN.
  1046. * \param sdn The specified #Slapi_DN value that you want to set.
  1047. * \warning This function makes a copy of the \c sdn parameter.
  1048. * \see slapi_entry_get_sdn()
  1049. */
  1050. void slapi_entry_set_sdn( Slapi_Entry *e, const Slapi_DN *sdn );
  1051. /**
  1052. * Determines if an entry contains the specified attribute.
  1053. *
  1054. * If the entry contains the attribute, the function returns a pointer to
  1055. * the attribute.
  1056. *
  1057. * \param e Entry that you want to check.
  1058. * \param type Name of the attribute that you want to check.
  1059. * \param attr Pointer to the attribute, if the attribute is found in the
  1060. * entry.
  1061. * \return \c 0 if the entry contains the specified attribute.
  1062. * \return \c -1 if the entry does not contain the specified attribute.
  1063. * \warning Do not free the returned \c attr. It is a pointer to the internal
  1064. * entry data structure. It is usually wise to make a copy of the
  1065. * returned attribute, using slapi_attr_dup(), to avoid dangling pointers
  1066. * if the entry is freed while the pointer to attr is still being used.
  1067. * \see slapi_attr_dup()
  1068. */
  1069. int slapi_entry_attr_find( const Slapi_Entry *e, const char *type, Slapi_Attr **attr );
  1070. /**
  1071. * Finds the first attribute in an entry.
  1072. *
  1073. * If you want to iterate through the attributes in an entry, use this function
  1074. * in conjunction with the slapi_entry_next_attr() function.
  1075. *
  1076. * \param e Entry from which you want to get the attribute.
  1077. * \param attr Pointer to the first attribute in the entry.
  1078. * \return Returns 0 when successful; any other value returned signals failure.
  1079. * \warning Do not free the returned \c attr. This is a pointer into the
  1080. * internal entry data structure. If you need a copy, use slapi_attr_dup().
  1081. * \see slapi_entry_next_attr()
  1082. * \see slapi_attr_dup()
  1083. */
  1084. int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr );
  1085. /**
  1086. * Finds the next attribute after \c prevattr in an entry.
  1087. *
  1088. * To iterate through the attributes in an entry, use this function in conjunction
  1089. * with the slapi_entry_first_attr() function.
  1090. *
  1091. * \param e Entry from which you want to get the attribute.
  1092. * \param prevattr Previous attribute in the entry.
  1093. * \param attr Pointer to the next attribute after \c prevattr in the entry.
  1094. * \return \c 0 if successful.
  1095. * \return \c -1 if \c prevattr was the last attribute in the entry.
  1096. * \warning Do not free the returned \c attr. This is a pointer into the
  1097. * internal entry data structure. If you need a copy, use slapi_attr_dup().
  1098. * \see slapi_entry_first_attr()
  1099. * \see slapi_entry_dup()
  1100. */
  1101. int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr );
  1102. /**
  1103. * Gets the unique ID value of the entry.
  1104. *
  1105. * \param e Entry from which you want to obtain the unique ID.
  1106. * \return This function returns the unique ID value of the entry specified.
  1107. * \warning Never free this value. If you need a copy, use slapi_ch_strdup().
  1108. * \see slapi_entry_set_uniqueid()
  1109. * \see slapi_ch_strdup()
  1110. */
  1111. const char *slapi_entry_get_uniqueid( const Slapi_Entry *e );
  1112. /**
  1113. * Replaces the unique ID value of an entry with the unique ID value that you
  1114. * supply.
  1115. *
  1116. * This function replaces the unique ID value of the entry with the \c uniqueid
  1117. * value that you specify. In addition, the function adds #SLAPI_ATTR_UNIQUEID to
  1118. * the attribute list and gives it the unique ID value supplied. If the entry
  1119. * already contains a #SLAPI_ATTR_UNIQUEID attribute, its value is updated with
  1120. * the new value supplied.
  1121. *
  1122. * \param e Entry for which you want to generate a unique ID.
  1123. * \param uniqueid The unique ID value that you want to assign to the entry.
  1124. * \warning Do not free the \c uniqueid after calling this function. The value
  1125. * will eventually be freed when slapi_entry_free() is called.
  1126. *
  1127. * \warning You should pass in a copy of the value because this function will
  1128. * consume the value passed in. For example:
  1129. * \code
  1130. * char *uniqueid = slapi_ch_strdup(some_uniqueid);
  1131. * slapi_entry_set_uniqueid(e, uniqueid);
  1132. * \endcode
  1133. *
  1134. * \warning Do not pass in a \c NULL for \c uniqueid.
  1135. * \see slapi_entry_get_uniqueid()
  1136. * \see slapi_entry_free()
  1137. */
  1138. void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid );
  1139. /**
  1140. * Determines whether the specified entry complies with the schema for its object
  1141. * class.
  1142. *
  1143. * \param pb Parmeter block.
  1144. * \param e Entry that you want to check.
  1145. * \return \c 0 if the entry complies with the schema or if schema checking is
  1146. * turned off. The function also returns \c 0 if the entry has additional
  1147. * attributes not allowed by the schema and has the object class
  1148. * \c extensibleObject.
  1149. * \return \c 1 if the entry is missing the \c objectclass attribute, if it is missing
  1150. * any required attributes, if it has any attributes not allowed by the schema
  1151. * but does not have the object class \c extensibleObject, or if the entry has
  1152. * multiple values for a single-valued attribute.
  1153. * \warning The \c pb argument can be \c NULL. It is only used to get the
  1154. * #SLAPI_IS_REPLICATED_OPERATION flag. If that flag is present, no schema
  1155. * checking is done.
  1156. */
  1157. int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e );
  1158. /**
  1159. * Determines whether the specified entry complies with the syntax rules imposed
  1160. * by it's attribute types.
  1161. *
  1162. * \param pb Parameter block.
  1163. * \param e Entry that you want to check.
  1164. * \param override Flag to override the server configuration and force syntax checking
  1165. * to be performed.
  1166. * \return \c 0 if the entry complies with the syntax rules or if syntax checking
  1167. * is disabled.
  1168. * \return \c 1 if the entry has any attribute values that violate the syntax rules
  1169. * imposed by the associated attribute type. If the \c pb parameter was
  1170. * passed in, an error message describing the syntax violations will be
  1171. * set in the #SLAPI_PB_RESULT_TEXT paramter.
  1172. * \warning The \c pb parameter can be \c NULL. It is used to store an error
  1173. * message with details of any syntax violations. The \c pb paramter
  1174. * is also used to check if the #SLAPI_IS_REPLICATED_OPERATION flag is
  1175. * set. If that flag is present, no syntax checking is performed.
  1176. */
  1177. int slapi_entry_syntax_check( Slapi_PBlock *pb, Slapi_Entry *e, int override );
  1178. /**
  1179. * Determines if any values being added to an entry violate the syntax rules
  1180. * imposed by the associated attribute type.
  1181. *
  1182. * \param pb Parameter block.
  1183. * \param mods Array of mods that you want to check.
  1184. * \param override Flag to override the server configuration and force syntax checking
  1185. * to be performed.
  1186. * \return \c 0 if the mods comply with the syntax rules or if syntax checking
  1187. * is disabled.
  1188. * \return \c 1 if the mods are adding any new attribute values that violate the
  1189. * syntax rules imposed by the associated attribute type. If the \c pb
  1190. * parameter was passed in, an error message describing the syntax violations
  1191. * will be set in the #SLAPI_PB_RESULT_TEXT paramter.
  1192. * \warning The \c pb parameter can be \c NULL. It is used to store an error
  1193. * message with details of any syntax violations. The \c pb paramter
  1194. * is also used to check if the #SLAPI_IS_REPLICATED_OPERATION flag is
  1195. * set. If that flag is present, no syntax checking is performed.
  1196. */
  1197. int slapi_mods_syntax_check( Slapi_PBlock *pb, LDAPMod **mods, int override );
  1198. /**
  1199. * Determines whether the values in an entry’s relative distinguished name (RDN)
  1200. * are also present as attribute values.
  1201. *
  1202. * For example, if the entry’s RDN is <tt>cn=Barbara Jensen</tt>, the function determines
  1203. * if the entry has the \c cn attribute with the value <tt>Barbara Jensen</tt>.
  1204. *
  1205. * \param e Entry that you want to check for RDN values.
  1206. * \return \c 1 if the values in the RDN are present in the attributes of the entry.
  1207. * \return \c 0 if the values are not present.
  1208. */
  1209. int slapi_entry_rdn_values_present( const Slapi_Entry *e );
  1210. /**
  1211. * Adds the components in an entry’s relative distinguished name (RDN) to the entry
  1212. * as attribute values.
  1213. *
  1214. * For example, if the entry’s RDN is <tt>uid=bjensen</tt>, the function adds
  1215. * <tt>uid=bjensen</tt> to the entry as an attribute value.
  1216. *
  1217. * \param e Entry to which you want to add the RDN attributes.
  1218. * \return \c LDAP_SUCCESS if the values were successfully added to the entry. The
  1219. * function also returns \c LDAP_SUCCESS if the entry is \c NULL, if the
  1220. * entry’s DN is \c NULL, or if the entry’s RDN is \c NULL.
  1221. * \return \c LDAP_INVALID_DN_SYNTAX if the DN of the entry cannot be parsed.
  1222. * \warning Free the entry from memory by using the slapi_entry_free() function, if the
  1223. * entry was allocated by the user.
  1224. * \see slapi_entry_free()
  1225. */
  1226. int slapi_entry_add_rdn_values( Slapi_Entry *e );
  1227. /**
  1228. * Deletes an attribute (and all its associated values) from an entry.
  1229. *
  1230. * \param e Entry from which you want to delete the attribute.
  1231. * \param type Attribute type that you want to delete.
  1232. * \return \c 0 if successful.
  1233. * \return \c 1 if the specified attribute is not part of the entry.
  1234. * \return \c -1 if an error occurred.
  1235. */
  1236. int slapi_entry_attr_delete( Slapi_Entry *e, const char *type );
  1237. /**
  1238. * Gets the values of a multi-valued attribute of an entry.
  1239. *
  1240. * This function is very similar to slapi_entry_attr_get_charptr(), except that it
  1241. * returns a <tt>char **</tt> array for multi-valued attributes. The array and all
  1242. * values are copies. Even if the attribute values are not strings, they will still
  1243. * be \c NULL terminated so that they can be used safely in a string context. If there
  1244. * are no values, \c NULL will be returned. Because the array is \c NULL terminated,
  1245. * the usage should be similar to the sample shown below:
  1246. *
  1247. * \code
  1248. * char **ary = slapi_entry_attr_get_charray(e, someattr);
  1249. * int ii;
  1250. * for (ii = 0; ary && ary[ii]; ++ii) {
  1251. * char *strval = ary[ii];
  1252. * ...
  1253. * }
  1254. * slapi_ch_array_free(ary);
  1255. * \endcode
  1256. *
  1257. * \param e Entry from which you want to get the values.
  1258. * \param type Attribute type from which you want to get the values.
  1259. * \return A copy of all the values of the attribute.
  1260. * \return \c NULL if the entry does not contain the attribute or if the attribute
  1261. * has no values.
  1262. * \warning When you are done working with the values, free them from memory by calling
  1263. * the slapi_ch_array_free() function.
  1264. * \see slapi_entry_attr_get_charptr()
  1265. */
  1266. char **slapi_entry_attr_get_charray(const Slapi_Entry* e, const char *type);
  1267. /**
  1268. * Gets the first value of an attribute of an entry as a string.
  1269. *
  1270. * \param e Entry from which you want to get the string value.
  1271. * \param type Attribute type from which you want to get the value.
  1272. * \return A copy of the first value in the attribute.
  1273. * \return \c NULL if the entry does not contain the attribute.
  1274. * \warning When you are done working with this value, free it from memory by calling the
  1275. * slapi_ch_free_string() function.
  1276. * \see slapi_entry_attr_get_charray()
  1277. */
  1278. char *slapi_entry_attr_get_charptr(const Slapi_Entry* e, const char *type);
  1279. /**
  1280. * Gets the first value of an attribute in an entry as an integer.
  1281. *
  1282. * \param e Entry from which you want to get the integer value.
  1283. * \param type Attribute type from which you want to get the value.
  1284. * \return The first value of the attribute converted to an integer.
  1285. * \return \c 0 if the entry does not contain the attribute.
  1286. */
  1287. int slapi_entry_attr_get_int(const Slapi_Entry* e, const char *type);
  1288. /**
  1289. * Gets the first value of an attribute in an entry as an unsigned integer data type.
  1290. *
  1291. * \param e Entry from which you want to get the integer value.
  1292. * \param type Attribute type from which you want to get the value.
  1293. * \return The first value of the attribute converted to an unsigned integer.
  1294. * \return \c 0 if the entry does not contain the attribute.
  1295. */
  1296. unsigned int slapi_entry_attr_get_uint(const Slapi_Entry* e, const char *type);
  1297. /**
  1298. * Gets the first value of an attribute in an entry as a long data type.
  1299. *
  1300. * \param e Entry from which you want to get the long value.
  1301. * \param type Attribute type from which you want to get the value.
  1302. * \return The first value of the attribute converted to a \c long type.
  1303. * \return \c 0 if the entry does not contain the attribute.
  1304. */
  1305. long slapi_entry_attr_get_long( const Slapi_Entry* e, const char *type);
  1306. /**
  1307. * Gets the first value of an attribute in an entry as an unsigned long
  1308. * data type.
  1309. *
  1310. * \param e Entry from which you want to get the unsigned long value.
  1311. * \param type Attribute type from which you want to get the value.
  1312. * \return The first value of the attribute converted to an <tt>
  1313. * unsigned long</tt>.
  1314. * \return \c 0 if the entry does not contain the attribute.
  1315. */
  1316. unsigned long slapi_entry_attr_get_ulong( const Slapi_Entry* e, const char *type);
  1317. /**
  1318. * Gets the first value of an attribute in an entry as a long long data type.
  1319. *
  1320. * \param e Entry from which you want to get the long long value.
  1321. * \param type Attribute type from which you want to get the value.
  1322. * \return The first value of the attribute converted to a <tt>long long</tt>.
  1323. * \return \c 0 if the entry does not contain the attribute.
  1324. */
  1325. long long slapi_entry_attr_get_longlong( const Slapi_Entry* e, const char *type);
  1326. /**
  1327. * Gets the first value of an attribute in an entry as an unsigned
  1328. * long long data type.
  1329. *
  1330. * \param e Entry from which you want to get the unsigned long long value.
  1331. * \param type Attribute type from which you want to get the value.
  1332. * \return The first value of the attribute converted to an <tt>unsigned
  1333. * long long</tt>.
  1334. * \return \c 0 if the entry does not contain the attribute.
  1335. */
  1336. unsigned long long slapi_entry_attr_get_ulonglong( const Slapi_Entry* e, const char *type);
  1337. /**
  1338. * Gets the value of a given attribute of a given entry as a boolean value.
  1339. *
  1340. * Comparisons are case-insensitive (\c TRUE, \c trUe, and \c true are all the
  1341. * same), and unique substrings can be matched (\c t and \c tr will be interpreted
  1342. * as \c true). If the attribute value is a number, then non-zero numbers are
  1343. * interpreted as \c true, and \c 0 is interpreted as \c false.
  1344. *
  1345. * \param e Entry from which you want to get the boolean value.
  1346. * \param type Attribute type from which you want to get the value.
  1347. * \return \c PR_TRUE | \c PR_FALSE
  1348. */
  1349. PRBool slapi_entry_attr_get_bool( const Slapi_Entry* e, const char *type);
  1350. /**
  1351. * Replaces the value or values of an attribute in an entry with a specified string
  1352. * value.
  1353. *
  1354. * \param e Entry in which you want to set the value.
  1355. * \param type Attribute type in which you want to set the value.
  1356. * \param value String value that you want to assign to the attribute.
  1357. * \warning This function makes a copy of the parameter \c value. The \c value
  1358. * parameter can be \c NULL; if so, this function is roughly equivalent
  1359. * to slapi_entry_attr_delete().
  1360. * \see slapi_entry_attr_delete()
  1361. */
  1362. void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value);
  1363. /**
  1364. * Replaces the value or values of an attribute in an entry with a specified integer
  1365. * data value.
  1366. *
  1367. * This function will replace the value or values of an attribute with the
  1368. * integer value that you specify. If the attribute does not exist, it is created
  1369. * with the integer value that you specify.
  1370. *
  1371. * \param e Entry in which you want to set the value.
  1372. * \param type Attribute type in which you want to set the value.
  1373. * \param l Integer value that you want to assign to the attribute.
  1374. */
  1375. void slapi_entry_attr_set_int( Slapi_Entry* e, const char *type, int l);
  1376. /**
  1377. * Replaces the value or values of an attribute in an entry with a specified
  1378. * unsigned integer data type value.
  1379. *
  1380. * This function will replace the value or values of an attribute with the
  1381. * unsigned integer value that you specify. If the attribute does not exist,
  1382. * it is created with the unsigned integer value you specify.
  1383. *
  1384. * \param e Entry in which you want to set the value.
  1385. * \param type Attribute type in which you want to set the value.
  1386. * \param l Unsigned integer value that you want to assign to the attribute.
  1387. */
  1388. void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l);
  1389. /**
  1390. * Replaces the value or values of an attribute in an entry with a specified long data
  1391. * type value.
  1392. *
  1393. * \param e Entry in which you want to set the value.
  1394. * \param type Attribute type in which you want to set the value.
  1395. * \param l Long integer value that you want to assign to the attribute.
  1396. */
  1397. void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
  1398. /**
  1399. * Replaces the value or values of an attribute in an entry with a specified unsigned
  1400. * long data type value.
  1401. *
  1402. * This function will replace the value or values of an attribute with the unsigned
  1403. * long value that you specify. If the attribute does not exist, it is created with the
  1404. * unsigned long value that you specify.
  1405. *
  1406. * \param e Entry in which you want to set the value.
  1407. * \param type Attribute type in which you want to set the value.
  1408. * \param l Unsigned long value that you want to assign to the attribute.
  1409. */
  1410. void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l);
  1411. /**
  1412. * Determines if an attribute in an entry contains a specified value.
  1413. *
  1414. * The syntax of the attribute type is taken into account when checking
  1415. * for the specified value.
  1416. *
  1417. * \param e Entry that you want to check.
  1418. * \param type Attribute type that you want to test for the value specified.
  1419. * \param value Value that you want to find in the attribute.
  1420. * \return \c 1 if the attribute contains the specified value.
  1421. * \return \c 0 if the attribute does not contain the specified value.
  1422. * \warning \c value must not be \c NULL.
  1423. */
  1424. int slapi_entry_attr_has_syntax_value(const Slapi_Entry *e, const char *type, const Slapi_Value *value);
  1425. /**
  1426. * This function determines if the specified entry has child entries.
  1427. *
  1428. * \param e Entry that you want to test for child entries.
  1429. * \return \c 1 if the entry you supply has child entries.
  1430. * \return \c 0 if the entry you supply has child entries.
  1431. */
  1432. int slapi_entry_has_children(const Slapi_Entry *e);
  1433. /**
  1434. * This function determines if an entry is the root DSE.
  1435. *
  1436. * The root DSE is a special entry that contains information about the Directory
  1437. * Server, including its capabilities and configuration.
  1438. *
  1439. * \param dn The DN that you want to test to see if it is the root DSE entry.
  1440. * \return \c 1 if \c dn is the root DSE.
  1441. * \return \c 0 if \c dn is not the root DSE.
  1442. */
  1443. int slapi_is_rootdse( const char *dn );
  1444. /**
  1445. * This function returns the approximate size of an entry, rounded to the nearest 1k.
  1446. *
  1447. * This can be useful for checking cache sizes, estimating storage needs, and so on.
  1448. *
  1449. * When determining the size of an entry, only the sizes of the attribute values are
  1450. * counted; the size of other entry values (such as the size of attribute names,
  1451. * variously-normalized DNs, or any metadata) are not included in the size
  1452. * returned. It is assumed that the size of the metadata, et al., is well enough
  1453. * accounted for by the rounding of the size to the next largest 1k . This holds true
  1454. * especially in larger entries, where the actual size of the attribute values far
  1455. * outweighs the size of the metadata.
  1456. *
  1457. * When determining the size of the entry, both deleted values and deleted
  1458. * attributes are included in the count.
  1459. *
  1460. * \param e Entry from which you want the size returned.
  1461. * \return The size of the entry, rounded to the nearest 1k. The value returned is a
  1462. * size_t data type with a u_long value.
  1463. * \return A size of 1k if the entry is empty.
  1464. * \warning The \c e parameter must not be \c NULL.
  1465. */
  1466. size_t slapi_entry_size(Slapi_Entry *e);
  1467. /**
  1468. * Adds an array of #Slapi_Value data values to the existing attribute values in
  1469. * an entry.
  1470. *
  1471. * If the attribute does not exist, it is created with the #Slapi_Value specified.
  1472. *
  1473. * \param e Entry to which you want to add values.
  1474. * \param type Attribute type to which you want to add values.
  1475. * \param vals \c NULL terminated array of #Slapi_Value data values you want to add.
  1476. * \return This function returns \c 0 if successful; any other value returned
  1477. * signals failure.
  1478. * \warning This function makes a copy of the parameter \c vals. The \c vals
  1479. * parameter can be \c NULL.
  1480. */
  1481. int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1482. /**
  1483. * Adds and array of #Slapi_Value data values to the specified attribute in an entry.
  1484. *
  1485. * This function adds an array of #Slapi_Value data values to an attribute. If the
  1486. * attribute does not exist, it is created and given the value contained in the
  1487. * #Slapi_Value array.
  1488. *
  1489. * \param e Entry to which you want to add values.
  1490. * \param type Attribute type to which you want to add values.
  1491. * \param vals \c NULL terminated array of #Slapi_Value data values you want to add.
  1492. * \return \c LDAP_SUCCESS if the #Slapi_Value array if successfully added to the
  1493. * attribute.
  1494. * \return \c LDAP_TYPE_OR_VALUE_EXISTS if any values you are trying to add duplicate
  1495. * an existing value in the attribute.
  1496. * \return \c LDAP_OPERATIONS_ERROR if there are pre-existing duplicate values in the
  1497. * attribute.
  1498. * \warning This function makes a copy of the parameter \c vals. The \c vals
  1499. * parameter can be \c NULL.
  1500. */
  1501. int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1502. /**
  1503. * Add a Slapi_ValueSet data value to the specified attribute in an entry.
  1504. *
  1505. * This function adds a set of values to an attribute in an entry. The values added
  1506. * are in the form of a #Slapi_ValueSet data type. If the entry does not contain the
  1507. * attribute specified, it is created with the specified #Slapi_ValueSet values.
  1508. *
  1509. * \param e Entry to which you want to add values.
  1510. * \param type Attribute type to which you want to add values.
  1511. * \param vs #Slapi_ValueSet data value that you want to add to the entry.
  1512. * \return \c 0 when successful; any other value returned signals failure.
  1513. * \warning This function makes a copy of the parameter \c vs. The \c vs
  1514. * parameter can be \c NULL.
  1515. */
  1516. int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs);
  1517. /**
  1518. * Removes an array of Slapi_Value data values from an attribute in an entry.
  1519. *
  1520. * This function removes an attribute/valueset from an entry. Both the attribute
  1521. * and its #Slapi_Value data values are removed from the entry. If you supply a
  1522. * #Slapi_Value whose value is \c NULL, the function will delete the specified
  1523. * attribute from the entry. In either case, the function returns \c LDAP_SUCCESS.
  1524. *
  1525. * \param e Entry from which you want to delete values.
  1526. * \param type Attribute type from which you want to delete values.
  1527. * \param vals \c NULL terminated array of #Slapi_Value data values that you
  1528. * want to delete.
  1529. * \return \c LDAP_SUCCESS if the specified attribute and the array of #Slapi_Value
  1530. * data values are deleted from the entry.
  1531. * \return If the specified attribute contains a \c NULL value, the attribute is
  1532. * deleted from the attribute list, and the function returns
  1533. * \c LDAP_NO_SUCH_ATTRIBUTE. As well, if the attribute is not found in the
  1534. * list of attributes for the specified entry, the function returns
  1535. * \c LDAP_NO_SUCH_ATTRIBUTE.
  1536. * \return If there is an operational error during the processing of this call such
  1537. * as a duplicate value found, the function will return
  1538. * \c LDAP_OPERATIONS_ERROR.
  1539. * \warning The \c vals parameter can be \c NULL, in which case this function does
  1540. * nothing.
  1541. */
  1542. int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1543. /**
  1544. * Merges (adds) and array of #Slapi_Value data values to a specified attribute in
  1545. * an entry.
  1546. *
  1547. * This function adds additional #Slapi_Value data values to the existing values
  1548. * contained in an attribute. If the attribute type does not exist, it is created.
  1549. *
  1550. * If the specified attribute exists in the entry, the function merges the value
  1551. * specified and returns \c LDAP_SUCCESS. If the attribute is not found in the entry,
  1552. * the function creates it with the #Slapi_Value specified and returns \c
  1553. * LDAP_NO_SUCH_ATTRIBUTE.
  1554. *
  1555. * If this function fails, it leaves the values for \c type within a pointer to
  1556. * \c e in an indeterminate state. The present valueset may be truncated.
  1557. *
  1558. * \param e Entry into which you want to merge values.
  1559. * \param type Attribute type that you want to merge the values into.
  1560. * \param vals \c NULL terminated array of #Slapi_Value values that you want to merge
  1561. * into the entry.
  1562. * \return \c LDAP_SUCCESS
  1563. * \return \c LDAP_NO_SUCH_ATTRIBUTE
  1564. * \warning This function makes a copy of \c vals. The \c vals parameter
  1565. * can be \c NULL.
  1566. */
  1567. int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1568. /**
  1569. * Replaces the values of an attribute with the #Slapi_Value data value you specify.
  1570. *
  1571. * This function replaces existing attribute values in a specified entry with a single
  1572. * #Slapi_Value data value. The function first deletes the existing attribute from the
  1573. * entry, then replaces it with the new value specified.
  1574. *
  1575. * \param e Entry in which you want to replace values.
  1576. * \param type Attribute type which will receive the replaced values
  1577. * \param vals \c NULL terminated array of #Slapi_Value valyes that should replace
  1578. * the existing values of the attribute.
  1579. * \return \c 0 when successfull; any other value returned signals failure.
  1580. * \warning This function makes a copy of \c vals. The \c vals parameter
  1581. * can be \c NULL.
  1582. */
  1583. int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1584. /**
  1585. * Adds a specified #Slapi_Value data value to an attribute in an entry.
  1586. *
  1587. * This function adds a #Slapi_Value data value to the existing attribute values in an
  1588. * entry. If the specified attribute does not exist in the entry, the attribute is
  1589. * created with the #Slapi_Value specified. The function doesn’t check for duplicate
  1590. * values, meaning it does not check if the value being added is already there.
  1591. *
  1592. * \param e Entry to which you want to add a value.
  1593. * \param type Attribute to which you want to add a value.
  1594. * \param value The #Slapi_Value data value you want to add to the entry.
  1595. * \return \c 0 when successfull; any other value returned signals failure.
  1596. * \warning This function makes a copy of \c value. The \c value parameter
  1597. * can be \c NULL.
  1598. */
  1599. int slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value);
  1600. /**
  1601. * Adds a string value to an attribute in an entry.
  1602. *
  1603. * This function adds a string value to the existing attribute values in an entry. If
  1604. * the specified attribute does not exist in the entry, the attribute is created with
  1605. * the string value specified. The function doesn’t check for duplicate values; it
  1606. * does not check if the string value being added is already there.
  1607. *
  1608. * \param e Entry to which you want to add a string value.
  1609. * \param type Attribute to which you want to add a string value.
  1610. * \param value String value you want to add.
  1611. * \return \c 0 when successfull; any other value returned signals failure.
  1612. * \warning This function makes a copy of \c value. The \c value parameter
  1613. * can be \c NULL.
  1614. */
  1615. int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value);
  1616. /**
  1617. * Deletes a string value from an attribute in an entry.
  1618. *
  1619. * \param e Entry from which you want the string deleted.
  1620. * \param type Attribute type from which you want the string deleted.
  1621. * \param value Value of string to delete.
  1622. * \return \c 0 when successfull; any other value returned signals failure.
  1623. */
  1624. int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value);
  1625. /**
  1626. * Find differences between two entries.
  1627. *
  1628. * Compares two #Slapi_Entry entries and determines the difference between them. The
  1629. * differences are returned as the modifications needed to the first entry to make it
  1630. * match the second entry.
  1631. *
  1632. * \param smods An empty #Slapi_Mods that will be filled in with the modifications
  1633. * needed to make \c e1 the same as \c e2.
  1634. * \param e1 The first entry you want to compare.
  1635. * \param e2 The second entry you want to compare.
  1636. * \param diff_ctrl Allows you to skip comparing operational attributes by passing
  1637. * #SLAPI_DUMP_NOOPATTRS. Pass \c 0 if you want to compare the
  1638. * operational attributes.
  1639. * \warning The caller must allocate the #Slapi_Mods that is passed in as \c smods.
  1640. * This must be an empty #Slapi_Mods, otherwise the contents will be leaked.
  1641. * \warning It is up to the caller to free \c smods when they are finished using them
  1642. * by calling slapi_mods_free() or slapi_mods_done() if \c smods was allocated
  1643. * on the stack.
  1644. */
  1645. void slapi_entry_diff(Slapi_Mods *smods, Slapi_Entry *e1, Slapi_Entry *e2, int diff_ctrl);
  1646. /**
  1647. * Applies an array of \c LDAPMod modifications a Slapi_Entry.
  1648. *
  1649. * \param e Entry to which you want to apply the modifications.
  1650. * \param mods \c NULL terminated array of \c LDAPMod modifications that you
  1651. * want to apply to the specified entry.
  1652. * \return \c LDAP_SUCCESS if the mods applied to the entry cleanly, otherwise an
  1653. * LDAP error is returned.
  1654. * \warning It is up to the caller to free the \c LDAPMod array after the mods have
  1655. * been applied.
  1656. */
  1657. int slapi_entry_apply_mods(Slapi_Entry *e, LDAPMod **mods);
  1658. /*------------------------
  1659. * Entry flags.
  1660. *-----------------------*/
  1661. /**
  1662. * Flag that signifies that an entry is a tombstone entry
  1663. *
  1664. * \see slapi_entry_flag_is_set()
  1665. * \see slapi_entry_set_flag()
  1666. * \see slapi_entry_clear_flag()
  1667. */
  1668. #define SLAPI_ENTRY_FLAG_TOMBSTONE 1
  1669. /**
  1670. * Determines if certain flags are set for a specified entry.
  1671. *
  1672. * \param e Entry for which you want to check for the specified flag.
  1673. * \param flag The flag whose presense you want to check for. Valid flags are:
  1674. * \arg #SLAPI_ENTRY_FLAG_TOMBSTONE
  1675. * \return \c 0 if the flag is not set.
  1676. * \return The value of the flag if it is set.
  1677. * \see slapi_entry_clear_flag()
  1678. * \see slapi_entry_set_flag()
  1679. */
  1680. int slapi_entry_flag_is_set( const Slapi_Entry *e, unsigned char flag );
  1681. /**
  1682. * Sets a flag for a specified entry.
  1683. *
  1684. * \param e Entry for which you want to set the flag.
  1685. * \param flag Flag that you want to set. Valid flags are:
  1686. * \arg #SLAPI_ENTRY_FLAG_TOMBSTONE
  1687. * \see slapi_entry_clear_flag()
  1688. * \see slapi_entry_flag_is_set()
  1689. */
  1690. void slapi_entry_set_flag( Slapi_Entry *e, unsigned char flag);
  1691. /**
  1692. * Clears a flag for a specified entry.
  1693. *
  1694. * \param e Entry for which you want to clear the flag.
  1695. * \param flag Flag that you want to clear. Valid flags are:
  1696. * \arg #SLAPI_ENTRY_FLAG_TOMBSTONE
  1697. * \see slapi_entry_flag_is_set()
  1698. * \see slapi_entry_set_flag()
  1699. */
  1700. void slapi_entry_clear_flag( Slapi_Entry *e, unsigned char flag);
  1701. /*------------------------------
  1702. * exported vattrcache routines
  1703. *------------------------------*/
  1704. /**
  1705. * Check if an entry is current in the virtual attribute cache.
  1706. *
  1707. * \param e The entry for which you want to check the virtual attribute cache
  1708. * validity.
  1709. * \return \c 1 if the entry is valid in the cache.
  1710. * \return \c 0 if the entry is invalid in the cache.
  1711. */
  1712. int slapi_entry_vattrcache_watermark_isvalid(const Slapi_Entry *e);
  1713. /**
  1714. * Mark an entry as valid in the virtual attribute cache.
  1715. *
  1716. * \param e The entry that you want to mark as valid.
  1717. */
  1718. void slapi_entry_vattrcache_watermark_set(Slapi_Entry *e);
  1719. /**
  1720. * Mark an entry as invalid in the virtual attribute cache.
  1721. *
  1722. * \param e The entry that you want to mark as invalid.
  1723. */
  1724. void slapi_entry_vattrcache_watermark_invalidate(Slapi_Entry *e);
  1725. /**
  1726. * Invalidate all entries in the virtual attribute cache.
  1727. */
  1728. void slapi_entrycache_vattrcache_watermark_invalidate();
  1729. /* TODO - Pickup Doxygen work here */
  1730. /*
  1731. * Slapi_DN routines
  1732. */
  1733. Slapi_DN *slapi_sdn_new( void );
  1734. Slapi_DN *slapi_sdn_new_dn_byval(const char *dn);
  1735. Slapi_DN *slapi_sdn_new_ndn_byval(const char *ndn);
  1736. Slapi_DN *slapi_sdn_new_dn_byref(const char *dn);
  1737. Slapi_DN *slapi_sdn_new_ndn_byref(const char *ndn);
  1738. Slapi_DN *slapi_sdn_new_dn_passin(const char *dn);
  1739. Slapi_DN *slapi_sdn_set_dn_byval(Slapi_DN *sdn, const char *dn);
  1740. Slapi_DN *slapi_sdn_set_dn_byref(Slapi_DN *sdn, const char *dn);
  1741. Slapi_DN *slapi_sdn_set_dn_passin(Slapi_DN *sdn, const char *dn);
  1742. Slapi_DN *slapi_sdn_set_ndn_byval(Slapi_DN *sdn, const char *ndn);
  1743. Slapi_DN *slapi_sdn_set_ndn_byref(Slapi_DN *sdn, const char *ndn);
  1744. void slapi_sdn_done(Slapi_DN *sdn);
  1745. void slapi_sdn_free(Slapi_DN **sdn);
  1746. const char * slapi_sdn_get_dn(const Slapi_DN *sdn);
  1747. const char * slapi_sdn_get_ndn(const Slapi_DN *sdn);
  1748. void slapi_sdn_get_parent(const Slapi_DN *sdn,Slapi_DN *sdn_parent);
  1749. void slapi_sdn_get_backend_parent(const Slapi_DN *sdn,Slapi_DN *sdn_parent,const Slapi_Backend *backend);
  1750. Slapi_DN * slapi_sdn_dup(const Slapi_DN *sdn);
  1751. void slapi_sdn_copy(const Slapi_DN *from, Slapi_DN *to);
  1752. int slapi_sdn_compare( const Slapi_DN *sdn1, const Slapi_DN *sdn2 );
  1753. int slapi_sdn_isempty( const Slapi_DN *sdn);
  1754. int slapi_sdn_issuffix(const Slapi_DN *sdn, const Slapi_DN *suffixsdn);
  1755. int slapi_sdn_isparent( const Slapi_DN *parent, const Slapi_DN *child );
  1756. int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child );
  1757. int slapi_sdn_get_ndn_len(const Slapi_DN *sdn);
  1758. int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope );
  1759. void slapi_sdn_get_rdn(const Slapi_DN *sdn,Slapi_RDN *rdn);
  1760. Slapi_DN *slapi_sdn_set_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
  1761. Slapi_DN *slapi_sdn_set_parent(Slapi_DN *sdn, const Slapi_DN *parentdn);
  1762. int slapi_sdn_is_rdn_component(const Slapi_DN *rdn, const Slapi_Attr *a, const Slapi_Value *v);
  1763. char * slapi_moddn_get_newdn(Slapi_DN *dn_olddn, char *newrdn, char *newsuperiordn);
  1764. /*
  1765. * Slapi_RDN functions
  1766. */
  1767. Slapi_RDN *slapi_rdn_new( void );
  1768. Slapi_RDN *slapi_rdn_new_dn(const char *dn);
  1769. Slapi_RDN *slapi_rdn_new_sdn(const Slapi_DN *sdn);
  1770. Slapi_RDN *slapi_rdn_new_rdn(const Slapi_RDN *fromrdn);
  1771. void slapi_rdn_init(Slapi_RDN *rdn);
  1772. void slapi_rdn_init_dn(Slapi_RDN *rdn,const char *dn);
  1773. void slapi_rdn_init_sdn(Slapi_RDN *rdn,const Slapi_DN *sdn);
  1774. void slapi_rdn_init_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn);
  1775. void slapi_rdn_set_dn(Slapi_RDN *rdn,const char *dn);
  1776. void slapi_rdn_set_sdn(Slapi_RDN *rdn,const Slapi_DN *sdn);
  1777. void slapi_rdn_set_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn);
  1778. void slapi_rdn_free(Slapi_RDN **rdn);
  1779. void slapi_rdn_done(Slapi_RDN *rdn);
  1780. int slapi_rdn_get_first(Slapi_RDN *rdn, char **type, char **value);
  1781. int slapi_rdn_get_next(Slapi_RDN *rdn, int index, char **type, char **value);
  1782. int slapi_rdn_get_index(Slapi_RDN *rdn, const char *type, const char *value,size_t length);
  1783. int slapi_rdn_get_index_attr(Slapi_RDN *rdn, const char *type, char **value);
  1784. int slapi_rdn_contains(Slapi_RDN *rdn, const char *type, const char *value,size_t length);
  1785. int slapi_rdn_contains_attr(Slapi_RDN *rdn, const char *type, char **value);
  1786. int slapi_rdn_add(Slapi_RDN *rdn, const char *type, const char *value);
  1787. int slapi_rdn_remove_index(Slapi_RDN *rdn, int atindex);
  1788. int slapi_rdn_remove(Slapi_RDN *rdn, const char *type, const char *value, size_t length);
  1789. int slapi_rdn_remove_attr(Slapi_RDN *rdn, const char *type);
  1790. int slapi_rdn_isempty(const Slapi_RDN *rdn);
  1791. int slapi_rdn_get_num_components(Slapi_RDN *rdn);
  1792. int slapi_rdn_compare(Slapi_RDN *rdn1, Slapi_RDN *rdn2);
  1793. const char *slapi_rdn_get_rdn(const Slapi_RDN *rdn);
  1794. const char *slapi_rdn_get_nrdn(const Slapi_RDN *rdn);
  1795. Slapi_DN *slapi_sdn_add_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
  1796. /*
  1797. * utility routines for dealing with DNs
  1798. */
  1799. char *slapi_dn_normalize( char *dn );
  1800. char *slapi_dn_normalize_to_end( char *dn, char *end );
  1801. char *slapi_dn_ignore_case( char *dn );
  1802. char *slapi_dn_normalize_case( char *dn );
  1803. char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn );
  1804. const char *slapi_dn_find_parent( const char *dn );
  1805. char *slapi_dn_parent( const char *dn );
  1806. int slapi_dn_issuffix( const char *dn, const char *suffix );
  1807. int slapi_dn_isparent( const char *parentdn, const char *childdn );
  1808. int slapi_dn_isroot( const char *dn );
  1809. int slapi_dn_isbesuffix( Slapi_PBlock *pb, const char *dn );
  1810. int slapi_rdn2typeval( char *rdn, char **type, struct berval *bv );
  1811. char *slapi_dn_plus_rdn(const char *dn, const char *rdn);
  1812. /*
  1813. * thread safe random functions
  1814. */
  1815. int slapi_rand_r(unsigned int * seed);
  1816. void slapi_rand_array(void *randx, size_t len);
  1817. int slapi_rand();
  1818. /*
  1819. * attribute routines
  1820. */
  1821. Slapi_Attr *slapi_attr_new( void );
  1822. Slapi_Attr *slapi_attr_init(Slapi_Attr *a, const char *type);
  1823. void slapi_attr_free( Slapi_Attr **a );
  1824. Slapi_Attr *slapi_attr_dup(const Slapi_Attr *attr);
  1825. int slapi_attr_add_value(Slapi_Attr *a, const Slapi_Value *v);
  1826. int slapi_attr_type2plugin( const char *type, void **pi );
  1827. int slapi_attr_get_type( Slapi_Attr *attr, char **type );
  1828. int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp );
  1829. int slapi_attr_get_syntax_oid_copy( const Slapi_Attr *a, char **oidp );
  1830. int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags );
  1831. int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag );
  1832. int slapi_attr_value_cmp( const Slapi_Attr *attr, const struct berval *v1, const struct berval *v2 );
  1833. int slapi_attr_value_find( const Slapi_Attr *a, const struct berval *v );
  1834. int slapi_attr_type_cmp( const char *t1, const char *t2, int opt );
  1835. /* Mode of operation (opt) values for slapi_attr_type_cmp() */
  1836. #define SLAPI_TYPE_CMP_EXACT 0
  1837. #define SLAPI_TYPE_CMP_BASE 1
  1838. #define SLAPI_TYPE_CMP_SUBTYPE 2
  1839. int slapi_attr_types_equivalent(const char *t1, const char *t2);
  1840. char *slapi_attr_basetype( const char *type, char *buf, size_t bufsiz );
  1841. int slapi_attr_first_value( Slapi_Attr *a, Slapi_Value **v );
  1842. int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v );
  1843. int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues);
  1844. int slapi_attr_get_valueset(const Slapi_Attr *a, Slapi_ValueSet **vs);
  1845. /* Make the valuset in Slapi_Attr be *vs--not a copy */
  1846. int slapi_attr_set_valueset(Slapi_Attr *a, const Slapi_ValueSet *vs);
  1847. int slapi_attr_set_type(Slapi_Attr *a, const char *type);
  1848. int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals );
  1849. char * slapi_attr_syntax_normalize( const char *s );
  1850. void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
  1851. void slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod);
  1852. /*
  1853. * value routines
  1854. */
  1855. Slapi_Value *slapi_value_new( void );
  1856. Slapi_Value *slapi_value_new_berval(const struct berval *bval);
  1857. Slapi_Value *slapi_value_new_value(const Slapi_Value *v);
  1858. Slapi_Value *slapi_value_new_string(const char *s);
  1859. Slapi_Value *slapi_value_new_string_passin(char *s);
  1860. Slapi_Value *slapi_value_init(Slapi_Value *v);
  1861. Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval);
  1862. Slapi_Value *slapi_value_init_string(Slapi_Value *v,const char *s);
  1863. Slapi_Value *slapi_value_init_string_passin(Slapi_Value *v, char *s);
  1864. Slapi_Value *slapi_value_dup(const Slapi_Value *v);
  1865. void slapi_value_set_flags(Slapi_Value *v, unsigned long flags);
  1866. void slapi_values_set_flags(Slapi_Value **vs, unsigned long flags);
  1867. unsigned long slapi_value_get_flags(Slapi_Value *v);
  1868. void slapi_value_free(Slapi_Value **value);
  1869. const struct berval *slapi_value_get_berval( const Slapi_Value *value );
  1870. Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bval );
  1871. Slapi_Value *slapi_value_set_value( Slapi_Value *value, const Slapi_Value *vfrom);
  1872. Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len);
  1873. int slapi_value_set_string(Slapi_Value *value, const char *strVal);
  1874. int slapi_value_set_string_passin(Slapi_Value *value, char *strVal);
  1875. int slapi_value_set_int(Slapi_Value *value, int intVal);
  1876. const char*slapi_value_get_string(const Slapi_Value *value);
  1877. int slapi_value_get_int(const Slapi_Value *value);
  1878. unsigned int slapi_value_get_uint(const Slapi_Value *value);
  1879. long slapi_value_get_long(const Slapi_Value *value);
  1880. unsigned long slapi_value_get_ulong(const Slapi_Value *value);
  1881. long long slapi_value_get_longlong(const Slapi_Value *value);
  1882. unsigned long long slapi_value_get_ulonglong(const Slapi_Value *value);
  1883. size_t slapi_value_get_length(const Slapi_Value *value);
  1884. int slapi_value_compare(const Slapi_Attr *a,const Slapi_Value *v1,const Slapi_Value *v2);
  1885. /*
  1886. * Valueset functions.
  1887. */
  1888. #define SLAPI_VALUE_FLAG_PASSIN 0x1
  1889. #define SLAPI_VALUE_FLAG_IGNOREERROR 0x2
  1890. #define SLAPI_VALUE_FLAG_PRESERVECSNSET 0x4
  1891. #define SLAPI_VALUE_FLAG_USENEWVALUE 0x8 /* see valueset_remove_valuearray */
  1892. Slapi_ValueSet *slapi_valueset_new( void );
  1893. void slapi_valueset_free(Slapi_ValueSet *vs);
  1894. void slapi_valueset_init(Slapi_ValueSet *vs);
  1895. void slapi_valueset_done(Slapi_ValueSet *vs);
  1896. void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval);
  1897. void slapi_valueset_add_value_ext(Slapi_ValueSet *vs, Slapi_Value *addval, unsigned long flags);
  1898. int slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v );
  1899. int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v);
  1900. int slapi_valueset_count( const Slapi_ValueSet *vs);
  1901. void slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod);
  1902. void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
  1903. Slapi_Value *slapi_valueset_find(const Slapi_Attr *a, const Slapi_ValueSet *vs, const Slapi_Value *v);
  1904. /*
  1905. * operation routines
  1906. */
  1907. int slapi_op_abandoned( Slapi_PBlock *pb );
  1908. unsigned long slapi_op_get_type(Slapi_Operation * op);
  1909. void slapi_operation_set_flag(Slapi_Operation *op, unsigned long flag);
  1910. void slapi_operation_clear_flag(Slapi_Operation *op, unsigned long flag);
  1911. int slapi_operation_is_flag_set(Slapi_Operation *op, unsigned long flag);
  1912. int slapi_op_reserved(Slapi_PBlock *pb);
  1913. void slapi_operation_set_csngen_handler ( Slapi_Operation *op, void *callback );
  1914. void slapi_operation_set_replica_attr_handler ( Slapi_Operation *op, void *callback );
  1915. int slapi_operation_get_replica_attr ( Slapi_PBlock *pb, Slapi_Operation *op, const char *type, void *value );
  1916. char *slapi_op_type_to_string(unsigned long type);
  1917. /*
  1918. * LDAPMod manipulation routines
  1919. */
  1920. Slapi_Mods* slapi_mods_new( void );
  1921. void slapi_mods_init(Slapi_Mods *smods, int initCount);
  1922. void slapi_mods_init_byref(Slapi_Mods *smods, LDAPMod **mods);
  1923. void slapi_mods_init_passin(Slapi_Mods *smods, LDAPMod **mods);
  1924. void slapi_mods_free(Slapi_Mods **smods);
  1925. void slapi_mods_done(Slapi_Mods *smods);
  1926. void slapi_mods_insert_at(Slapi_Mods *smods, LDAPMod *mod, int pos);
  1927. void slapi_mods_insert_smod_at(Slapi_Mods *smods, Slapi_Mod *smod, int pos);
  1928. void slapi_mods_insert_before(Slapi_Mods *smods, LDAPMod *mod);
  1929. void slapi_mods_insert_smod_before(Slapi_Mods *smods, Slapi_Mod *smod);
  1930. void slapi_mods_insert_after(Slapi_Mods *smods, LDAPMod *mod);
  1931. void slapi_mods_insert_after(Slapi_Mods *smods, LDAPMod *mod);
  1932. void slapi_mods_add( Slapi_Mods *smods, int modtype, const char *type, unsigned long len, const char *val);
  1933. void slapi_mods_add_ldapmod(Slapi_Mods *smods, LDAPMod *mod);
  1934. void slapi_mods_add_modbvps( Slapi_Mods *smods, int modtype, const char *type, struct berval **bvps );
  1935. void slapi_mods_add_mod_values( Slapi_Mods *smods, int modtype, const char *type, Slapi_Value **va );
  1936. void slapi_mods_add_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  1937. void slapi_mods_add_string( Slapi_Mods *smods, int modtype, const char *type, const char *val);
  1938. void slapi_mods_remove(Slapi_Mods *smods);
  1939. LDAPMod *slapi_mods_get_first_mod(Slapi_Mods *smods);
  1940. LDAPMod *slapi_mods_get_next_mod(Slapi_Mods *smods);
  1941. Slapi_Mod *slapi_mods_get_first_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  1942. Slapi_Mod *slapi_mods_get_next_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  1943. void slapi_mods_iterator_backone(Slapi_Mods *smods);
  1944. LDAPMod **slapi_mods_get_ldapmods_byref(Slapi_Mods *smods);
  1945. LDAPMod **slapi_mods_get_ldapmods_passout(Slapi_Mods *smods);
  1946. int slapi_mods_get_num_mods(const Slapi_Mods *smods);
  1947. void slapi_mods_dump(const Slapi_Mods *smods, const char *text);
  1948. Slapi_Mod* slapi_mod_new( void );
  1949. void slapi_mod_init(Slapi_Mod *smod, int initCount);
  1950. void slapi_mod_init_byval(Slapi_Mod *smod, const LDAPMod *mod);
  1951. void slapi_mod_init_byref(Slapi_Mod *smod, LDAPMod *mod);
  1952. void slapi_mod_init_passin(Slapi_Mod *smod, LDAPMod *mod);
  1953. /* init a mod and set the mod values to be a copy of the given valueset */
  1954. void slapi_mod_init_valueset_byval(Slapi_Mod *smod, int op, const char *type, const Slapi_ValueSet *svs);
  1955. void slapi_mod_add_value(Slapi_Mod *smod, const struct berval *val);
  1956. void slapi_mod_remove_value(Slapi_Mod *smod);
  1957. struct berval *slapi_mod_get_first_value(Slapi_Mod *smod);
  1958. struct berval *slapi_mod_get_next_value(Slapi_Mod *smod);
  1959. const char *slapi_mod_get_type(const Slapi_Mod *smod);
  1960. int slapi_mod_get_operation(const Slapi_Mod *smod);
  1961. void slapi_mod_set_type(Slapi_Mod *smod, const char *type);
  1962. void slapi_mod_set_operation(Slapi_Mod *smod, int op);
  1963. int slapi_mod_get_num_values(const Slapi_Mod *smod);
  1964. const LDAPMod *slapi_mod_get_ldapmod_byref(const Slapi_Mod *smod);
  1965. LDAPMod *slapi_mod_get_ldapmod_passout(Slapi_Mod *smod);
  1966. void slapi_mod_free(Slapi_Mod **smod);
  1967. void slapi_mod_done(Slapi_Mod *mod);
  1968. int slapi_mod_isvalid(const Slapi_Mod *mod);
  1969. void slapi_mod_dump(LDAPMod *mod, int n);
  1970. /* helper functions to translate between entry and a set of mods */
  1971. int slapi_mods2entry(Slapi_Entry **e, const char *dn, LDAPMod **attrs);
  1972. int slapi_entry2mods(const Slapi_Entry *e, char **dn, LDAPMod ***attrs);
  1973. /*
  1974. * routines for dealing with filters
  1975. */
  1976. int slapi_filter_get_choice( Slapi_Filter *f );
  1977. int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
  1978. int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type );
  1979. int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
  1980. char ***any, char **final );
  1981. Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
  1982. Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
  1983. Slapi_Filter *slapi_str2filter( char *str );
  1984. Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1,
  1985. Slapi_Filter *f2 );
  1986. Slapi_Filter *slapi_filter_join_ex( int ftype, Slapi_Filter *f1,
  1987. Slapi_Filter *f2, int recurse_always );
  1988. void slapi_filter_free( Slapi_Filter *f, int recurse );
  1989. int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  1990. int verify_access );
  1991. int slapi_vattr_filter_test( Slapi_PBlock *pb, Slapi_Entry *e,
  1992. struct slapi_filter *f, int verify_access);
  1993. int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f);
  1994. char *slapi_find_matching_paren( const char *str );
  1995. int slapi_filter_test_ext( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  1996. int verify_access , int only_test_access);
  1997. int slapi_vattr_filter_test_ext( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  1998. int verify_access , int only_test_access);
  1999. int slapi_filter_compare(struct slapi_filter *f1, struct slapi_filter *f2);
  2000. Slapi_Filter *slapi_filter_dup(Slapi_Filter *f);
  2001. int slapi_filter_changetype(Slapi_Filter *f, const char *newtype);
  2002. /*
  2003. * slapi_filter_apply() is used to apply a function to each simple filter
  2004. * component within a complex filter. A 'simple filter' is anything other
  2005. * than AND, OR or NOT.
  2006. */
  2007. typedef int (*FILTER_APPLY_FN)( Slapi_Filter *f, void *arg);
  2008. int slapi_filter_apply( struct slapi_filter *f, FILTER_APPLY_FN fn, void *arg,
  2009. int *error_code );
  2010. /*
  2011. * Possible return values for slapi_filter_apply() and FILTER_APPLY_FNs.
  2012. * Note that a FILTER_APPLY_FN should return _STOP or _CONTINUE only.
  2013. */
  2014. #define SLAPI_FILTER_SCAN_STOP -1 /* premature abort */
  2015. #define SLAPI_FILTER_SCAN_ERROR -2 /* an error occurred */
  2016. #define SLAPI_FILTER_SCAN_NOMORE 0 /* success */
  2017. #define SLAPI_FILTER_SCAN_CONTINUE 1 /* continue scanning */
  2018. /* Error codes that slapi_filter_apply() may set in *error_code */
  2019. #define SLAPI_FILTER_UNKNOWN_FILTER_TYPE 2
  2020. /*
  2021. * Bit-Twiddlers
  2022. */
  2023. unsigned char slapi_setbit_uchar(unsigned char f,unsigned char bitnum);
  2024. unsigned char slapi_unsetbit_uchar(unsigned char f,unsigned char bitnum);
  2025. int slapi_isbitset_uchar(unsigned char f,unsigned char bitnum);
  2026. unsigned int slapi_setbit_int(unsigned int f,unsigned int bitnum);
  2027. unsigned int slapi_unsetbit_int(unsigned int f,unsigned int bitnum);
  2028. int slapi_isbitset_int(unsigned int f,unsigned int bitnum);
  2029. /*
  2030. * routines for sending entries and results to the client
  2031. */
  2032. int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e,
  2033. LDAPControl **ectrls, char **attrs, int attrsonly );
  2034. void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched,
  2035. char *text, int nentries, struct berval **urls );
  2036. int slapi_send_ldap_referral( Slapi_PBlock *pb, Slapi_Entry *e,
  2037. struct berval **refs, struct berval ***urls );
  2038. typedef int (*send_ldap_search_entry_fn_ptr_t)( Slapi_PBlock *pb,
  2039. Slapi_Entry *e, LDAPControl **ectrls, char **attrs, int attrsonly );
  2040. typedef void (*send_ldap_result_fn_ptr_t)( Slapi_PBlock *pb, int err,
  2041. char *matched, char *text, int nentries, struct berval **urls );
  2042. typedef int (*send_ldap_referral_fn_ptr_t)( Slapi_PBlock *pb,
  2043. Slapi_Entry *e, struct berval **refs, struct berval ***urls );
  2044. /*
  2045. * matching rule
  2046. */
  2047. typedef int (*mrFilterMatchFn) (void* filter, Slapi_Entry*, Slapi_Attr* vals);
  2048. /* returns: 0 filter matched
  2049. * -1 filter did not match
  2050. * >0 an LDAP error code
  2051. */
  2052. int slapi_mr_indexer_create(Slapi_PBlock* opb);
  2053. int slapi_mr_filter_index(Slapi_Filter* f, Slapi_PBlock* pb);
  2054. int slapi_berval_cmp(const struct berval* L, const struct berval* R);
  2055. #define SLAPI_BERVAL_EQ(L,R) ((L)->bv_len == (R)->bv_len && \
  2056. ! memcmp ((L)->bv_val, (R)->bv_val, (L)->bv_len))
  2057. typedef struct slapi_matchingRuleEntry {
  2058. char *mr_oid;
  2059. char *mr_oidalias;
  2060. char *mr_name;
  2061. char *mr_desc;
  2062. char *mr_syntax;
  2063. int mr_obsolete;
  2064. } slapi_matchingRuleEntry;
  2065. typedef struct slapi_matchingRuleEntry Slapi_MatchingRuleEntry;
  2066. Slapi_MatchingRuleEntry *slapi_matchingrule_new(void);
  2067. void slapi_matchingrule_free(Slapi_MatchingRuleEntry **mrEntry,
  2068. int freeMembers);
  2069. int slapi_matchingrule_get(Slapi_MatchingRuleEntry *mr, int arg, void *value);
  2070. int slapi_matchingrule_set(Slapi_MatchingRuleEntry *mr, int arg, void *value);
  2071. int slapi_matchingrule_register(Slapi_MatchingRuleEntry *mrEntry);
  2072. int slapi_matchingrule_unregister(char *oid);
  2073. int slapi_matchingrule_is_ordering(const char *oid_or_name, const char *syntax_oid);
  2074. /*
  2075. * access control
  2076. */
  2077. int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr,
  2078. struct berval *val, int access );
  2079. int slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e,
  2080. LDAPMod **mods, char **errbuf );
  2081. int slapi_acl_verify_aci_syntax(Slapi_PBlock *pb, Slapi_Entry *e, char **errbuf);
  2082. /*
  2083. * attribute stuff
  2084. */
  2085. int slapi_value_find( void *plugin, struct berval **vals, struct berval *v );
  2086. /*
  2087. * password handling
  2088. */
  2089. #define SLAPI_USERPWD_ATTR "userpassword"
  2090. int slapi_pw_find_sv( Slapi_Value **vals, const Slapi_Value *v );
  2091. /* value encoding encoding */
  2092. /* checks if the value is encoded with any known algorithm*/
  2093. int slapi_is_encoded(char *value);
  2094. /* encode value with the specified algorithm */
  2095. char* slapi_encode(char *value, char *alg);
  2096. /* UTF8 related */
  2097. int slapi_has8thBit(unsigned char *s);
  2098. unsigned char *slapi_utf8StrToLower(unsigned char *s);
  2099. void slapi_utf8ToLower(unsigned char *s, unsigned char *d, int *ssz, int *dsz);
  2100. int slapi_utf8isUpper(unsigned char *s);
  2101. unsigned char *slapi_utf8StrToUpper(unsigned char *s);
  2102. void slapi_utf8ToUpper(unsigned char *s, unsigned char *d, int *ssz, int *dsz);
  2103. int slapi_utf8isLower(unsigned char *s);
  2104. int slapi_utf8casecmp(unsigned char *s0, unsigned char *s1);
  2105. int slapi_utf8ncasecmp(unsigned char *s0, unsigned char *s1, int n);
  2106. unsigned char *slapi_UTF8STRTOLOWER(char *s);
  2107. void slapi_UTF8TOLOWER(char *s, char *d, int *ssz, int *dsz);
  2108. int slapi_UTF8ISUPPER(char *s);
  2109. unsigned char *slapi_UTF8STRTOUPPER(char *s);
  2110. void slapi_UTF8TOUPPER(char *s, char *d, int *ssz, int *dsz);
  2111. int slapi_UTF8ISLOWER(char *s);
  2112. int slapi_UTF8CASECMP(char *s0, char *s1);
  2113. int slapi_UTF8NCASECMP(char *s0, char *s1, int n);
  2114. /*
  2115. * Interface to the API broker service
  2116. *
  2117. * The API broker allows plugins to publish an API that may be discovered
  2118. * and used dynamically at run time by other subsystems e.g. other plugins.
  2119. */
  2120. /* Function: slapi_apib_register
  2121. Description: this function allows publication of an interface
  2122. Parameters: guid - a string constant that uniquely identifies the
  2123. interface (must exist for the life of the server)
  2124. api - a vtable for the published api (must exist for the
  2125. life of the server or until the reference count,
  2126. if it exists, reaches zero)
  2127. Return: 0 if function succeeds
  2128. non-zero otherwise
  2129. */
  2130. int slapi_apib_register(char *guid, void **api); /* publish an interface */
  2131. /* Function: slapi_apib_unregister
  2132. Description: this function allows removal of a published interface
  2133. Parameters: guid - a string constant that uniquely identifies the interface
  2134. Return: 0 if function succeeds
  2135. non-zero otherwise
  2136. */
  2137. int slapi_apib_unregister(char *guid); /* remove interface from published list */
  2138. /* Function: slapi_apib_get_interface
  2139. Description: this function allows retrieval of a published interface,
  2140. if the api reference counted, then the reference
  2141. count is incremented
  2142. Parameters: guid - a string constant that uniquely identifies the
  2143. interface requested
  2144. api - the retrieved vtable for the published api (must NOT
  2145. be freed)
  2146. Return: 0 if function succeeds
  2147. non-zero otherwise
  2148. */
  2149. int slapi_apib_get_interface(char *guid, void ***api); /* retrieve an interface for use */
  2150. /* Function: slapi_apib_make_reference_counted
  2151. Description: this function makes an interface a reference counted interface
  2152. it must be called prior to registering the interface
  2153. Parameters: api - the api to make a reference counted api
  2154. callback - if non-zero, this must be a pointer to a function
  2155. which the api broker will call when the ref count for
  2156. the api reaches zero. This function must return 0 if
  2157. it deregisters the api, non-zero otherwise
  2158. api - the retrieved vtable for the published api (must NOT
  2159. be freed)
  2160. Return: 0 if function succeeds
  2161. non-zero otherwise
  2162. */
  2163. typedef int (*slapi_apib_callback_on_zero)(void **api);
  2164. int slapi_apib_make_reference_counted(void **api,
  2165. slapi_apib_callback_on_zero callback);
  2166. /* Function: slapi_apib_addref
  2167. Description: this function adds to the reference count of an api - a
  2168. call to this function should be paired with a call
  2169. to slapi_apib_release
  2170. - ONLY FOR REFERENCE COUNTED APIS
  2171. Parameters: api - the api to add a reference to
  2172. Return: the new reference count
  2173. */
  2174. int slapi_apib_addref(void **api);
  2175. /* Function: slapi_apib_release
  2176. Description: this function adds to the reference count of an api - a
  2177. call to this function should be paired with a prior call
  2178. to slapi_apib_addref or slapi_apib_get_interface
  2179. - ONLY FOR REFERENCE COUNTED APIS
  2180. Parameters: api - the api to add a reference to
  2181. Return: the new reference count
  2182. */
  2183. int slapi_apib_release(void **api);
  2184. /**** End of API broker interface. *******************************************/
  2185. /*
  2186. * routines for dealing with controls
  2187. */
  2188. int slapi_control_present( LDAPControl **controls, char *oid,
  2189. struct berval **val, int *iscritical );
  2190. void slapi_register_supported_control( char *controloid,
  2191. unsigned long controlops );
  2192. LDAPControl * slapi_dup_control( LDAPControl *ctrl );
  2193. #define SLAPI_OPERATION_BIND 0x00000001UL
  2194. #define SLAPI_OPERATION_UNBIND 0x00000002UL
  2195. #define SLAPI_OPERATION_SEARCH 0x00000004UL
  2196. #define SLAPI_OPERATION_MODIFY 0x00000008UL
  2197. #define SLAPI_OPERATION_ADD 0x00000010UL
  2198. #define SLAPI_OPERATION_DELETE 0x00000020UL
  2199. #define SLAPI_OPERATION_MODDN 0x00000040UL
  2200. #define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN
  2201. #define SLAPI_OPERATION_COMPARE 0x00000080UL
  2202. #define SLAPI_OPERATION_ABANDON 0x00000100UL
  2203. #define SLAPI_OPERATION_EXTENDED 0x00000200UL
  2204. #define SLAPI_OPERATION_ANY 0xFFFFFFFFUL
  2205. #define SLAPI_OPERATION_NONE 0x00000000UL
  2206. int slapi_get_supported_controls_copy( char ***ctrloidsp,
  2207. unsigned long **ctrlopsp );
  2208. int slapi_build_control( char *oid, BerElement *ber,
  2209. char iscritical, LDAPControl **ctrlp );
  2210. int slapi_build_control_from_berval( char *oid, struct berval *bvp,
  2211. char iscritical, LDAPControl **ctrlp );
  2212. /* Given an array of controls e.g. LDAPControl **ctrls, add the given
  2213. control to the end of the array, growing the array with realloc
  2214. e.g. slapi_add_control_ext(&ctrls, newctrl, 1);
  2215. if ctrls is NULL, the array will be created with malloc
  2216. if copy is true, the given control will be copied
  2217. if copy is false, the given control will be used and owned by the array
  2218. if copy is false, make sure the control can be freed by ldap_controls_free
  2219. */
  2220. void slapi_add_control_ext( LDAPControl ***ctrlsp, LDAPControl *newctrl, int copy );
  2221. /* Given an array of controls e.g. LDAPControl **ctrls, add all of the given
  2222. controls in the newctrls array to the end of ctrls, growing the array with realloc
  2223. if ctrls is NULL, the array will be created with malloc
  2224. if copy is true, each given control will be copied
  2225. if copy is false, each given control will be used and owned by the array
  2226. if copy is false, make sure each control can be freed by ldap_controls_free
  2227. */
  2228. void slapi_add_controls( LDAPControl ***ctrlsp, LDAPControl **newctrls, int copy );
  2229. /*
  2230. * routines for dealing with extended operations
  2231. */
  2232. char **slapi_get_supported_extended_ops_copy( void );
  2233. /*
  2234. * bind, including SASL
  2235. */
  2236. void slapi_register_supported_saslmechanism( char *mechanism );
  2237. char ** slapi_get_supported_saslmechanisms_copy( void );
  2238. void slapi_add_auth_response_control( Slapi_PBlock *pb, const char *binddn );
  2239. int slapi_add_pwd_control( Slapi_PBlock *pb, char *arg, long time );
  2240. int slapi_pwpolicy_make_response_control (Slapi_PBlock *pb, int seconds, int logins, int error);
  2241. /* Password Policy Response Control stuff - the error argument above */
  2242. #define LDAP_PWPOLICY_PWDEXPIRED 0
  2243. #define LDAP_PWPOLICY_ACCTLOCKED 1
  2244. #define LDAP_PWPOLICY_CHGAFTERRESET 2
  2245. #define LDAP_PWPOLICY_PWDMODNOTALLOWED 3
  2246. #define LDAP_PWPOLICY_MUSTSUPPLYOLDPWD 4
  2247. #define LDAP_PWPOLICY_INVALIDPWDSYNTAX 5
  2248. #define LDAP_PWPOLICY_PWDTOOSHORT 6
  2249. #define LDAP_PWPOLICY_PWDTOOYOUNG 7
  2250. #define LDAP_PWPOLICY_PWDINHISTORY 8
  2251. /*
  2252. * routine for freeing the ch_arrays returned by the slapi_get*_copy functions above
  2253. */
  2254. void slapi_ch_array_free( char **array );
  2255. /*
  2256. * Add the given string to the given null terminated array.
  2257. * s is not copied, so if you want to add a copy of s to the
  2258. * array, use slapi_ch_strdup(s)
  2259. * if *a is NULL, a new array will be created
  2260. */
  2261. void slapi_ch_array_add( char ***array, char *string );
  2262. /*
  2263. * checking routines for allocating and freeing memory
  2264. */
  2265. char * slapi_ch_malloc( unsigned long size );
  2266. char * slapi_ch_realloc( char *block, unsigned long size );
  2267. char * slapi_ch_calloc( unsigned long nelem, unsigned long size );
  2268. char * slapi_ch_strdup( const char *s );
  2269. void slapi_ch_free( void **ptr );
  2270. void slapi_ch_free_string( char **s );
  2271. struct berval* slapi_ch_bvdup(const struct berval*);
  2272. struct berval** slapi_ch_bvecdup(struct berval**);
  2273. void slapi_ch_bvfree(struct berval** v);
  2274. char * slapi_ch_smprintf(const char *fmt, ...)
  2275. #ifdef __GNUC__
  2276. __attribute__ ((format (printf, 1, 2)));
  2277. #else
  2278. ;
  2279. #endif
  2280. /*
  2281. * syntax plugin routines
  2282. */
  2283. int slapi_call_syntax_values2keys_sv( void *vpi, Slapi_Value **vals,
  2284. Slapi_Value ***ivals, int ftype );
  2285. int slapi_call_syntax_values2keys_sv_pb( void *vpi, Slapi_Value **vals,
  2286. Slapi_Value ***ivals, int ftype, Slapi_PBlock *pb );
  2287. int slapi_call_syntax_assertion2keys_ava_sv( void *vpi, Slapi_Value *val,
  2288. Slapi_Value ***ivals, int ftype );
  2289. int slapi_call_syntax_assertion2keys_sub_sv( void *vpi, char *initial,
  2290. char **any, char *final, Slapi_Value ***ivals );
  2291. /*
  2292. * internal operation and plugin callback routines
  2293. */
  2294. typedef void (*plugin_result_callback)(int rc, void *callback_data);
  2295. typedef int (*plugin_referral_entry_callback)(char * referral,
  2296. void *callback_data);
  2297. typedef int (*plugin_search_entry_callback)(Slapi_Entry *e,
  2298. void *callback_data);
  2299. void slapi_free_search_results_internal(Slapi_PBlock *pb);
  2300. /*
  2301. * The following functions can be used for internal operations based on DN
  2302. * as well as on uniqueid. These functions should be used by all new plugins
  2303. * and preferrably old plugins should be changed to use them to take
  2304. * advantage of new plugin configuration capabilities and to use an
  2305. * extensible interface.
  2306. *
  2307. * These functions return -1 if pb is NULL and 0 otherwise.
  2308. * The SLAPI_PLUGIN_INTOP_RESULT pblock parameter should be checked to
  2309. * check if the operation was successful.
  2310. *
  2311. * Helper functions are provided to set up pblock parameters currently used
  2312. * by the functions, e.g., slapi_search_internal_set_pb().
  2313. * Additional parameters may be set directly in the pblock.
  2314. */
  2315. int slapi_search_internal_pb(Slapi_PBlock *pb);
  2316. int slapi_search_internal_callback_pb(Slapi_PBlock *pb, void *callback_data,
  2317. plugin_result_callback prc, plugin_search_entry_callback psec,
  2318. plugin_referral_entry_callback prec);
  2319. int slapi_add_internal_pb(Slapi_PBlock *pb);
  2320. int slapi_modify_internal_pb(Slapi_PBlock *pb);
  2321. int slapi_modrdn_internal_pb(Slapi_PBlock *pb);
  2322. int slapi_delete_internal_pb(Slapi_PBlock *pb);
  2323. int slapi_seq_internal_callback_pb(Slapi_PBlock *pb, void *callback_data,
  2324. plugin_result_callback res_callback,
  2325. plugin_search_entry_callback srch_callback,
  2326. plugin_referral_entry_callback ref_callback);
  2327. void slapi_search_internal_set_pb(Slapi_PBlock *pb, const char *base,
  2328. int scope, const char *filter, char **attrs, int attrsonly,
  2329. LDAPControl **controls, const char *uniqueid,
  2330. Slapi_ComponentId *plugin_identity, int operation_flags);
  2331. void slapi_add_entry_internal_set_pb(Slapi_PBlock *pb, Slapi_Entry *e,
  2332. LDAPControl **controls, Slapi_ComponentId *plugin_identity,
  2333. int operation_flags);
  2334. int slapi_add_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  2335. LDAPMod **attrs, LDAPControl **controls,
  2336. Slapi_ComponentId *plugin_identity, int operation_flags);
  2337. void slapi_modify_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  2338. LDAPMod **mods, LDAPControl **controls, const char *uniqueid,
  2339. Slapi_ComponentId *plugin_identity, int operation_flags);
  2340. void slapi_rename_internal_set_pb(Slapi_PBlock *pb, const char *olddn,
  2341. const char *newrdn, const char *newsuperior, int deloldrdn,
  2342. LDAPControl **controls, const char *uniqueid,
  2343. Slapi_ComponentId *plugin_identity, int operation_flags);
  2344. void slapi_delete_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  2345. LDAPControl **controls, const char *uniqueid,
  2346. Slapi_ComponentId *plugin_identity, int operation_flags);
  2347. void slapi_seq_internal_set_pb(Slapi_PBlock *pb, char *ibase, int type,
  2348. char *attrname, char *val, char **attrs, int attrsonly,
  2349. LDAPControl **controls, Slapi_ComponentId *plugin_identity,
  2350. int operation_flags);
  2351. /*
  2352. * slapi_search_internal_get_entry() finds an entry given a dn. It returns
  2353. * an LDAP error code (LDAP_SUCCESS if all goes well).
  2354. */
  2355. int slapi_search_internal_get_entry( Slapi_DN *dn, char ** attrlist,
  2356. Slapi_Entry **ret_entry , void *caller_identity);
  2357. /*
  2358. * interface for registering object extensions.
  2359. */
  2360. typedef void *(*slapi_extension_constructor_fnptr)(void *object, void *parent);
  2361. typedef void (*slapi_extension_destructor_fnptr)(void *extension,
  2362. void *object, void *parent);
  2363. int slapi_register_object_extension( const char *pluginname,
  2364. const char *objectname, slapi_extension_constructor_fnptr constructor,
  2365. slapi_extension_destructor_fnptr destructor, int *objecttype,
  2366. int *extensionhandle);
  2367. /* objects that can be extended (possible values for the objectname param.) */
  2368. #define SLAPI_EXT_CONNECTION "Connection"
  2369. #define SLAPI_EXT_OPERATION "Operation"
  2370. #define SLAPI_EXT_ENTRY "Entry"
  2371. #define SLAPI_EXT_MTNODE "Mapping Tree Node"
  2372. void *slapi_get_object_extension(int objecttype, void *object,
  2373. int extensionhandle);
  2374. void slapi_set_object_extension(int objecttype, void *object,
  2375. int extensionhandle, void *extension);
  2376. /*
  2377. * interface to allow a plugin to register additional plugins.
  2378. */
  2379. typedef int (*slapi_plugin_init_fnptr)( Slapi_PBlock *pb );
  2380. int slapi_register_plugin( const char *plugintype, int enabled,
  2381. const char *initsymbol, slapi_plugin_init_fnptr initfunc,
  2382. const char *name, char **argv, void *group_identity);
  2383. /*
  2384. * logging
  2385. */
  2386. int slapi_log_error( int severity, char *subsystem, char *fmt, ... )
  2387. #ifdef __GNUC__
  2388. __attribute__ ((format (printf, 3, 4)));
  2389. #else
  2390. ;
  2391. #endif
  2392. /* allowed values for the "severity" parameter */
  2393. #define SLAPI_LOG_FATAL 0
  2394. #define SLAPI_LOG_TRACE 1
  2395. #define SLAPI_LOG_PACKETS 2
  2396. #define SLAPI_LOG_ARGS 3
  2397. #define SLAPI_LOG_CONNS 4
  2398. #define SLAPI_LOG_BER 5
  2399. #define SLAPI_LOG_FILTER 6
  2400. #define SLAPI_LOG_CONFIG 7
  2401. #define SLAPI_LOG_ACL 8
  2402. #define SLAPI_LOG_SHELL 9
  2403. #define SLAPI_LOG_PARSE 10
  2404. #define SLAPI_LOG_HOUSE 11
  2405. #define SLAPI_LOG_REPL 12
  2406. #define SLAPI_LOG_CACHE 13
  2407. #define SLAPI_LOG_PLUGIN 14
  2408. #define SLAPI_LOG_TIMING 15
  2409. #define SLAPI_LOG_ACLSUMMARY 16
  2410. int slapi_is_loglevel_set( const int loglevel );
  2411. /*
  2412. * locks and synchronization
  2413. */
  2414. typedef struct slapi_mutex Slapi_Mutex;
  2415. typedef struct slapi_condvar Slapi_CondVar;
  2416. Slapi_Mutex *slapi_new_mutex( void );
  2417. void slapi_destroy_mutex( Slapi_Mutex *mutex );
  2418. void slapi_lock_mutex( Slapi_Mutex *mutex );
  2419. int slapi_unlock_mutex( Slapi_Mutex *mutex );
  2420. Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex );
  2421. void slapi_destroy_condvar( Slapi_CondVar *cvar );
  2422. int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout );
  2423. int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all );
  2424. /*
  2425. * thread-safe LDAP connections
  2426. */
  2427. LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared );
  2428. void slapi_ldap_unbind( LDAP *ld );
  2429. LDAP *
  2430. slapi_ldap_init_ext(
  2431. const char *ldapurl, /* full ldap url */
  2432. const char *hostname, /* can also use this to override
  2433. host in url */
  2434. int port, /* can also use this to override port in url */
  2435. int secure, /* 0 for ldap, 1 for ldaps, 2 for starttls -
  2436. override proto in url */
  2437. int shared, /* if true, LDAP* will be shared among multiple threads */
  2438. const char *filename /* for ldapi */
  2439. );
  2440. int
  2441. slapi_ldap_bind(
  2442. LDAP *ld, /* ldap connection */
  2443. const char *bindid, /* usually a bind DN for simple bind */
  2444. const char *creds, /* usually a password for simple bind */
  2445. const char *mech, /* name of mechanism */
  2446. LDAPControl **serverctrls, /* additional controls to send */
  2447. LDAPControl ***returnedctrls, /* returned controls */
  2448. struct timeval *timeout, /* timeout */
  2449. int *msgidp /* pass in non-NULL for async handling */
  2450. );
  2451. /*
  2452. * computed attributes
  2453. */
  2454. struct _computed_attr_context;
  2455. typedef struct _computed_attr_context computed_attr_context;
  2456. typedef int (*slapi_compute_output_t)(computed_attr_context *c,Slapi_Attr *a , Slapi_Entry *e);
  2457. typedef int (*slapi_compute_callback_t)(computed_attr_context *c,char* type,Slapi_Entry *e,slapi_compute_output_t outputfn);
  2458. typedef int (*slapi_search_rewrite_callback_t)(Slapi_PBlock *pb);
  2459. int slapi_compute_add_evaluator(slapi_compute_callback_t function);
  2460. int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function);
  2461. int compute_rewrite_search_filter(Slapi_PBlock *pb);
  2462. /*
  2463. * routines for dealing with backends
  2464. */
  2465. Slapi_Backend *slapi_be_new( const char *type, const char *name,
  2466. int isprivate, int logchanges );
  2467. void slapi_be_free(Slapi_Backend **be);
  2468. Slapi_Backend *slapi_be_select( const Slapi_DN *sdn );
  2469. Slapi_Backend *slapi_be_select_by_instance_name( const char *name );
  2470. int slapi_be_exist(const Slapi_DN *sdn);
  2471. void slapi_be_delete_onexit(Slapi_Backend *be);
  2472. void slapi_be_set_readonly(Slapi_Backend *be, int readonly);
  2473. int slapi_be_get_readonly(Slapi_Backend *be);
  2474. int slapi_be_getentrypoint(Slapi_Backend *be, int entrypoint, void **ret_fnptr,
  2475. Slapi_PBlock *pb);
  2476. int slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr,
  2477. Slapi_PBlock *pb);
  2478. int slapi_be_logchanges(Slapi_Backend *be);
  2479. int slapi_be_issuffix(const Slapi_Backend *be, const Slapi_DN *suffix );
  2480. void slapi_be_addsuffix(Slapi_Backend *be,const Slapi_DN *suffix);
  2481. char * slapi_be_get_name(Slapi_Backend * be);
  2482. const Slapi_DN *slapi_be_getsuffix(Slapi_Backend *be, int n);
  2483. Slapi_Backend* slapi_get_first_backend(char **cookie);
  2484. Slapi_Backend* slapi_get_next_backend(char *cookie);
  2485. int slapi_be_private( Slapi_Backend *be );
  2486. void * slapi_be_get_instance_info(Slapi_Backend * be);
  2487. void slapi_be_set_instance_info(Slapi_Backend * be, void * data);
  2488. Slapi_DN * slapi_get_first_suffix(void ** node, int show_private);
  2489. Slapi_DN * slapi_get_next_suffix(void ** node, int show_private);
  2490. int slapi_is_root_suffix(Slapi_DN * dn);
  2491. const char * slapi_be_gettype(Slapi_Backend *be);
  2492. int slapi_be_is_flag_set(Slapi_Backend * be, int flag);
  2493. void slapi_be_set_flag(Slapi_Backend * be, int flag);
  2494. #define SLAPI_BE_FLAG_REMOTE_DATA 0x1 /* entries held by backend are remote */
  2495. #define SLAPI_BE_FLAG_DONT_BYPASS_FILTERTEST 0x10 /* force to call filter_test (search only) */
  2496. /* These functions allow a plugin to register for callback when
  2497. * a backend state change
  2498. */
  2499. typedef void (*slapi_backend_state_change_fnptr)(void *handle, char *be_name,
  2500. int old_be_state, int new_be_state);
  2501. void slapi_register_backend_state_change(void * handle, slapi_backend_state_change_fnptr funct);
  2502. int slapi_unregister_backend_state_change(void * handle);
  2503. #define SLAPI_BE_STATE_ON 1 /* backend is ON */
  2504. #define SLAPI_BE_STATE_OFFLINE 2 /* backend is OFFLINE (import process) */
  2505. #define SLAPI_BE_STATE_DELETE 3 /* backend has been deleted */
  2506. /*
  2507. * Distribution.
  2508. */
  2509. /* SLAPI_BE_ALL_BACKENDS is a special value that is returned by
  2510. * a distribution plugin function to indicate that all backends
  2511. * should be searched (it is only used for search operations).
  2512. */
  2513. #define SLAPI_BE_ALL_BACKENDS -1
  2514. /*
  2515. * virtual attribute service
  2516. */
  2517. /* General flags (flags parameter) */
  2518. #define SLAPI_REALATTRS_ONLY 1
  2519. #define SLAPI_VIRTUALATTRS_ONLY 2
  2520. #define SLAPI_VIRTUALATTRS_REQUEST_POINTERS 4 /* I want to receive pointers into the entry, if possible */
  2521. #define SLAPI_VIRTUALATTRS_LIST_OPERATIONAL_ATTRS 8 /* Include operational attributes in attribute lists */
  2522. #define SLAPI_VIRTUALATTRS_SUPPRESS_SUBTYPES 16 /* I want only the requested attribute */
  2523. /* Buffer disposition flags (buffer_flags parameter) */
  2524. #define SLAPI_VIRTUALATTRS_RETURNED_POINTERS 1
  2525. #define SLAPI_VIRTUALATTRS_RETURNED_COPIES 2
  2526. #define SLAPI_VIRTUALATTRS_REALATTRS_ONLY 4
  2527. /* Attribute type name disposition values (type_name_disposition parameter) */
  2528. #define SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_EXACTLY_OR_ALIAS 1
  2529. #define SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_SUBTYPE 2
  2530. #define SLAPI_VIRTUALATTRS_NOT_FOUND -1
  2531. #define SLAPI_VIRTUALATTRS_LOOP_DETECTED -2
  2532. typedef struct _vattr_type_thang vattr_type_thang;
  2533. typedef struct _vattr_get_thang vattr_get_thang;
  2534. vattr_get_thang *slapi_vattr_getthang_first(vattr_get_thang *t);
  2535. vattr_get_thang *slapi_vattr_getthang_next(vattr_get_thang *t);
  2536. int slapi_vattr_values_type_thang_get(
  2537. /* Entry we're interested in */ Slapi_Entry *e,
  2538. /* attr type */ vattr_type_thang *type_thang,
  2539. /* pointer to result set */ Slapi_ValueSet** results,
  2540. int *type_name_disposition, char **actual_type_name, int flags,
  2541. int *buffer_flags);
  2542. int slapi_vattr_values_get(
  2543. /* Entry we're interested in */ Slapi_Entry *e,
  2544. /* attr type name */ char *type,
  2545. /* pointer to result set */ Slapi_ValueSet** results,
  2546. int *type_name_disposition, char **actual_type_name, int flags,
  2547. int *buffer_flags);
  2548. int slapi_vattr_values_get_ex(
  2549. /* Entry we're interested in */ Slapi_Entry *e,
  2550. /* attr type name */ char *type,
  2551. /* pointer to result set */ Slapi_ValueSet*** results,
  2552. int **type_name_disposition, char ***actual_type_name, int flags,
  2553. int *buffer_flags, int *subtype_count);
  2554. int slapi_vattr_namespace_values_get(
  2555. /* Entry we're interested in */ Slapi_Entry *e,
  2556. /* backend namespace dn */ Slapi_DN *namespace_dn,
  2557. /* attr type name */ char *type,
  2558. /* pointer to result set */ Slapi_ValueSet*** results,
  2559. int **type_name_disposition, char ***actual_type_name, int flags,
  2560. int *buffer_flags, int *subtype_count);
  2561. void slapi_vattr_values_free(Slapi_ValueSet **value, char **actual_type_name,
  2562. int flags);
  2563. int slapi_vattr_value_compare(
  2564. /* Entry we're interested in */ Slapi_Entry *e,
  2565. /* attr type name */ char *type,
  2566. Slapi_Value *test_this,/* pointer to result */ int *result,
  2567. int flags);
  2568. int slapi_vattr_namespace_value_compare(
  2569. /* Entry we're interested in */ Slapi_Entry *e,
  2570. /* backend namespace dn */ Slapi_DN *namespace_dn,
  2571. /* attr type name */ const char *type,
  2572. Slapi_Value *test_this,/* pointer to result */ int *result,
  2573. int flags);
  2574. int slapi_vattr_list_attrs(
  2575. /* Entry we're interested in */ Slapi_Entry *e,
  2576. /* pointer to receive the list */ vattr_type_thang **types,
  2577. int flags, int *buffer_flags);
  2578. void slapi_vattr_attrs_free(vattr_type_thang **types, int flags);
  2579. char *vattr_typethang_get_name(vattr_type_thang *t);
  2580. unsigned long vattr_typethang_get_flags(vattr_type_thang *t);
  2581. vattr_type_thang *vattr_typethang_next(vattr_type_thang *t);
  2582. vattr_type_thang *vattr_typethang_first(vattr_type_thang *t);
  2583. int slapi_vattr_schema_check_type(Slapi_Entry *e, char *type);
  2584. /* roles */
  2585. typedef int (*roles_check_fn_type)(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present);
  2586. int slapi_role_check(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present);
  2587. void slapi_register_role_check(roles_check_fn_type check_fn);
  2588. /* DSE */
  2589. /* Front end configuration */
  2590. typedef int (*dseCallbackFn)(Slapi_PBlock *, Slapi_Entry *, Slapi_Entry *,
  2591. int *, char*, void *);
  2592. /*
  2593. * Note: DSE callback functions MUST return one of these three values:
  2594. *
  2595. * SLAPI_DSE_CALLBACK_OK -- no errors occurred; apply changes.
  2596. * SLAPI_DSE_CALLBACK_ERROR -- an error occurred; don't apply changes.
  2597. * SLAPI_DSE_CALLBACK_DO_NOT_APPLY -- no error, but do not apply changes.
  2598. *
  2599. * SLAPI_DSE_CALLBACK_DO_NOT_APPLY should only be returned by modify
  2600. * callbacks (i.e., those registered with operation==SLAPI_OPERATION_MODIFY).
  2601. * A return value of SLAPI_DSE_CALLBACK_DO_NOT_APPLY is treated the same as
  2602. * SLAPI_DSE_CALLBACK_ERROR for all other operations.
  2603. */
  2604. #define SLAPI_DSE_CALLBACK_OK (1)
  2605. #define SLAPI_DSE_CALLBACK_ERROR (-1)
  2606. #define SLAPI_DSE_CALLBACK_DO_NOT_APPLY (0)
  2607. /*
  2608. * Flags for slapi_config_register_callback() and
  2609. * slapi_config_remove_callback()
  2610. */
  2611. #define DSE_FLAG_PREOP 0x0001
  2612. #define DSE_FLAG_POSTOP 0x0002
  2613. /* This is the size of the returntext parameter passed to the config callback function,
  2614. which is the "char *" argument to dseCallbackFn above */
  2615. #define SLAPI_DSE_RETURNTEXT_SIZE 512 /* for use by callback functions */
  2616. int slapi_config_register_callback(int operation, int flags, const char *base, int scope, const char *filter, dseCallbackFn fn, void *fn_arg);
  2617. int slapi_config_remove_callback(int operation, int flags, const char *base, int scope, const char *filter, dseCallbackFn fn);
  2618. /******************************************************************************
  2619. * Online tasks interface (to support import, export, etc)
  2620. * After some cleanup, we could consider making these public.
  2621. */
  2622. /* task states */
  2623. #define SLAPI_TASK_SETUP 0
  2624. #define SLAPI_TASK_RUNNING 1
  2625. #define SLAPI_TASK_FINISHED 2
  2626. #define SLAPI_TASK_CANCELLED 3
  2627. /* task flag (pb_task_flags)*/
  2628. #define SLAPI_TASK_RUNNING_AS_TASK 0x0
  2629. #define SLAPI_TASK_RUNNING_FROM_COMMANDLINE 0x1
  2630. /* task flags (set by the task-control code) */
  2631. #define SLAPI_TASK_DESTROYING 0x01 /* queued event for destruction */
  2632. int slapi_task_register_handler(const char *name, dseCallbackFn func);
  2633. void slapi_task_begin(Slapi_Task *task, int total_work);
  2634. void slapi_task_inc_progress(Slapi_Task *task);
  2635. void slapi_task_finish(Slapi_Task *task, int rc);
  2636. void slapi_task_cancel(Slapi_Task *task, int rc);
  2637. int slapi_task_get_state(Slapi_Task *task);
  2638. void slapi_task_set_data(Slapi_Task *task, void *data);
  2639. void * slapi_task_get_data(Slapi_Task *task);
  2640. void slapi_task_inc_refcount(Slapi_Task *task);
  2641. void slapi_task_dec_refcount(Slapi_Task *task);
  2642. int slapi_task_get_refcount(Slapi_Task *task);
  2643. void slapi_task_set_destructor_fn(Slapi_Task *task, TaskCallbackFn func);
  2644. void slapi_task_set_cancel_fn(Slapi_Task *task, TaskCallbackFn func);
  2645. void slapi_task_status_changed(Slapi_Task *task);
  2646. void slapi_task_log_status(Slapi_Task *task, char *format, ...)
  2647. #ifdef __GNUC__
  2648. __attribute__ ((format (printf, 2, 3)));
  2649. #else
  2650. ;
  2651. #endif
  2652. void slapi_task_log_notice(Slapi_Task *task, char *format, ...)
  2653. #ifdef __GNUC__
  2654. __attribute__ ((format (printf, 2, 3)));
  2655. #else
  2656. ;
  2657. #endif
  2658. /*
  2659. * slapi_new_task: create new task, fill in DN, and setup modify callback
  2660. * argument:
  2661. * dn: task dn
  2662. * result:
  2663. * Success: Slapi_Task object
  2664. * Failure: NULL
  2665. */
  2666. Slapi_Task *slapi_new_task(const char *dn);
  2667. /* slapi_destroy_task: destroy a task
  2668. * argument:
  2669. * task: task to destroy
  2670. * result:
  2671. * none
  2672. */
  2673. void slapi_destroy_task(void *arg);
  2674. /* End of interface to support online tasks **********************************/
  2675. /* Slapi_Counter Interface */
  2676. Slapi_Counter *slapi_counter_new();
  2677. void slapi_counter_init(Slapi_Counter *counter);
  2678. void slapi_counter_destroy(Slapi_Counter **counter);
  2679. PRUint64 slapi_counter_increment(Slapi_Counter *counter);
  2680. PRUint64 slapi_counter_decrement(Slapi_Counter *counter);
  2681. PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue);
  2682. PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue);
  2683. PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue);
  2684. PRUint64 slapi_counter_get_value(Slapi_Counter *counter);
  2685. /* Binder-based (connection centric) resource limits */
  2686. /*
  2687. * Valid values for `type' parameter to slapi_reslimit_register().
  2688. */
  2689. #define SLAPI_RESLIMIT_TYPE_INT 0
  2690. /*
  2691. * Status codes returned by all functions.
  2692. */
  2693. #define SLAPI_RESLIMIT_STATUS_SUCCESS 0 /* goodness */
  2694. #define SLAPI_RESLIMIT_STATUS_NOVALUE 1 /* no value is available */
  2695. #define SLAPI_RESLIMIT_STATUS_INIT_FAILURE 2 /* initialization failed */
  2696. #define SLAPI_RESLIMIT_STATUS_PARAM_ERROR 3 /* bad parameter */
  2697. #define SLAPI_RESLIMIT_STATUS_UNKNOWN_HANDLE 4 /* unregistered handle */
  2698. #define SLAPI_RESLIMIT_STATUS_INTERNAL_ERROR 5 /* unexpected error */
  2699. /*
  2700. * Functions.
  2701. */
  2702. int slapi_reslimit_register( int type, const char *attrname, int *handlep );
  2703. int slapi_reslimit_get_integer_limit( Slapi_Connection *conn, int handle,
  2704. int *limitp );
  2705. /* END of Binder-based resource limits API */
  2706. /*
  2707. * Plugin and parameter block related macros (remainder of this file).
  2708. */
  2709. /*
  2710. * Plugin version. Note that the Directory Server will load version 01
  2711. * and 02 plugins, but some server features require 03 plugins.
  2712. */
  2713. #define SLAPI_PLUGIN_VERSION_01 "01"
  2714. #define SLAPI_PLUGIN_VERSION_02 "02"
  2715. #define SLAPI_PLUGIN_VERSION_03 "03"
  2716. #define SLAPI_PLUGIN_CURRENT_VERSION SLAPI_PLUGIN_VERSION_03
  2717. #define SLAPI_PLUGIN_IS_COMPAT(x) \
  2718. ((strcmp((x), SLAPI_PLUGIN_VERSION_01) == 0) || \
  2719. (strcmp((x), SLAPI_PLUGIN_VERSION_02) == 0) || \
  2720. (strcmp((x), SLAPI_PLUGIN_VERSION_03) == 0))
  2721. #define SLAPI_PLUGIN_IS_V2(x) \
  2722. ((strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_02) == 0) || \
  2723. (strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_03) == 0))
  2724. #define SLAPI_PLUGIN_IS_V3(x) \
  2725. (strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_03) == 0)
  2726. /* this one just has to be human readable */
  2727. #define SLAPI_PLUGIN_SUPPORTED_VERSIONS "01,02,03"
  2728. /*
  2729. * types of plugin interfaces
  2730. */
  2731. #define SLAPI_PLUGIN_EXTENDEDOP 2
  2732. #define SLAPI_PLUGIN_PREOPERATION 3
  2733. #define SLAPI_PLUGIN_POSTOPERATION 4
  2734. #define SLAPI_PLUGIN_MATCHINGRULE 5
  2735. #define SLAPI_PLUGIN_SYNTAX 6
  2736. #define SLAPI_PLUGIN_ACL 7
  2737. #define SLAPI_PLUGIN_BEPREOPERATION 8
  2738. #define SLAPI_PLUGIN_BEPOSTOPERATION 9
  2739. #define SLAPI_PLUGIN_ENTRY 10
  2740. #define SLAPI_PLUGIN_TYPE_OBJECT 11
  2741. #define SLAPI_PLUGIN_INTERNAL_PREOPERATION 12
  2742. #define SLAPI_PLUGIN_INTERNAL_POSTOPERATION 13
  2743. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME 14
  2744. #define SLAPI_PLUGIN_VATTR_SP 15
  2745. #define SLAPI_PLUGIN_REVER_PWD_STORAGE_SCHEME 16
  2746. #define SLAPI_PLUGIN_LDBM_ENTRY_FETCH_STORE 17
  2747. #define SLAPI_PLUGIN_INDEX 18
  2748. /*
  2749. * special return values for extended operation plugins (zero or positive
  2750. * return values should be LDAP error codes as defined in ldap.h)
  2751. */
  2752. #define SLAPI_PLUGIN_EXTENDED_SENT_RESULT -1
  2753. #define SLAPI_PLUGIN_EXTENDED_NOT_HANDLED -2
  2754. /*
  2755. * the following can be used as the second argument to the
  2756. * slapi_pblock_get() and slapi_pblock_set() calls.
  2757. */
  2758. /* backend, connection, operation */
  2759. #define SLAPI_BACKEND 130
  2760. #define SLAPI_CONNECTION 131
  2761. #define SLAPI_OPERATION 132
  2762. #define SLAPI_REQUESTOR_ISROOT 133
  2763. #define SLAPI_BE_TYPE 135
  2764. #define SLAPI_BE_READONLY 136
  2765. #define SLAPI_BE_LASTMOD 137
  2766. #define SLAPI_CONN_ID 139
  2767. #define SLAPI_BACKEND_COUNT 860
  2768. /* operation */
  2769. #define SLAPI_OPINITIATED_TIME 140
  2770. #define SLAPI_REQUESTOR_DN 141
  2771. #define SLAPI_OPERATION_PARAMETERS 138
  2772. #define SLAPI_OPERATION_TYPE 590
  2773. #define SLAPI_OPERATION_AUTHTYPE 741
  2774. #define SLAPI_OPERATION_ID 744
  2775. #define SLAPI_IS_REPLICATED_OPERATION 142
  2776. #define SLAPI_IS_MMR_REPLICATED_OPERATION 153
  2777. #define SLAPI_IS_LEGACY_REPLICATED_OPERATION 154
  2778. #define SLAPI_SKIP_MODIFIED_ATTRS 155
  2779. /* connection */
  2780. #define SLAPI_CONN_DN 143
  2781. #define SLAPI_CONN_CLIENTNETADDR 850
  2782. #define SLAPI_CONN_SERVERNETADDR 851
  2783. #define SLAPI_CONN_IS_REPLICATION_SESSION 149
  2784. #define SLAPI_CONN_IS_SSL_SESSION 747
  2785. #define SLAPI_CONN_CERT 743
  2786. #define SLAPI_CONN_AUTHMETHOD 746
  2787. #define SLAPI_CONN_SASL_SSF 748
  2788. #define SLAPI_CONN_SSL_SSF 749
  2789. /*
  2790. * Types of authentication for SLAPI_CONN_AUTHMETHOD
  2791. * (and deprecated SLAPI_CONN_AUTHTYPE)
  2792. */
  2793. #define SLAPD_AUTH_NONE "none"
  2794. #define SLAPD_AUTH_SIMPLE "simple"
  2795. #define SLAPD_AUTH_SSL "SSL"
  2796. #define SLAPD_AUTH_SASL "SASL " /* followed by the mechanism name */
  2797. #define SLAPD_AUTH_OS "OS"
  2798. /* Command Line Arguments */
  2799. #define SLAPI_ARGC 147
  2800. #define SLAPI_ARGV 148
  2801. /* Slapd config file directory */
  2802. #define SLAPI_CONFIG_DIRECTORY 281
  2803. /* DSE flags */
  2804. #define SLAPI_DSE_DONT_WRITE_WHEN_ADDING 282
  2805. #define SLAPI_DSE_MERGE_WHEN_ADDING 283
  2806. #define SLAPI_DSE_DONT_CHECK_DUPS 284
  2807. #define SLAPI_DSE_REAPPLY_MODS 287
  2808. #define SLAPI_DSE_IS_PRIMARY_FILE 289
  2809. /* internal schema flags */
  2810. #define SLAPI_SCHEMA_FLAGS 285
  2811. /* urp flags */
  2812. #define SLAPI_URP_NAMING_COLLISION_DN 286
  2813. #define SLAPI_URP_TOMBSTONE_UNIQUEID 288
  2814. /* common to all plugins */
  2815. #define SLAPI_PLUGIN 3
  2816. #define SLAPI_PLUGIN_PRIVATE 4
  2817. #define SLAPI_PLUGIN_TYPE 5
  2818. #define SLAPI_PLUGIN_ARGV 6
  2819. #define SLAPI_PLUGIN_ARGC 7
  2820. #define SLAPI_PLUGIN_VERSION 8
  2821. #define SLAPI_PLUGIN_OPRETURN 9
  2822. #define SLAPI_PLUGIN_OBJECT 10
  2823. #define SLAPI_PLUGIN_DESTROY_FN 11
  2824. #define SLAPI_PLUGIN_DESCRIPTION 12
  2825. typedef struct slapi_plugindesc {
  2826. char *spd_id;
  2827. char *spd_vendor;
  2828. char *spd_version;
  2829. char *spd_description;
  2830. } Slapi_PluginDesc;
  2831. #define SLAPI_PLUGIN_IDENTITY 13
  2832. /* common for internal plugin_ops */
  2833. #define SLAPI_PLUGIN_INTOP_RESULT 15
  2834. #define SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES 16
  2835. #define SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS 17
  2836. /* miscellaneous plugin functions */
  2837. #define SLAPI_PLUGIN_CLOSE_FN 210
  2838. #define SLAPI_PLUGIN_START_FN 212
  2839. #define SLAPI_PLUGIN_CLEANUP_FN 232
  2840. #define SLAPI_PLUGIN_POSTSTART_FN 233
  2841. /* extendedop plugin functions */
  2842. #define SLAPI_PLUGIN_EXT_OP_FN 300
  2843. #define SLAPI_PLUGIN_EXT_OP_OIDLIST 301
  2844. #define SLAPI_PLUGIN_EXT_OP_NAMELIST 302
  2845. /* preoperation plugin functions */
  2846. #define SLAPI_PLUGIN_PRE_BIND_FN 401
  2847. #define SLAPI_PLUGIN_PRE_UNBIND_FN 402
  2848. #define SLAPI_PLUGIN_PRE_SEARCH_FN 403
  2849. #define SLAPI_PLUGIN_PRE_COMPARE_FN 404
  2850. #define SLAPI_PLUGIN_PRE_MODIFY_FN 405
  2851. #define SLAPI_PLUGIN_PRE_MODRDN_FN 406
  2852. #define SLAPI_PLUGIN_PRE_ADD_FN 407
  2853. #define SLAPI_PLUGIN_PRE_DELETE_FN 408
  2854. #define SLAPI_PLUGIN_PRE_ABANDON_FN 409
  2855. #define SLAPI_PLUGIN_PRE_ENTRY_FN 410
  2856. #define SLAPI_PLUGIN_PRE_REFERRAL_FN 411
  2857. #define SLAPI_PLUGIN_PRE_RESULT_FN 412
  2858. /* internal preoperation plugin functions */
  2859. #define SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN 420
  2860. #define SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN 421
  2861. #define SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN 422
  2862. #define SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN 423
  2863. /* preoperation plugin to the backend */
  2864. #define SLAPI_PLUGIN_BE_PRE_ADD_FN 450
  2865. #define SLAPI_PLUGIN_BE_PRE_MODIFY_FN 451
  2866. #define SLAPI_PLUGIN_BE_PRE_MODRDN_FN 452
  2867. #define SLAPI_PLUGIN_BE_PRE_DELETE_FN 453
  2868. /* postoperation plugin functions */
  2869. #define SLAPI_PLUGIN_POST_BIND_FN 501
  2870. #define SLAPI_PLUGIN_POST_UNBIND_FN 502
  2871. #define SLAPI_PLUGIN_POST_SEARCH_FN 503
  2872. #define SLAPI_PLUGIN_POST_COMPARE_FN 504
  2873. #define SLAPI_PLUGIN_POST_MODIFY_FN 505
  2874. #define SLAPI_PLUGIN_POST_MODRDN_FN 506
  2875. #define SLAPI_PLUGIN_POST_ADD_FN 507
  2876. #define SLAPI_PLUGIN_POST_DELETE_FN 508
  2877. #define SLAPI_PLUGIN_POST_ABANDON_FN 509
  2878. #define SLAPI_PLUGIN_POST_ENTRY_FN 510
  2879. #define SLAPI_PLUGIN_POST_REFERRAL_FN 511
  2880. #define SLAPI_PLUGIN_POST_RESULT_FN 512
  2881. #define SLAPI_PLUGIN_POST_SEARCH_FAIL_FN 513
  2882. /* internal preoperation plugin functions */
  2883. #define SLAPI_PLUGIN_INTERNAL_POST_ADD_FN 520
  2884. #define SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN 521
  2885. #define SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN 522
  2886. #define SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN 523
  2887. /* postoperation plugin to the backend */
  2888. #define SLAPI_PLUGIN_BE_POST_ADD_FN 550
  2889. #define SLAPI_PLUGIN_BE_POST_MODIFY_FN 551
  2890. #define SLAPI_PLUGIN_BE_POST_MODRDN_FN 552
  2891. #define SLAPI_PLUGIN_BE_POST_DELETE_FN 553
  2892. /* matching rule plugin functions */
  2893. #define SLAPI_PLUGIN_MR_FILTER_CREATE_FN 600
  2894. #define SLAPI_PLUGIN_MR_INDEXER_CREATE_FN 601
  2895. #define SLAPI_PLUGIN_MR_FILTER_MATCH_FN 602
  2896. #define SLAPI_PLUGIN_MR_FILTER_INDEX_FN 603
  2897. #define SLAPI_PLUGIN_MR_FILTER_RESET_FN 604
  2898. #define SLAPI_PLUGIN_MR_INDEX_FN 605
  2899. /* matching rule plugin arguments */
  2900. #define SLAPI_PLUGIN_MR_OID 610
  2901. #define SLAPI_PLUGIN_MR_TYPE 611
  2902. #define SLAPI_PLUGIN_MR_VALUE 612
  2903. #define SLAPI_PLUGIN_MR_VALUES 613
  2904. #define SLAPI_PLUGIN_MR_KEYS 614
  2905. #define SLAPI_PLUGIN_MR_FILTER_REUSABLE 615
  2906. #define SLAPI_PLUGIN_MR_QUERY_OPERATOR 616
  2907. #define SLAPI_PLUGIN_MR_USAGE 617
  2908. /* Defined values of SLAPI_PLUGIN_MR_QUERY_OPERATOR: */
  2909. #define SLAPI_OP_LESS 1
  2910. #define SLAPI_OP_LESS_OR_EQUAL 2
  2911. #define SLAPI_OP_EQUAL 3
  2912. #define SLAPI_OP_GREATER_OR_EQUAL 4
  2913. #define SLAPI_OP_GREATER 5
  2914. #define SLAPI_OP_SUBSTRING 6
  2915. /* Defined values of SLAPI_PLUGIN_MR_USAGE: */
  2916. #define SLAPI_PLUGIN_MR_USAGE_INDEX 0
  2917. #define SLAPI_PLUGIN_MR_USAGE_SORT 1
  2918. /* Defined values for matchingRuleEntry accessor functions */
  2919. #define SLAPI_MATCHINGRULE_NAME 1
  2920. #define SLAPI_MATCHINGRULE_OID 2
  2921. #define SLAPI_MATCHINGRULE_DESC 3
  2922. #define SLAPI_MATCHINGRULE_SYNTAX 4
  2923. #define SLAPI_MATCHINGRULE_OBSOLETE 5
  2924. /* syntax plugin functions and arguments */
  2925. #define SLAPI_PLUGIN_SYNTAX_FILTER_AVA 700
  2926. #define SLAPI_PLUGIN_SYNTAX_FILTER_SUB 701
  2927. #define SLAPI_PLUGIN_SYNTAX_VALUES2KEYS 702
  2928. #define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA 703
  2929. #define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB 704
  2930. #define SLAPI_PLUGIN_SYNTAX_NAMES 705
  2931. #define SLAPI_PLUGIN_SYNTAX_OID 706
  2932. #define SLAPI_PLUGIN_SYNTAX_FLAGS 707
  2933. #define SLAPI_PLUGIN_SYNTAX_COMPARE 708
  2934. /* user defined substrlen; not stored in slapdplugin, but pblock itself */
  2935. #define SLAPI_SYNTAX_SUBSTRLENS 709
  2936. #define SLAPI_PLUGIN_SYNTAX_VALIDATE 710
  2937. /* ACL plugin functions and arguments */
  2938. #define SLAPI_PLUGIN_ACL_INIT 730
  2939. #define SLAPI_PLUGIN_ACL_SYNTAX_CHECK 731
  2940. #define SLAPI_PLUGIN_ACL_ALLOW_ACCESS 732
  2941. #define SLAPI_PLUGIN_ACL_MODS_ALLOWED 733
  2942. #define SLAPI_PLUGIN_ACL_MODS_UPDATE 734
  2943. #define ACLPLUGIN_ACCESS_DEFAULT 0
  2944. #define ACLPLUGIN_ACCESS_READ_ON_ENTRY 1
  2945. #define ACLPLUGIN_ACCESS_READ_ON_ATTR 2
  2946. #define ACLPLUGIN_ACCESS_READ_ON_VLV 3
  2947. #define ACLPLUGIN_ACCESS_MODRDN 4
  2948. #define ACLPLUGIN_ACCESS_GET_EFFECTIVE_RIGHTS 5
  2949. /* Authorization types */
  2950. #define SLAPI_BE_MAXNESTLEVEL 742
  2951. #define SLAPI_CLIENT_DNS 745
  2952. /* Password storage scheme functions and arguments */
  2953. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN 800
  2954. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DEC_FN 801 /* only meaningfull for reversible encryption */
  2955. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN 802
  2956. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME 810 /* name of the method: SHA, SSHA... */
  2957. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_USER_PWD 811 /* value sent over LDAP */
  2958. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DB_PWD 812 /* value from the DB */
  2959. /* entry fetch and entry store values */
  2960. #define SLAPI_PLUGIN_ENTRY_FETCH_FUNC 813
  2961. #define SLAPI_PLUGIN_ENTRY_STORE_FUNC 814
  2962. #define SLAPI_PLUGIN_ENABLED 815
  2963. /*
  2964. * Defined values of SLAPI_PLUGIN_SYNTAX_FLAGS:
  2965. */
  2966. #define SLAPI_PLUGIN_SYNTAX_FLAG_ORKEYS 1
  2967. #define SLAPI_PLUGIN_SYNTAX_FLAG_ORDERING 2
  2968. /* controls we know about */
  2969. #define SLAPI_MANAGEDSAIT 1000
  2970. #define SLAPI_PWPOLICY 1001
  2971. /* arguments that are common to all operation */
  2972. #define SLAPI_TARGET_ADDRESS 48 /* target address (dn + uniqueid) should be normalized */
  2973. #define SLAPI_TARGET_UNIQUEID 49 /* target uniqueid of the operation */
  2974. #define SLAPI_TARGET_DN 50 /* target dn of the operation should be normalized */
  2975. #define SLAPI_REQCONTROLS 51 /* request controls */
  2976. /* Copies of entry before and after add, mod, mod[r]dn operations */
  2977. #define SLAPI_ENTRY_PRE_OP 52
  2978. #define SLAPI_ENTRY_POST_OP 53
  2979. /* a PRE_ENTRY_FN may alter the entry to be returned to the client -
  2980. SLAPI_SEARCH_ORIG_ENTRY holds the original entry from
  2981. the database - this must not be changed
  2982. SLAPI_SEARCH_ENTRY_COPY holds a copy of the original entry that
  2983. has been modified by the plugin - this will be NULL by default -
  2984. if a plugin needs to modify the entry, it should first check to
  2985. see if there is already a SLAPI_SEARCH_ENTRY_COPY - if not, the
  2986. plugin must use slapi_entry_dup() or similar to make a copy, edit
  2987. the copy, then store it in SLAPI_SEARCH_ENTRY_COPY - the internal
  2988. server code will free SLAPI_SEARCH_ENTRY_COPY
  2989. */
  2990. #define SLAPI_SEARCH_ENTRY_ORIG SLAPI_ENTRY_PRE_OP
  2991. #define SLAPI_SEARCH_ENTRY_COPY SLAPI_ENTRY_POST_OP
  2992. /* LDAPv3 controls to be sent with the operation result */
  2993. #define SLAPI_RESCONTROLS 55
  2994. #define SLAPI_ADD_RESCONTROL 56 /* add result control */
  2995. /* Extra notes to be logged within access log RESULT lines */
  2996. #define SLAPI_OPERATION_NOTES 57
  2997. #define SLAPI_OP_NOTE_UNINDEXED 0x01
  2998. /* Allows controls to be passed before operation object is created */
  2999. #define SLAPI_CONTROLS_ARG 58
  3000. /* specify whether pblock content should be destroyed when the pblock is destroyed */
  3001. #define SLAPI_DESTROY_CONTENT 59
  3002. /* add arguments */
  3003. #define SLAPI_ADD_TARGET SLAPI_TARGET_DN
  3004. #define SLAPI_ADD_ENTRY 60
  3005. #define SLAPI_ADD_EXISTING_DN_ENTRY 61
  3006. #define SLAPI_ADD_PARENT_ENTRY 62
  3007. #define SLAPI_ADD_PARENT_UNIQUEID 63
  3008. #define SLAPI_ADD_EXISTING_UNIQUEID_ENTRY 64
  3009. /* bind arguments */
  3010. #define SLAPI_BIND_TARGET SLAPI_TARGET_DN
  3011. #define SLAPI_BIND_METHOD 70
  3012. #define SLAPI_BIND_CREDENTIALS 71 /* v3 only */
  3013. #define SLAPI_BIND_SASLMECHANISM 72 /* v3 only */
  3014. /* bind return values */
  3015. #define SLAPI_BIND_RET_SASLCREDS 73 /* v3 only */
  3016. /* compare arguments */
  3017. #define SLAPI_COMPARE_TARGET SLAPI_TARGET_DN
  3018. #define SLAPI_COMPARE_TYPE 80
  3019. #define SLAPI_COMPARE_VALUE 81
  3020. /* delete arguments */
  3021. #define SLAPI_DELETE_TARGET SLAPI_TARGET_DN
  3022. #define SLAPI_DELETE_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  3023. #define SLAPI_DELETE_GLUE_PARENT_ENTRY SLAPI_ADD_PARENT_ENTRY
  3024. #define SLAPI_DELETE_BEPREOP_ENTRY SLAPI_ENTRY_PRE_OP
  3025. /* modify arguments */
  3026. #define SLAPI_MODIFY_TARGET SLAPI_TARGET_DN
  3027. #define SLAPI_MODIFY_MODS 90
  3028. #define SLAPI_MODIFY_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  3029. /* modrdn arguments */
  3030. #define SLAPI_MODRDN_TARGET SLAPI_TARGET_DN
  3031. #define SLAPI_MODRDN_NEWRDN 100
  3032. #define SLAPI_MODRDN_DELOLDRDN 101
  3033. #define SLAPI_MODRDN_NEWSUPERIOR 102 /* v3 only */
  3034. #define SLAPI_MODRDN_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  3035. #define SLAPI_MODRDN_PARENT_ENTRY 104
  3036. #define SLAPI_MODRDN_NEWPARENT_ENTRY 105
  3037. #define SLAPI_MODRDN_TARGET_ENTRY 106
  3038. #define SLAPI_MODRDN_NEWSUPERIOR_ADDRESS 107
  3039. /*
  3040. * unnormalized dn argument (useful for MOD, MODRDN and DEL operations to carry
  3041. * the original non-escaped dn as introduced by the client application)
  3042. */
  3043. #define SLAPI_ORIGINAL_TARGET_DN 109
  3044. #define SLAPI_ORIGINAL_TARGET SLAPI_ORIGINAL_TARGET_DN
  3045. /* search arguments */
  3046. #define SLAPI_SEARCH_TARGET SLAPI_TARGET_DN
  3047. #define SLAPI_SEARCH_SCOPE 110
  3048. #define SLAPI_SEARCH_DEREF 111
  3049. #define SLAPI_SEARCH_SIZELIMIT 112
  3050. #define SLAPI_SEARCH_TIMELIMIT 113
  3051. #define SLAPI_SEARCH_FILTER 114
  3052. #define SLAPI_SEARCH_STRFILTER 115
  3053. #define SLAPI_SEARCH_ATTRS 116
  3054. #define SLAPI_SEARCH_GERATTRS 1160
  3055. #define SLAPI_SEARCH_ATTRSONLY 117
  3056. #define SLAPI_SEARCH_IS_AND 118
  3057. /* abandon arguments */
  3058. #define SLAPI_ABANDON_MSGID 120
  3059. /* seq access arguments */
  3060. #define SLAPI_SEQ_TYPE 150
  3061. #define SLAPI_SEQ_ATTRNAME 151
  3062. #define SLAPI_SEQ_VAL 152
  3063. /* extended operation arguments */
  3064. #define SLAPI_EXT_OP_REQ_OID 160 /* v3 only */
  3065. #define SLAPI_EXT_OP_REQ_VALUE 161 /* v3 only */
  3066. /* extended operation return values */
  3067. #define SLAPI_EXT_OP_RET_OID 162 /* v3 only */
  3068. #define SLAPI_EXT_OP_RET_VALUE 163 /* v3 only */
  3069. /* extended filter arguments */
  3070. #define SLAPI_MR_FILTER_ENTRY 170 /* v3 only */
  3071. #define SLAPI_MR_FILTER_TYPE 171 /* v3 only */
  3072. #define SLAPI_MR_FILTER_VALUE 172 /* v3 only */
  3073. #define SLAPI_MR_FILTER_OID 173 /* v3 only */
  3074. #define SLAPI_MR_FILTER_DNATTRS 174 /* v3 only */
  3075. /* ldif2db arguments */
  3076. /* ldif file to convert to db */
  3077. #define SLAPI_LDIF2DB_FILE 180
  3078. /* check for duplicate values or not */
  3079. #define SLAPI_LDIF2DB_REMOVEDUPVALS 185
  3080. /* index only this attribute from existing database */
  3081. #define SLAPI_DB2INDEX_ATTRS 186
  3082. /* do not generate attribute indexes */
  3083. #define SLAPI_LDIF2DB_NOATTRINDEXES 187
  3084. /* list if DNs to include */
  3085. #define SLAPI_LDIF2DB_INCLUDE 188
  3086. /* list of DNs to exclude */
  3087. #define SLAPI_LDIF2DB_EXCLUDE 189
  3088. /* generate uniqueid */
  3089. #define SLAPI_LDIF2DB_GENERATE_UNIQUEID 175
  3090. #define SLAPI_LDIF2DB_NAMESPACEID 177
  3091. #define SLAPI_LDIF2DB_ENCRYPT 303
  3092. #define SLAPI_DB2LDIF_DECRYPT 304
  3093. /* uniqueid generation options */
  3094. #define SLAPI_UNIQUEID_GENERATE_NONE 0 /* do not generate */
  3095. #define SLAPI_UNIQUEID_GENERATE_TIME_BASED 1 /* generate time based id */
  3096. #define SLAPI_UNIQUEID_GENERATE_NAME_BASED 2 /* generate name based id */
  3097. /* db2ldif arguments */
  3098. /* print keys or not in ldif */
  3099. #define SLAPI_DB2LDIF_PRINTKEY 183
  3100. /* filename to export */
  3101. #define SLAPI_DB2LDIF_FILE 184
  3102. /* dump uniqueid */
  3103. #define SLAPI_DB2LDIF_DUMP_UNIQUEID 176
  3104. #define SLAPI_DB2LDIF_SERVER_RUNNING 197
  3105. /* db2ldif/ldif2db/bak2db/db2bak arguments */
  3106. #define SLAPI_BACKEND_INSTANCE_NAME 178
  3107. #define SLAPI_BACKEND_TASK 179
  3108. #define SLAPI_TASK_FLAGS 181
  3109. /* bulk import (online wire import) */
  3110. #define SLAPI_BULK_IMPORT_ENTRY 182
  3111. #define SLAPI_BULK_IMPORT_STATE 192
  3112. /* the actual states (these are not pblock args) */
  3113. #define SLAPI_BI_STATE_START 1
  3114. #define SLAPI_BI_STATE_DONE 2
  3115. #define SLAPI_BI_STATE_ADD 3
  3116. /* possible error codes from a bulk import */
  3117. #define SLAPI_BI_ERR_BUSY -23 /* backend is busy; try later */
  3118. /* transaction arguments */
  3119. #define SLAPI_PARENT_TXN 190
  3120. #define SLAPI_TXN 191
  3121. /*
  3122. * The following are used to pass information back and forth
  3123. * between the front end and the back end. The backend
  3124. * creates a search result set as an opaque structure and
  3125. * passes a reference to this back to the front end. The
  3126. * front end uses the backend's iterator entry point to
  3127. * step through the results. The entry, nentries, and
  3128. * referrals options, below, are set/read by both the
  3129. * front end and back end while stepping through the
  3130. * search results.
  3131. */
  3132. /* Search result set */
  3133. #define SLAPI_SEARCH_RESULT_SET 193
  3134. /* Search result - next entry returned from search result set */
  3135. #define SLAPI_SEARCH_RESULT_ENTRY 194
  3136. #define SLAPI_SEARCH_RESULT_ENTRY_EXT 1944
  3137. /* Number of entries returned from search */
  3138. #define SLAPI_NENTRIES 195
  3139. /* Any referrals encountered during the search */
  3140. #define SLAPI_SEARCH_REFERRALS 196
  3141. /* for search operations, allows plugins to provide
  3142. controls to pass for each entry or referral returned
  3143. corresponds to pb_search_ctrls */
  3144. #define SLAPI_SEARCH_CTRLS 198
  3145. #define SLAPI_RESULT_CODE 881
  3146. #define SLAPI_RESULT_TEXT 882
  3147. #define SLAPI_RESULT_MATCHED 883
  3148. #define SLAPI_PB_RESULT_TEXT 885
  3149. /* Size of the database, in kilobytes */
  3150. #define SLAPI_DBSIZE 199
  3151. /* convenience macros for checking modify operation types */
  3152. #define SLAPI_IS_MOD_ADD(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_ADD)
  3153. #define SLAPI_IS_MOD_DELETE(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_DELETE)
  3154. #define SLAPI_IS_MOD_REPLACE(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_REPLACE)
  3155. /* regex.c */
  3156. typedef struct slapi_regex_handle Slapi_Regex;
  3157. /**
  3158. * Compiles a regular expression pattern. A thin wrapper of pcre_compile.
  3159. *
  3160. * \param pat Pattern to be compiled.
  3161. * \param error The error string is set if the compile fails.
  3162. * \return This function returns a pointer to the regex handler which stores
  3163. * the compiled pattern. NULL if the compile fails.
  3164. * \warning The regex handler should be released by slapi_re_free().
  3165. */
  3166. Slapi_Regex *slapi_re_comp( const char *pat, const char **error );
  3167. /**
  3168. * Matches a compiled regular expression pattern against a given string.
  3169. * A thin wrapper of pcre_exec.
  3170. *
  3171. * \param re_handle The regex handler returned from slapi_re_comp.
  3172. * \param subject A string to be checked against the compiled pattern.
  3173. * \param time_up If the current time is larger than the value, this function
  3174. * returns immediately. (-1) means no time limit.
  3175. * \return This function returns 0 if the string did not match.
  3176. * \return This function returns 1 if the string matched.
  3177. * \return This function returns other values if any error occurred.
  3178. * \warning The regex handler should be released by slapi_re_free().
  3179. */
  3180. int slapi_re_exec( Slapi_Regex *re_handle, const char *subject, time_t time_up );
  3181. /**
  3182. * Substitutes '&' or '\#' in the param src with the matched string.
  3183. *
  3184. * \param re_handle The regex handler returned from slapi_re_comp.
  3185. * \param subject A string checked against the compiled pattern.
  3186. * \param src A given string which could contain the substitution symbols.
  3187. * \param dst A pointer pointing to the memory which stores the output string.
  3188. * \param dstlen Size of the memory dst.
  3189. * \return This function returns 1 if the substitution was successful.
  3190. * \return This function returns 0 if the substitution failed.
  3191. * \warning The regex handler should be released by slapi_re_free().
  3192. */
  3193. int slapi_re_subs( Slapi_Regex *re_handle, const char *subject, const char *src, char **dst, unsigned long dstlen );
  3194. /**
  3195. * Releases the regex handler which was returned from slapi_re_comp.
  3196. *
  3197. * \param re_handle The regex handler to be released.
  3198. * \return nothing
  3199. */
  3200. void slapi_re_free(Slapi_Regex *re_handle);
  3201. /* wrap non-portable LDAP API functions */
  3202. void slapi_ldap_value_free(char **vals);
  3203. int slapi_ldap_count_values(char **vals);
  3204. int slapi_ldap_url_parse(const char *url, LDAPURLDesc **ludpp, int require_dn, int *secure);
  3205. const char *slapi_urlparse_err2string(int err);
  3206. int slapi_ldap_get_lderrno(LDAP *ld, char **m, char **s);
  3207. #ifndef LDIF_OPT_NOWRAP
  3208. #define LDIF_OPT_NOWRAP 0x01UL
  3209. #endif
  3210. #ifndef LDIF_OPT_VALUE_IS_URL
  3211. #define LDIF_OPT_VALUE_IS_URL 0x02UL
  3212. #endif
  3213. #ifndef LDIF_OPT_MINIMAL_ENCODING
  3214. #define LDIF_OPT_MINIMAL_ENCODING 0x04UL
  3215. #endif
  3216. void slapi_ldif_put_type_and_value_with_options( char **out, const char *t, const char *val, int vlen, unsigned long options );
  3217. #if defined(USE_OPENLDAP)
  3218. /*
  3219. * UTF-8 routines (should these move into libnls?)
  3220. */
  3221. /* number of bytes in character */
  3222. int ldap_utf8len( const char* );
  3223. /* find next character */
  3224. char *ldap_utf8next( char* );
  3225. /* find previous character */
  3226. char *ldap_utf8prev( char* );
  3227. /* copy one character */
  3228. int ldap_utf8copy( char* dst, const char* src );
  3229. /* total number of characters */
  3230. size_t ldap_utf8characters( const char* );
  3231. /* get one UCS-4 character, and move *src to the next character */
  3232. unsigned long ldap_utf8getcc( const char** src );
  3233. /* UTF-8 aware strtok_r() */
  3234. char *ldap_utf8strtok_r( char* src, const char* brk, char** next);
  3235. /* like isalnum(*s) in the C locale */
  3236. int ldap_utf8isalnum( char* s );
  3237. /* like isalpha(*s) in the C locale */
  3238. int ldap_utf8isalpha( char* s );
  3239. /* like isdigit(*s) in the C locale */
  3240. int ldap_utf8isdigit( char* s );
  3241. /* like isxdigit(*s) in the C locale */
  3242. int ldap_utf8isxdigit(char* s );
  3243. /* like isspace(*s) in the C locale */
  3244. int ldap_utf8isspace( char* s );
  3245. #define LDAP_UTF8LEN(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8len (s) : 1)
  3246. #define LDAP_UTF8NEXT(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8next(s) : ( s)+1)
  3247. #define LDAP_UTF8INC(s) ((0x80 & *(unsigned char*)(s)) ? s=ldap_utf8next(s) : ++s)
  3248. #define LDAP_UTF8PREV(s) ldap_utf8prev(s)
  3249. #define LDAP_UTF8DEC(s) (s=ldap_utf8prev(s))
  3250. #define LDAP_UTF8COPY(d,s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8copy(d,s) : ((*(d) = *(s)), 1))
  3251. #define LDAP_UTF8GETCC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc (&s) : *s++)
  3252. #define LDAP_UTF8GETC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc ((const char**)&s) : *s++)
  3253. #endif /* USE_OPENLDAP */
  3254. /* by default will allow dups */
  3255. char **slapi_str2charray( char *str, char *brkstr );
  3256. /*
  3257. * extended version of str2charray lets you disallow
  3258. * duplicate values into the array.
  3259. */
  3260. char **slapi_str2charray_ext( char *str, char *brkstr, int allow_dups );
  3261. #ifndef LDAP_PORT_MAX
  3262. #define LDAP_PORT_MAX 65535 /* API extension */
  3263. #endif
  3264. #ifndef LDAP_ALL_USER_ATTRS
  3265. #ifdef LDAP_ALL_USER_ATTRIBUTES
  3266. #define LDAP_ALL_USER_ATTRS LDAP_ALL_USER_ATTRIBUTES
  3267. #else
  3268. #define LDAP_ALL_USER_ATTRS "*"
  3269. #endif
  3270. #endif
  3271. #ifndef LDAP_SASL_EXTERNAL
  3272. #define LDAP_SASL_EXTERNAL "EXTERNAL" /* TLS/SSL extension */
  3273. #endif
  3274. #ifndef LBER_SOCKET
  3275. #ifdef LBER_SOCKET_T
  3276. #define LBER_SOCKET LBER_SOCKET_T
  3277. #else
  3278. #define LBER_SOCKET int
  3279. #endif
  3280. #endif
  3281. /**
  3282. * Set given "type: value" to the plugin default config entry
  3283. * (cn=plugin default config,cn=config) unless the same "type: value" pair
  3284. * already exists in the entry.
  3285. *
  3286. * \param type Attribute type to add to the default config entry
  3287. * \param value Attribute value to add to the default config entry
  3288. * \return 0 if the operation was successful
  3289. * \return non-0 if the operation was not successful
  3290. */
  3291. int slapi_set_plugin_default_config(const char *type, Slapi_Value *value);
  3292. /**
  3293. * Get attribute values of given type from the plugin default config entry
  3294. * (cn=plugin default config,cn=config).
  3295. *
  3296. * \param type Attribute type to get from the default config entry
  3297. * \param valueset Valueset holding the attribute values
  3298. * \return 0 if the operation was successful
  3299. * \return non-0 if the operation was not successful
  3300. * \warning Caller is responsible to free attrs by slapi_ch_array_free
  3301. * */
  3302. int slapi_get_plugin_default_config(char *type, Slapi_ValueSet **valueset);
  3303. #ifdef __cplusplus
  3304. }
  3305. #endif
  3306. #endif /* _SLAPIPLUGIN */