slapi-plugin.h 292 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800
  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) 2009 Red Hat, Inc.
  36. * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
  37. * All rights reserved.
  38. *
  39. * Contributors:
  40. * Hewlett-Packard Development Company, L.P.
  41. * Bugfix for bug #195302
  42. *
  43. * END COPYRIGHT BLOCK */
  44. /*! \file slapi-plugin.h
  45. * \brief Public Directory Server plugin interface.
  46. *
  47. * The SLAPI plugin interface allows complex plugins to be created
  48. * for Directory Server.
  49. */
  50. #ifndef _SLAPIPLUGIN
  51. #define _SLAPIPLUGIN
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. #include "prtypes.h"
  56. #include "ldap.h"
  57. #include "prprf.h"
  58. #include "nspr.h"
  59. NSPR_API(PRUint32) PR_snprintf(char *out, PRUint32 outlen, const char *fmt, ...)
  60. #ifdef __GNUC__
  61. __attribute__ ((format (printf, 3, 4)));
  62. #else
  63. ;
  64. #endif
  65. NSPR_API(char*) PR_smprintf(const char *fmt, ...)
  66. #ifdef __GNUC__
  67. __attribute__ ((format (printf, 1, 2)));
  68. #else
  69. ;
  70. #endif
  71. NSPR_API(char*) PR_sprintf_append(char *last, const char *fmt, ...)
  72. #ifdef __GNUC__
  73. __attribute__ ((format (printf, 2, 3)));
  74. #else
  75. ;
  76. #endif
  77. NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...)
  78. #ifdef __GNUC__
  79. __attribute__ ((format (printf, 2, 3)));
  80. #else
  81. ;
  82. #endif
  83. /* NSPR uses the print macros a bit differently than ANSI C. We
  84. * need to use ll for a 64-bit integer, even when a long is 64-bit.
  85. */
  86. #define NSPRIu64 "llu"
  87. #define NSPRI64 "ll"
  88. /* OpenLDAP uses unsigned long for ber_tag_t and ber_len_t but mozldap uses unsigned int */
  89. /* use this macro for printf statements for ber_tag_t and ber_len_t */
  90. #if defined(USE_OPENLDAP)
  91. #define BERTAG_T "lu"
  92. #define BERLEN_T "lu"
  93. #else
  94. #define BERTAG_T "u"
  95. #define BERLEN_T "u"
  96. #endif
  97. #define DEFINETOSTR(xxx) #xxx
  98. #define STRINGIFYDEFINE(xxx) DEFINETOSTR(xxx)
  99. /* Common check on berval before accessing the contents. */
  100. /* bv is a struct berval *bv */
  101. #define BV_HAS_DATA(bv) ((bv != NULL) && (bv->bv_len > 0) && (bv->bv_val != NULL))
  102. /*
  103. * The slapi_attr_get_flags() routine returns a bitmap that contains one or
  104. * more of these values.
  105. *
  106. * Note that the flag values 0x0010, 0x0020, 0x4000, and 0x8000 are reserved.
  107. */
  108. /**
  109. * Flag indicating that an attribtue is single-valued.
  110. *
  111. * \see slapi_attr_flag_is_set()
  112. * \see slapi_attr_set_flags()
  113. */
  114. #define SLAPI_ATTR_FLAG_SINGLE 0x0001 /* single-valued attribute */
  115. /**
  116. * Flag indicating than an attribute is operational.
  117. *
  118. * \see slapi_attr_flag_is_set()
  119. * \see slapi_attr_set_flags()
  120. */
  121. #define SLAPI_ATTR_FLAG_OPATTR 0x0002 /* operational attribute */
  122. /**
  123. * Flag indicating than an attribute is read-only.
  124. *
  125. * \see slapi_attr_flag_is_set()
  126. * \see slapi_attr_set_flags()
  127. */
  128. #define SLAPI_ATTR_FLAG_READONLY 0x0004 /* read from shipped config file */
  129. /**
  130. * Flag indicating than an attribute is read-only.
  131. *
  132. * This is an alias for #SLAPI_ATTR_FLAG_READONLY.
  133. * \see slapi_attr_flag_is_set()
  134. * \see slapi_attr_set_flags()
  135. */
  136. #define SLAPI_ATTR_FLAG_STD_ATTR SLAPI_ATTR_FLAG_READONLY /* alias for read only */
  137. /**
  138. * Flag indicating than an attribute is obsolete.
  139. *
  140. * \see slapi_attr_flag_is_set()
  141. * \see slapi_attr_set_flags()
  142. */
  143. #define SLAPI_ATTR_FLAG_OBSOLETE 0x0040 /* an outdated definition */
  144. /**
  145. * Flag indicating that an attribute is collective.
  146. *
  147. * \warning Collective attributes are not supported, so this
  148. * flag has no effect.
  149. * \see slapi_attr_flag_is_set()
  150. * \see slapi_attr_set_flags()
  151. */
  152. #define SLAPI_ATTR_FLAG_COLLECTIVE 0x0080 /* collective (not supported) */
  153. /**
  154. * Flag indicating that an attribute is not modifiable over LDAP.
  155. *
  156. * \see slapi_attr_flag_is_set()
  157. * \see slapi_attr_set_flags()
  158. */
  159. #define SLAPI_ATTR_FLAG_NOUSERMOD 0x0100 /* can't be modified over LDAP */
  160. /**
  161. * Flag to indicate that the attribute value is normalized.
  162. *
  163. * \see slapi_value_set_flags()
  164. * \see slapi_values_set_flags()
  165. */
  166. /* the attr value is normalized */
  167. #define SLAPI_ATTR_FLAG_NORMALIZED \
  168. (SLAPI_ATTR_FLAG_NORMALIZED_CES|SLAPI_ATTR_FLAG_NORMALIZED_CIS)
  169. #define SLAPI_ATTR_FLAG_NORMALIZED_CES 0x0200 /* the attr value is normalized,
  170. but not case-normalized.
  171. Used for DN. */
  172. #define SLAPI_ATTR_FLAG_NORMALIZED_CIS 0x0400 /* the attr value is normalized
  173. including case.
  174. Used for DN. */
  175. /**
  176. * Flag to indicate that the attribute value is not exposed if specified.
  177. *
  178. * \see slapi_value_set_flags()
  179. * \see slapi_values_set_flags()
  180. */
  181. #define SLAPI_ATTR_FLAG_NOEXPOSE 0x0800 /* the attr value is not exposed */
  182. /**
  183. * Flag to indicate that the attribute value is LDAP_SCHEMA_DISTRIBUTED_OPERATION
  184. * If this is set, SLAPI_ATTR_FLAG_OPATTR must also be set
  185. *
  186. * \see slapi_value_set_flags()
  187. * \see slapi_values_set_flags()
  188. */
  189. #define SLAPI_ATTR_FLAG_DISTRIBUTED_OPERATION 0x1000 /* USAGE distributedOperation */
  190. /**
  191. * Flag to indicate that the attribute value is LDAP_SCHEMA_DSA_OPERATION
  192. * If this is set, SLAPI_ATTR_FLAG_OPATTR must also be set
  193. *
  194. * \see slapi_value_set_flags()
  195. * \see slapi_values_set_flags()
  196. */
  197. #define SLAPI_ATTR_FLAG_DSA_OPERATION 0x2000 /* USAGE dSAOperation */
  198. /* operation flags */
  199. #define SLAPI_OP_FLAG_INTERNAL 0x00020 /* An operation generated by the core server or a plugin. */
  200. #define SLAPI_OP_FLAG_NEVER_CHAIN 0x00800 /* Do not chain the operation */
  201. #define SLAPI_OP_FLAG_NO_ACCESS_CHECK 0x10000 /* Do not check for access control - bypass them */
  202. #define SLAPI_OP_FLAG_BYPASS_REFERRALS 0x40000 /* Useful for performing internal operations on read-only replica */
  203. #define SLAPI_OC_FLAG_REQUIRED 0x0001
  204. #define SLAPI_OC_FLAG_ALLOWED 0x0002
  205. /*
  206. * access control levels
  207. */
  208. #define SLAPI_ACL_COMPARE 0x01
  209. #define SLAPI_ACL_SEARCH 0x02
  210. #define SLAPI_ACL_READ 0x04
  211. #define SLAPI_ACL_WRITE 0x08
  212. #define SLAPI_ACL_DELETE 0x10
  213. #define SLAPI_ACL_ADD 0x20
  214. #define SLAPI_ACL_SELF 0x40
  215. #define SLAPI_ACL_PROXY 0x80
  216. #define SLAPI_ACL_ALL 0x7f
  217. /*
  218. * filter types
  219. * openldap defines these, but not mozldap
  220. */
  221. #ifndef LDAP_FILTER_AND
  222. #define LDAP_FILTER_AND 0xa0L
  223. #endif
  224. #ifndef LDAP_FILTER_OR
  225. #define LDAP_FILTER_OR 0xa1L
  226. #endif
  227. #ifndef LDAP_FILTER_NOT
  228. #define LDAP_FILTER_NOT 0xa2L
  229. #endif
  230. #ifndef LDAP_FILTER_EQUALITY
  231. #define LDAP_FILTER_EQUALITY 0xa3L
  232. #endif
  233. #ifndef LDAP_FILTER_SUBSTRINGS
  234. #define LDAP_FILTER_SUBSTRINGS 0xa4L
  235. #endif
  236. #ifndef LDAP_FILTER_GE
  237. #define LDAP_FILTER_GE 0xa5L
  238. #endif
  239. #ifndef LDAP_FILTER_LE
  240. #define LDAP_FILTER_LE 0xa6L
  241. #endif
  242. #ifndef LDAP_FILTER_PRESENT
  243. #define LDAP_FILTER_PRESENT 0x87L
  244. #endif
  245. #ifndef LDAP_FILTER_APPROX
  246. #define LDAP_FILTER_APPROX 0xa8L
  247. #endif
  248. #ifndef LDAP_FILTER_EXTENDED
  249. #ifdef LDAP_FILTER_EXT
  250. #define LDAP_FILTER_EXTENDED LDAP_FILTER_EXT
  251. #else
  252. #define LDAP_FILTER_EXTENDED 0xa9L
  253. #endif
  254. #endif
  255. #ifndef LBER_END_OF_SEQORSET
  256. #define LBER_END_OF_SEQORSET ((ber_tag_t) -2) /* 0xfffffffeU */
  257. #endif
  258. #ifndef LDAP_CHANGETYPE_ADD
  259. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_ADD
  260. #define LDAP_CHANGETYPE_ADD LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_ADD
  261. #else
  262. #define LDAP_CHANGETYPE_ADD 1
  263. #endif
  264. #endif
  265. #ifndef LDAP_CHANGETYPE_DELETE
  266. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_DELETE
  267. #define LDAP_CHANGETYPE_DELETE LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_DELETE
  268. #else
  269. #define LDAP_CHANGETYPE_DELETE 2
  270. #endif
  271. #endif
  272. #ifndef LDAP_CHANGETYPE_MODIFY
  273. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_MODIFY
  274. #define LDAP_CHANGETYPE_MODIFY LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_MODIFY
  275. #else
  276. #define LDAP_CHANGETYPE_MODIFY 4
  277. #endif
  278. #endif
  279. #ifndef LDAP_CHANGETYPE_MODDN
  280. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_RENAME
  281. #define LDAP_CHANGETYPE_MODDN LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_RENAME
  282. #else
  283. #define LDAP_CHANGETYPE_MODDN 8
  284. #endif
  285. #endif
  286. #ifndef LDAP_CHANGETYPE_ANY
  287. #define LDAP_CHANGETYPE_ANY (1|2|4|8)
  288. #endif
  289. #ifndef LDAP_CONTROL_PERSISTENTSEARCH
  290. #ifdef LDAP_CONTROL_PERSIST_REQUEST
  291. #define LDAP_CONTROL_PERSISTENTSEARCH LDAP_CONTROL_PERSIST_REQUEST
  292. #else
  293. #define LDAP_CONTROL_PERSISTENTSEARCH "2.16.840.1.113730.3.4.3"
  294. #endif
  295. #endif
  296. #ifndef LDAP_CONTROL_ENTRYCHANGE
  297. #ifdef LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE
  298. #define LDAP_CONTROL_ENTRYCHANGE LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE
  299. #else
  300. #define LDAP_CONTROL_ENTRYCHANGE "2.16.840.1.113730.3.4.7"
  301. #endif
  302. #endif
  303. #ifndef LDAP_CONTROL_PWEXPIRED
  304. #define LDAP_CONTROL_PWEXPIRED "2.16.840.1.113730.3.4.4"
  305. #endif
  306. #ifndef LDAP_CONTROL_PWEXPIRING
  307. #define LDAP_CONTROL_PWEXPIRING "2.16.840.1.113730.3.4.5"
  308. #endif
  309. #ifndef LDAP_X_CONTROL_PWPOLICY_REQUEST
  310. #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
  311. #define LDAP_X_CONTROL_PWPOLICY_REQUEST LDAP_CONTROL_PASSWORDPOLICYREQUEST
  312. #else
  313. #define LDAP_X_CONTROL_PWPOLICY_REQUEST "1.3.6.1.4.1.42.2.27.8.5.1"
  314. #endif
  315. #endif
  316. #ifndef LDAP_X_CONTROL_PWPOLICY_RESPONSE
  317. #ifdef LDAP_CONTROL_PASSWORDPOLICYRESPONSE
  318. #define LDAP_X_CONTROL_PWPOLICY_RESPONSE LDAP_CONTROL_PASSWORDPOLICYRESPONSE
  319. #else
  320. #define LDAP_X_CONTROL_PWPOLICY_RESPONSE "1.3.6.1.4.1.42.2.27.8.5.1"
  321. #endif
  322. #endif
  323. #ifndef LDAP_CONTROL_PROXYAUTH
  324. #define LDAP_CONTROL_PROXYAUTH "2.16.840.1.113730.3.4.12" /* version 1 */
  325. #endif
  326. #ifndef LDAP_CONTROL_PROXIEDAUTH
  327. #ifdef LDAP_CONTROL_PROXY_AUTHZ
  328. #define LDAP_CONTROL_PROXIEDAUTH LDAP_CONTROL_PROXY_AUTHZ
  329. #else
  330. #define LDAP_CONTROL_PROXIEDAUTH "2.16.840.1.113730.3.4.18" /* version 2 */
  331. #endif
  332. #endif
  333. #ifndef LDAP_CONTROL_AUTH_REQUEST
  334. #define LDAP_CONTROL_AUTH_REQUEST "2.16.840.1.113730.3.4.16"
  335. #endif
  336. /* Read Entry Controls - PRE & POST */
  337. #ifndef LDAP_CONTROL_PRE_READ_ENTRY
  338. #define LDAP_CONTROL_PRE_READ_ENTRY "1.3.6.1.1.13.1"
  339. #endif
  340. #ifndef LDAP_CONTROL_POST_READ_ENTRY
  341. #define LDAP_CONTROL_POST_READ_ENTRY "1.3.6.1.1.13.2"
  342. #endif
  343. #ifndef LDAP_SORT_CONTROL_MISSING
  344. #define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 (server side sort extn) */
  345. #endif
  346. #ifndef LDAP_INDEX_RANGE_ERROR
  347. #define LDAP_INDEX_RANGE_ERROR 0x3D /* 61 (VLV extn) */
  348. #endif
  349. /* openldap does not use this */
  350. #ifndef LBER_OVERFLOW
  351. #define LBER_OVERFLOW ((ber_tag_t) -3) /* 0xfffffffdU */
  352. #endif
  353. #ifndef LDAP_MAXINT
  354. /* RFC 4511: maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- */
  355. #define LDAP_MAXINT (2147483647)
  356. #endif
  357. /* for mozldap builds */
  358. #ifndef LDAP_CANCELLED
  359. #define LDAP_CANCELLED 0x76
  360. #endif
  361. #ifndef LDAP_RES_INTERMEDIATE
  362. #define LDAP_RES_INTERMEDIATE ((ber_tag_t) 0x79U)
  363. #endif
  364. #ifndef LDAP_TAG_IM_RES_OID
  365. #define LDAP_TAG_IM_RES_OID ((ber_tag_t) 0x80U)
  366. #endif
  367. #ifndef LDAP_TAG_IM_RES_VALUE
  368. #define LDAP_TAG_IM_RES_VALUE ((ber_tag_t) 0x81U)
  369. #endif
  370. #ifndef LDAP_SCOPE_ONE
  371. #define LDAP_SCOPE_ONE LDAP_SCOPE_ONELEVEL
  372. #endif
  373. #ifndef LDAP_SYNC_OID
  374. /* LDAP Content Synchronization Operation -- RFC 4533 */
  375. #define LDAP_SYNC_OID "1.3.6.1.4.1.4203.1.9.1"
  376. #define LDAP_CONTROL_SYNC LDAP_SYNC_OID ".1"
  377. #define LDAP_CONTROL_SYNC_STATE LDAP_SYNC_OID ".2"
  378. #define LDAP_CONTROL_SYNC_DONE LDAP_SYNC_OID ".3"
  379. #define LDAP_SYNC_INFO LDAP_SYNC_OID ".4"
  380. #define LDAP_TAG_SYNC_NEW_COOKIE ((ber_tag_t) 0x80U)
  381. #define LDAP_TAG_SYNC_REFRESH_DELETE ((ber_tag_t) 0xa1U)
  382. #define LDAP_TAG_SYNC_REFRESH_PRESENT ((ber_tag_t) 0xa2U)
  383. #define LDAP_TAG_SYNC_ID_SET ((ber_tag_t) 0xa3U)
  384. #define LDAP_SYNC_NONE 0x00
  385. #define LDAP_SYNC_REFRESH_ONLY 0x01
  386. #define LDAP_SYNC_RESERVED 0x02
  387. #define LDAP_SYNC_REFRESH_AND_PERSIST 0x03
  388. #define LDAP_SYNC_REFRESH_PRESENTS 0
  389. #define LDAP_SYNC_REFRESH_DELETES 1
  390. #define LDAP_TAG_SYNC_COOKIE ((ber_tag_t) 0x04U)
  391. #define LDAP_TAG_REFRESHDELETES ((ber_tag_t) 0x01U)
  392. #define LDAP_TAG_REFRESHDONE ((ber_tag_t) 0x01U)
  393. #define LDAP_TAG_RELOAD_HINT ((ber_tag_t) 0x01U)
  394. #define LDAP_SYNC_PRESENT 0
  395. #define LDAP_SYNC_ADD 1
  396. #define LDAP_SYNC_MODIFY 2
  397. #define LDAP_SYNC_DELETE 3
  398. #define LDAP_SYNC_NEW_COOKIE 4
  399. #endif
  400. #ifndef LDAP_REQ_BIND
  401. #define LDAP_REQ_BIND ((ber_tag_t) 0x60U) /* application + constructed */
  402. #define LDAP_REQ_UNBIND ((ber_tag_t) 0x42U) /* application + primitive */
  403. #define LDAP_REQ_SEARCH ((ber_tag_t) 0x63U) /* application + constructed */
  404. #define LDAP_REQ_MODIFY ((ber_tag_t) 0x66U) /* application + constructed */
  405. #define LDAP_REQ_ADD ((ber_tag_t) 0x68U) /* application + constructed */
  406. #define LDAP_REQ_DELETE ((ber_tag_t) 0x4aU) /* application + primitive */
  407. #define LDAP_REQ_MODDN ((ber_tag_t) 0x6cU) /* application + constructed */
  408. #define LDAP_REQ_MODRDN LDAP_REQ_MODDN
  409. #define LDAP_REQ_RENAME LDAP_REQ_MODDN
  410. #define LDAP_REQ_COMPARE ((ber_tag_t) 0x6eU) /* application + constructed */
  411. #define LDAP_REQ_ABANDON ((ber_tag_t) 0x50U) /* application + primitive */
  412. #define LDAP_REQ_EXTENDED ((ber_tag_t) 0x77U) /* application + constructed */
  413. #endif
  414. #ifndef LDAP_SYNC_PRESENT
  415. #define LDAP_SYNC_PRESENT 0
  416. #define LDAP_SYNC_ADD 1
  417. #define LDAP_SYNC_MODIFY 2
  418. #define LDAP_SYNC_DELETE 3
  419. #define LDAP_SYNC_NEW_COOKIE 4
  420. #endif
  421. /*
  422. * Sequential access types
  423. */
  424. #define SLAPI_SEQ_FIRST 1
  425. #define SLAPI_SEQ_LAST 2
  426. #define SLAPI_SEQ_PREV 3
  427. #define SLAPI_SEQ_NEXT 4
  428. /*
  429. * return codes from a backend API call
  430. */
  431. #define SLAPI_FAIL_GENERAL -1
  432. #define SLAPI_FAIL_DISKFULL -2
  433. /*
  434. * return codes used by BIND functions
  435. */
  436. #define SLAPI_BIND_SUCCESS 0 /* front end will send result */
  437. #define SLAPI_BIND_FAIL 2 /* back end should send result */
  438. #define SLAPI_BIND_ANONYMOUS 3 /* front end will send result */
  439. /* commonly used attributes names */
  440. #define SLAPI_ATTR_UNIQUEID "nsuniqueid"
  441. #define SLAPI_ATTR_OBJECTCLASS "objectclass"
  442. #define SLAPI_ATTR_VALUE_TOMBSTONE "nsTombstone"
  443. #define SLAPI_ATTR_VALUE_PARENT_UNIQUEID "nsParentUniqueID"
  444. #define SLAPI_ATTR_VALUE_SUBENTRY "ldapsubentry"
  445. #define SLAPI_ATTR_NSCP_ENTRYDN "nscpEntryDN"
  446. #define SLAPI_ATTR_ENTRYUSN "entryusn"
  447. #define SLAPI_ATTR_ENTRYDN "entrydn"
  448. #define SLAPI_ATTR_DN "dn"
  449. #define SLAPI_ATTR_RDN "rdn"
  450. #define SLAPI_ATTR_UNIQUEID_LENGTH 10
  451. #define SLAPI_ATTR_OBJECTCLASS_LENGTH 11
  452. #define SLAPI_ATTR_VALUE_TOMBSTONE_LENGTH 11
  453. #define SLAPI_ATTR_VALUE_PARENT_UNIQUEID_LENGTH 16
  454. #define SLAPI_ATTR_VALUE_SUBENTRY_LENGTH 12
  455. #define SLAPI_ATTR_NSCP_ENTRYDN_LENGTH 11
  456. #define SLAPI_ATTR_ENTRYUSN_LENGTH 8
  457. #define SLAPI_ATTR_ENTRYDN_LENGTH 7
  458. #define SLAPI_ATTR_DN_LENGTH 2
  459. #define SLAPI_ATTR_RDN_LENGTH 3
  460. /* plugin shared config area */
  461. #define SLAPI_PLUGIN_SHARED_CONFIG_AREA "nsslapd-pluginConfigArea"
  462. /* opaque structures */
  463. /**
  464. * Contains name-value pairs, known as parameter blocks, that you can get or set for
  465. * each LDAP operation.
  466. *
  467. * #Slapi_PBlock contains name-value pairs that you can use to retrieve information
  468. * from the server and set information to be used by the server.
  469. *
  470. * For most types of plug-in functions, the server passes in a #Slapi_PBlock
  471. * structure that typically includes data relevant to the operation being processed.
  472. * You can get the value of a parameter by calling the slapi_pblock_get() function.
  473. *
  474. * For example, when the plug-in function for an LDAP bind operation is called, the
  475. * server puts the DN and credentials in the #SLAPI_BIND_TARGET and
  476. * #SLAPI_BIND_CREDENTIALS parameters of the Slapi_PBlock structure. You can
  477. * call slapi_pblock_get() to get the DN and credentials of the client requesting
  478. * authentication.
  479. *
  480. * For plug-in initialization functions, you can use the #Slapi_PBlock structure to
  481. * pass information to the server, such as the description of your plug-in and the
  482. * names of your plug-in functions. You can set the value of a parameter by calling
  483. * the slapi_pblock_set() function.
  484. *
  485. * For example, in order to register a pre-operation bind plug-in function, you need to
  486. * call slapi_pblock_set() to set the version number, description, and name of the
  487. * plug-in function as the #SLAPI_PLUGIN_VERSION, #SLAPI_PLUGIN_DESCRIPTION,
  488. * and #SLAPI_PLUGIN_PRE_BIND_FN parameters.
  489. *
  490. * The available parameters that you can use depends on the type of plug-in function
  491. * you are writing.
  492. */
  493. typedef struct slapi_pblock Slapi_PBlock;
  494. /**
  495. * Represents an entry in the directory.
  496. *
  497. * #Slapi_Entry is the data type for an opaque structure that represents an entry in
  498. * the directory. In certain cases, your server plug-in may need to work with an entry
  499. * in the directory.
  500. */
  501. typedef struct slapi_entry Slapi_Entry;
  502. /**
  503. * Represents an attribute in an entry.
  504. *
  505. * #Slapi_Attr is the data type for an opaque structure that represents an attribute
  506. * in a directory entry. In certain cases, your server plug-in may need to work with
  507. * an entry’s attributes.
  508. */
  509. typedef struct slapi_attr Slapi_Attr;
  510. /**
  511. * Represents the value of the attribute in a directory entry.
  512. *
  513. * #Slapi_Value is the data type for an opaque structure that represents the value of
  514. * an attribute in a directory entry.
  515. */
  516. typedef struct slapi_value Slapi_Value;
  517. /**
  518. * Represents a set of Slapi_Value (or a list of Slapi_Value).
  519. *
  520. * #Slapi_ValueSet is the data type for an opaque structure that represents set of
  521. * #Slapi_Value (or a list of #Slapi_Value).
  522. */
  523. typedef struct slapi_value_set Slapi_ValueSet;
  524. /**
  525. * Represents a search filter.
  526. *
  527. * #Slapi_Filter is the data type for an opaque structure that represents an search
  528. * filter.
  529. */
  530. typedef struct slapi_filter Slapi_Filter;
  531. /**
  532. * Represents a backend operation in the server plug-in.
  533. *
  534. * #Slapi_Backend is the data type for an opaque structure that represents a backend
  535. * operation.
  536. */
  537. typedef struct backend Slapi_Backend;
  538. /**
  539. * Represents password scheme information
  540. */
  541. typedef struct pw_scheme PWScheme;
  542. /**
  543. * Represents the unique identifier of a directory entry.
  544. *
  545. * #Slapi_UniqueID is the data type for an opaque structure that represents the
  546. * unique identifier of a directory entry. All directory entries contain a unique
  547. * identifier. Unlike the distinguished name (DN), the unique identifier of an entry
  548. * never changes, providing a good way to refer unambiguously to an entry in a
  549. * distributed/replicated environment.
  550. */
  551. typedef struct _guid_t Slapi_UniqueID;
  552. /**
  553. * Represents an operation pending from an LDAP client.
  554. *
  555. * #Slapi_Operation is the data type for an opaque structure that represents an
  556. * operation pending from an LDAP client.
  557. */
  558. typedef struct op Slapi_Operation;
  559. /**
  560. * Represents a connection.
  561. *
  562. * #Slapi_Connection is the data type for an opaque structure that represents a
  563. * connection.
  564. */
  565. typedef struct conn Slapi_Connection;
  566. /**
  567. * Represents a distinguished name in a directory entry.
  568. *
  569. * #Slapi_DN is the data type for an opaque structure that represents a distinguished
  570. * name in the server plug-in.
  571. */
  572. typedef struct slapi_dn Slapi_DN;
  573. /**
  574. * Represents a relative distinguished name in a directory entry.
  575. *
  576. * #Slapi_RDN is the data type for an opaque structure that represents a relative
  577. * distinguished name in the server plug-in.
  578. */
  579. typedef struct slapi_rdn Slapi_RDN;
  580. /**
  581. * Represents a single LDAP modification to a directory entry.
  582. *
  583. * #Slapi_Mod is the data type for an opaque structure that represents LDAPMod
  584. * modifications to an attribute in a directory entry.
  585. */
  586. typedef struct slapi_mod Slapi_Mod;
  587. /**
  588. * Represents two or more LDAP modifications to a directory entry
  589. *
  590. * #Slapi_Mods is the data type for an opaque structure that represents LDAPMod
  591. * manipulations that can be made to a directory entry.
  592. */
  593. typedef struct slapi_mods Slapi_Mods;
  594. /**
  595. * Represents a the component ID in a directory entry.
  596. *
  597. * #Slapi_ComponentId is the data type for an opaque structure that represents the
  598. * component ID in a directory entry.
  599. */
  600. typedef struct slapi_componentid Slapi_ComponentId;
  601. /**
  602. * Represents an integral counter.
  603. *
  604. * Provides 64-bit integers with support for atomic operations, even on 32-bit
  605. * systems. This lets your plug-in have global integers that can be updated by
  606. * multiple worker threads in a thread-safe manner.
  607. *
  608. * The #Slapi_Counter structure is a wrapper around the actual counter value
  609. */
  610. typedef struct slapi_counter Slapi_Counter;
  611. /* Online tasks interface (to support import, export, etc) */
  612. #define SLAPI_TASK_PUBLIC 1 /* tell old plugins that the task api is now public */
  613. /**
  614. * An opaque structure that represents a task that has been initiated.
  615. *
  616. * Common Directory Server tasks, including importing, exporting, and indexing
  617. * databases, can be initiated through a special task configuration entry in
  618. * cn=tasks,cn=config. These task operations are managed using the #Slapi_Task
  619. * structure.
  620. */
  621. typedef struct slapi_task Slapi_Task;
  622. typedef struct passwordpolicyarray Slapi_PWPolicy;
  623. /**
  624. * Defines a callback used specifically by Slapi_Task structure cancel and
  625. * destructor functions.
  626. *
  627. * \param task The task that is being cancelled or destroyed.
  628. */
  629. typedef void (*TaskCallbackFn)(Slapi_Task *task);
  630. /*
  631. * The default thread stacksize for nspr21 is 64k (except on IRIX! It's 32k!).
  632. * For OSF, we require a larger stacksize as actual storage allocation is
  633. * higher i.e pointers are allocated 8 bytes but lower 4 bytes are used.
  634. * The value 0 means use the default stacksize.
  635. *
  636. * larger stacksize (256KB) is needed on IRIX due to its 4KB BUFSIZ.
  637. * (@ pthread IRIX porting -- 01/11/99)
  638. *
  639. * HP-UX on PA-RISC uses 64KB default stack size. Just set to 256K for all
  640. * HP-UX.
  641. */
  642. #if ( defined( irix ))
  643. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  644. #elif ( defined ( OSF1 ))
  645. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  646. #elif ( defined ( AIX ))
  647. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  648. #elif ( defined ( hpux ))
  649. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  650. #else
  651. /* All other platforms use the default stack size */
  652. #define SLAPD_DEFAULT_THREAD_STACKSIZE 0
  653. #endif
  654. /*---------------------------
  655. * parameter block routines
  656. *--------------------------*/
  657. /**
  658. * Creates a new parameter block.
  659. *
  660. * \return This function returns a pointer to the new parameter block.
  661. * \warning The pblock pointer allocated with this function must always be freed by
  662. * slapi_pblock_destroy(). The use of other memory deallocators (for example,
  663. * <tt>free()</tt>) is not supported and may lead to crashes or memory leaks.
  664. * \see slapi_pblock_destroy()
  665. */
  666. Slapi_PBlock *slapi_pblock_new( void ); /* allocate and initialize */
  667. /**
  668. * Initializes an existing parameter block for re-use.
  669. *
  670. * \param pb The parameter block to initialize.
  671. * \warning The parameter block that you wish to free must have been created using
  672. * slapi_pblock_new(). When you are finished with the parameter block, you
  673. * must free it using the slapi_pblock_destroy() function.
  674. *
  675. * \warning Note that search results will not be freed from the parameter block by
  676. * slapi_pblock_init(). You must free any internal search results with the
  677. * slapi_free_search_results_internal() function prior to calling
  678. * slapi_pblock_init(), otherwise the search results will be leaked.
  679. * \see slapi_pblock_new()
  680. * \see slapi_pblock_destroy()
  681. * \see slapi_free_search_results_internal()
  682. */
  683. void slapi_pblock_init( Slapi_PBlock *pb ); /* clear out for re-use */
  684. /**
  685. * Gets the value of a name-value pair from a parameter block.
  686. *
  687. * \param pb Parameter block.
  688. * \param arg ID of the name-value pair that you want to get.
  689. * \param value Pointer to the value retrieved from the parameter block.
  690. * \return \c 0 if successful.
  691. * \return \c -1 if an error occurs (for example, if an invalid ID is specified).
  692. * \todo Document valid values for the ID.
  693. * \warning The <tt>void *value</tt> argument should always be a pointer to the
  694. * type of value you are retrieving:
  695. * \code
  696. * int connid = 0;
  697. * ...
  698. * retval = slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
  699. * \endcode
  700. *
  701. * \warning #SLAPI_CONN_ID is an integer value, so you will pass in a pointer
  702. * to/address of an integer to get the value. Similarly, for a
  703. * <tt>char *</tt> value (a string), pass in a pointer to/address of the value.
  704. * For example:
  705. * \code
  706. * char *binddn = NULL;
  707. * ...
  708. * retval = slapi_pblock_get(pb, SLAPI_CONN_DN, &binddn);
  709. * \endcode
  710. *
  711. * \warning With certain compilers on some platforms, you may have to cast the
  712. * value to <tt>(void *)</tt>.
  713. *
  714. * \warning We recommend that you set the value to \c 0 or \c NULL before calling
  715. * slapi_pblock_get() to avoid reading from uninitialized memory, in
  716. * case the call to slapi_pblock_get() fails.
  717. *
  718. * \warning In most instances, the caller should not free the returned value.
  719. * The value will usually be freed internally or through the call to
  720. * slapi_pblock_destroy(). The exception is if the value is explicitly
  721. * set by the caller through slapi_pblock_set(). In this case, the caller
  722. * is responsible for memory management. If the value is freed, it is
  723. * strongly recommended that the free is followed by a call to
  724. * slapi_pblock_set() with a value of \c NULL. For example:
  725. * \code
  726. * char *someparam = NULL;
  727. * ...
  728. * someparam = slapi_ch_strdup(somestring);
  729. * slapi_pblock_set(pb, SOME_PARAM, someparam);
  730. * someparam = NULL;
  731. * ...
  732. * slapi_pblock_get(pb, SOME_PARAM, &someparam);
  733. * slapi_pblock_set(pb, SOME_PARAM, NULL);
  734. * slapi_ch_free_string(&someparam);
  735. * ...
  736. * \endcode
  737. *
  738. * \warning Some internal functions may change the value passed in, so it is
  739. * recommended to use slapi_pblock_get() to retrieve the value again,
  740. * rather than relying on a potential dangling pointer. This is shown
  741. * in the example above, which sets someparam to \c NULL after setting
  742. * it in the pblock.
  743. *
  744. * \see slapi_pblock_destroy()
  745. * \see slapi_pblock_set()
  746. */
  747. int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value );
  748. /**
  749. * Sets the value of a name-value pair in a parameter block.
  750. *
  751. * \param pb Parameter block.
  752. * \param arg ID of the name-value pair that you want to get.
  753. * \param value Pointer to the value you want to set in the parameter block.
  754. * \return \c 0 if successful.
  755. * \return \c -1 if an error occurs (for example, if an invalid ID is specified).
  756. * \warning The value to be passed in must always be a pointer, even for integer
  757. * arguments. For example, if you wanted to do a search with the
  758. * \c ManageDSAIT control:
  759. * \code
  760. * int managedsait = 1;
  761. * ...
  762. * slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, &managedsait);
  763. * \endcode
  764. *
  765. * \warning A call similar to the following example will cause a crash:
  766. * \code
  767. * slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, 1);
  768. * \endcode
  769. *
  770. * \warning However, for values which are already pointers, (<tt>char * string</tt>,
  771. * <tt>char **arrays</tt>, <tt>#Slapi_Backend *</tt>, etc.), you can pass
  772. * in the value directly. For example:
  773. * \code
  774. * Slapi_DN *target_sdn = slapi_sdn_dup(some_sdn);
  775. * slapi_pblock_set(pb, SLAPI_TARGET_SDN, target_sdn);
  776. * \endcode
  777. *
  778. * \warning or
  779. * \code
  780. * slapi_pblock_set(pb, SLAPI_TARGET_SDN, NULL);
  781. * \endcode
  782. *
  783. * \warning With some compilers, you will have to cast the value argument to
  784. * <tt>(void *)</tt>. If the caller allocates the memory passed in, the
  785. * caller is responsible for freeing that memory. Also, it is recommended
  786. * to use slapi_pblock_get() to retrieve the value to free, rather than
  787. * relying on a potentially dangling pointer. See the slapi_pblock_get()
  788. * example for more details.
  789. *
  790. * \warning When setting parameters to register a plug-in, the plug-in type must
  791. * always be set first, since many of the plug-in parameters depend on
  792. * the type. For example, set the #SLAPI_PLUGIN_TYPE to extended
  793. * operation before setting the list of extended operation OIDs for
  794. * the plug-in.
  795. *
  796. * \see slapi_pblock_get()
  797. */
  798. int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value );
  799. /**
  800. * Frees the specified parameter block from memory.
  801. *
  802. * \param pb Parameter block you want to free.
  803. * \warning The parameter block that you wish to free must have been created
  804. * using slapi_pblock_new(). Use of this function with parameter
  805. * blocks allocated on the stack (for example, <tt>#Slapi_PBlock pb;</tt>)
  806. * or using another memory allocator is not supported and may lead to
  807. * memory errors and memory leaks. For example:
  808. * \code
  809. * Slapi_PBlock *pb = malloc(sizeof(Slapi_PBlock));
  810. * \endcode
  811. *
  812. * \warning After calling this function, you should set the parameter block
  813. * pointer to \c NULL to avoid reusing freed memory in your function
  814. * context, as in the following:
  815. * \code
  816. * slapi_pblock_destroy(pb);
  817. * pb =NULL;
  818. * \endcode
  819. *
  820. * \warning If you reuse the pointer in this way, it makes it easier to
  821. * identify a Segmentation Fault, rather than using some difficult
  822. * method to detect memory leaks or other abnormal behavior.
  823. *
  824. * \warning It is safe to call this function with a \c NULL pointer. For
  825. * example:
  826. * \code
  827. * Slapi_PBlock *pb = NULL;
  828. * slapi_pblock_destroy(pb);
  829. * \endcode
  830. *
  831. * \warning This saves the trouble of checking for \c NULL before calling
  832. * slapi_pblock_destroy().
  833. *
  834. * \see slapi_pblock_new()
  835. */
  836. void slapi_pblock_destroy( Slapi_PBlock *pb );
  837. /*----------------
  838. * entry routines
  839. *---------------*/
  840. /**
  841. * Converts an LDIF description of a directory entry (a string value) into
  842. * an entry of the #Slapi_Entry type.
  843. *
  844. * A directory entry can be described by a string in LDIF format. Calling
  845. * the slapi_str2entry() function converts a string description in this
  846. * format to a #Slapi_Entry structure, which you can pass to other API
  847. * functions.
  848. *
  849. * \param s Description of an entry that you want to convert to a #Slapi_Entry.
  850. * \param flags One or more flags specifying how the entry should be generated.
  851. * The valid values of the \c flags argument are:
  852. * \arg #SLAPI_STR2ENTRY_REMOVEDUPVALS
  853. * \arg #SLAPI_STR2ENTRY_ADDRDNVALS
  854. * \arg #SLAPI_STR2ENTRY_BIGENTRY
  855. * \arg #SLAPI_STR2ENTRY_TOMBSTONE_CHECK
  856. * \arg #SLAPI_STR2ENTRY_IGNORE_STATE
  857. * \arg #SLAPI_STR2ENTRY_INCLUDE_VERSION_STR
  858. * \arg #SLAPI_STR2ENTRY_EXPAND_OBJECTCLASSES
  859. * \arg #SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF
  860. * \arg #SLAPI_STR2ENTRY_NO_SCHEMA_LOCK
  861. * \arg #SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT
  862. * \arg #SLAPI_STR2ENTRY_NO_ENTRYDN
  863. * \arg #SLAPI_STR2ENTRY_DN_NORMALIZED
  864. *
  865. * \return A pointer to the #Slapi_Entry structure representing the entry.
  866. * \return \c NULL if the string cannot be converted; for example, if no DN is
  867. * specified in the string.
  868. * \warning This function modifies the string argument s. If you still need to
  869. * use this string value, you should make a copy of this string before
  870. * calling slapi_str2entry().
  871. *
  872. * \warning When you are done working with the entry, you should call the
  873. * slapi_entry_free() function.
  874. *
  875. * \note To convert an entry to a string description, call the slapi_entry2str()
  876. * function.
  877. *
  878. * \see slapi_entry_free()
  879. * \see slapi_entry2str()
  880. */
  881. Slapi_Entry *slapi_str2entry( char *s, int flags );
  882. /*
  883. * Same as slapi_str2entry except passing optional dn and rdn structure as argument
  884. */
  885. Slapi_Entry *slapi_str2entry_ext( const char *dn, const Slapi_RDN *srdn, char *s, int flags );
  886. /*-----------------------------
  887. * Flags for slapi_str2entry()
  888. *----------------------------*/
  889. /**
  890. * Removes any duplicate values in the attributes of the entry.
  891. *
  892. * \see slapi_str2entry()
  893. */
  894. #define SLAPI_STR2ENTRY_REMOVEDUPVALS 1
  895. /**
  896. * Adds the relative distinguished name (RDN) components (for example,
  897. * \c uid=bjensen) as attributes of the entry.
  898. *
  899. * \see slapi_str2entry()
  900. */
  901. #define SLAPI_STR2ENTRY_ADDRDNVALS 2
  902. /**
  903. * Provide a hint that the entry is large. This enables some optimizations
  904. * related to large entries.
  905. *
  906. * \see slapi_str2entry()
  907. */
  908. #define SLAPI_STR2ENTRY_BIGENTRY 4
  909. /**
  910. * Check to see if the entry is a tombstone. If so, set the tombstone flag
  911. * (#SLAPI_ENTRY_FLAG_TOMBSTONE).
  912. *
  913. * \see slapi_str2entry()
  914. */
  915. #define SLAPI_STR2ENTRY_TOMBSTONE_CHECK 8
  916. /**
  917. * Ignore entry state information if present.
  918. *
  919. * \see slapi_str2entry()
  920. */
  921. #define SLAPI_STR2ENTRY_IGNORE_STATE 16
  922. /**
  923. * Return entries that have a <tt>version: 1</tt> line as part of the LDIF
  924. * representation.
  925. *
  926. * \see slapi_str2entry()
  927. */
  928. #define SLAPI_STR2ENTRY_INCLUDE_VERSION_STR 32
  929. /**
  930. * Add any missing ancestor values based on the object class hierarchy.
  931. *
  932. * \see slapi_str2entry()
  933. */
  934. #define SLAPI_STR2ENTRY_EXPAND_OBJECTCLASSES 64
  935. /**
  936. * Inform slapi_str2entry() that the LDIF input is not well formed.
  937. *
  938. * Well formed LDIF has no duplicate attribute values, already has the RDN
  939. * as an attribute of the entry, and has all values for a given attribute
  940. * type listed contiguously.
  941. *
  942. * \see slapi_str2entry()
  943. */
  944. #define SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF 128
  945. /**
  946. * Don't acquire the schema lock.
  947. *
  948. * You should use this flag if you are sure that the lock is already held,
  949. * or if the server has not started it's threads yet during startup.
  950. *
  951. * \see slapi_str2entry()
  952. */
  953. #define SLAPI_STR2ENTRY_NO_SCHEMA_LOCK 256
  954. /**
  955. * Normalize DN using obsolete DN normalizer.
  956. *
  957. * This marco is used only for the upgrading dn format tool.
  958. *
  959. * \see slapi_str2entry()
  960. */
  961. #define SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT 512
  962. /**
  963. * Do not include entrydn attribute value in the in-memory entry
  964. *
  965. * If this flag is set, entrydn in the source string is ignored.
  966. *
  967. * \see slapi_str2entry()
  968. */
  969. #define SLAPI_STR2ENTRY_NO_ENTRYDN 1024
  970. /**
  971. * Passed DN is already normalized.
  972. *
  973. * If this flag is set, str2entry assumes passed DN is already normalized.
  974. *
  975. * \see slapi_str2entry()
  976. */
  977. #define SLAPI_STR2ENTRY_DN_NORMALIZED 2048
  978. /**
  979. * Generates a description of an entry as an LDIF string.
  980. *
  981. * This function behaves much like slapi_entry2str(); however, you can specify
  982. * output options with this function.
  983. *
  984. * This function generates an LDIF string value conforming to the following syntax:
  985. * \code
  986. * dn: dn\n
  987. * [attr: value\n]*
  988. * \endcode
  989. *
  990. * For example:
  991. * \code
  992. * dn: uid=jdoe, ou=People, dc=example,dc=com
  993. * cn: Jane Doe
  994. * sn: Doe
  995. * ...
  996. * \endcode
  997. *
  998. * To convert an entry described in LDIF string format to an LDAP entry using
  999. * the #Slapi_Entry data type, call the slapi_str2entry() function.
  1000. *
  1001. * \param e Entry that you want to convert into an LDIF string.
  1002. * \param len Length of the LDIF string returned by this function.
  1003. * \param options An option set that specifies how you want the string
  1004. * converted. You can \c OR together any of the following options
  1005. * when you call this function:
  1006. * \arg #SLAPI_DUMP_STATEINFO
  1007. * \arg #SLAPI_DUMP_UNIQUEID
  1008. * \arg #SLAPI_DUMP_NOOPATTRS
  1009. * \arg #SLAPI_DUMP_NOWRAP
  1010. * \arg #SLAPI_DUMP_MINIMAL_ENCODING
  1011. * \return The LDIF string representation of the entry you specify.
  1012. * \return \c NULL if an error occurs.
  1013. * \warning When you no longer need to use the string, you should free it
  1014. * from memory by calling the slapi_ch_free_string() function.
  1015. *
  1016. * \see slapi_entry2str()
  1017. * \see slapi_str2entry()
  1018. */
  1019. char *slapi_entry2str_with_options( Slapi_Entry *e, int *len, int options );
  1020. /*---------------------------------------------
  1021. * Options for slapi_entry2str_with_options()
  1022. *--------------------------------------------*/
  1023. /**
  1024. * Output entry with replication state info.
  1025. *
  1026. * This allows access to the internal data used by multi-master replication.
  1027. *
  1028. * \see slapi_entry2str_with_options()
  1029. */
  1030. #define SLAPI_DUMP_STATEINFO 1 /* replication state */
  1031. /**
  1032. * Output entry with uniqueid.
  1033. *
  1034. * This option is used when creating an LDIF file to be used to initialize
  1035. * a replica. Each entry will contain the nsuniqueID operational attribute.
  1036. *
  1037. * \see slapi_entry2str_with_options()
  1038. */
  1039. #define SLAPI_DUMP_UNIQUEID 2 /* unique ID */
  1040. /**
  1041. * Output entry without operational attributes.
  1042. *
  1043. * By default, certain operational attributes (such as \c creatorsName,
  1044. * \c modifiersName, \c createTimestamp, \c modifyTimestamp) may be
  1045. * included in the output. With this option, no operational attributes
  1046. * will be included.
  1047. *
  1048. * \see slapi_entry2str_with_options()
  1049. */
  1050. #define SLAPI_DUMP_NOOPATTRS 4 /* suppress operational attrs */
  1051. /**
  1052. * Output entry without LDIF line wrapping.
  1053. *
  1054. * By default, lines will be wrapped as defined in the LDIF specification.
  1055. * With this option, line wrapping is disabled.
  1056. *
  1057. * \see slapi_entry2str_with_options()
  1058. */
  1059. #define SLAPI_DUMP_NOWRAP 8 /* no line breaks */
  1060. /**
  1061. * Output entry with less base64 encoding.
  1062. *
  1063. * Uses as little base64 encoding as possible in the output.
  1064. *
  1065. * \see slapi_entry2str_with_options()
  1066. */
  1067. #define SLAPI_DUMP_MINIMAL_ENCODING 16 /* use less base64 encoding */
  1068. /**
  1069. * Output rdn based entry instead of dn based. Introduced for subtree rename.
  1070. *
  1071. * \see slapi_entry2str_with_options()
  1072. */
  1073. #define SLAPI_DUMP_RDN_ENTRY 32 /* rdn based entry */
  1074. /**
  1075. * Generates an LDIF string description of an LDAP entry.
  1076. *
  1077. * This function generates an LDIF string value conforming to the following syntax:
  1078. * \code
  1079. * dn: dn\n
  1080. * [attr: value\n]*
  1081. * \endcode
  1082. *
  1083. * For example:
  1084. * \code
  1085. * dn: uid=jdoe, ou=People, dc=example,dc=com
  1086. * cn: Jane Doe
  1087. * sn: Doe
  1088. * ...
  1089. * \endcode
  1090. *
  1091. * To convert an entry described in LDIF string format to an LDAP entry using
  1092. * the #Slapi_Entry data type, call the slapi_str2entry() function.
  1093. *
  1094. * \param e Entry that you want to convert into an LDIF string.
  1095. * \param len Length of the LDIF string returned by this function.
  1096. * \return The LDIF string representation of the entry you specify.
  1097. * \return \c NULL if an error occurs.
  1098. * \warning When you no longer need to use the string, you should free it
  1099. * from memory by calling the slapi_ch_free_string() function.
  1100. *
  1101. * \see slapi_entry2str_with_options()
  1102. * \see slapi_str2entry()
  1103. */
  1104. char *slapi_entry2str( Slapi_Entry *e, int *len );
  1105. /**
  1106. * Allocates memory for a new entry of the data type #Slapi_Entry.
  1107. *
  1108. * This function returns an empty #Slapi_Entry structure. You can call other
  1109. * front-end functions to set the DN and attributes of this entry.
  1110. *
  1111. * When you are no longer using the entry, you should free it from memory by
  1112. * calling the slapi_entry_free() function.
  1113. *
  1114. * \return This function returns a pointer to the newly allocated entry of the
  1115. * data type #Slapi_Entry. If space cannot be allocated, e.g., no more
  1116. * virtual memory exists, the \c ns-slapd program terminates.
  1117. * \warning When you no longer use the entry, free it from memory by calling the
  1118. * slapi_entry_free() function.
  1119. *
  1120. * \see slapi_entry_dup()
  1121. * \see slapi_entry_free()
  1122. */
  1123. Slapi_Entry *slapi_entry_alloc(void);
  1124. /**
  1125. * Initializes the values of an entry with the DN and attribute value pairs you
  1126. * supply.
  1127. *
  1128. * This function initializes the attributes and the corresponding attribute values
  1129. * of an entry. Also, during the course of processing, the unique ID of the entry
  1130. * is set to \c NULL, and the flag value is set to \c 0.
  1131. *
  1132. * Use this function to initialize a #Slapi_Entry pointer.
  1133. *
  1134. * \param e The entry you want to initialize.
  1135. * \param dn The DN of the entry you are initializing.
  1136. * \param a Initialization list of attribute value pairs, supplied as a
  1137. * #Slapi_Attr data value.
  1138. * \warning This function should always be used after slapi_entry_alloc() and
  1139. * never otherwise. For example:
  1140. * \code
  1141. * Slapi_Entry *e = slapi_entry_alloc();
  1142. * slapi_entry_init(e, NULL, NULL);
  1143. * \endcode
  1144. *
  1145. * \warning To set the DN in the entry:
  1146. * \code
  1147. * slapi_sdn_set_dn_passin(slapi_entry_get_sdn(e), dn);
  1148. * \endcode
  1149. *
  1150. * \warning In this case, the dn argument is not copied but is consumed by the
  1151. * function. To copy the argument, see the following example:
  1152. * \code
  1153. * char *dn = slapi_ch_strdup(some_dn);
  1154. * Slapi_Entry *e = slapi_entry_alloc();
  1155. * slapi_entry_init(e, dn, NULL);
  1156. * \endcode
  1157. *
  1158. * \warning The \c dn argument is not freed in this context but will eventually
  1159. * be freed when slapi_entry_free() is called.
  1160. *
  1161. * \see slapi_entry_free()
  1162. * \see slapi_entry_alloc()
  1163. */
  1164. void slapi_entry_init(Slapi_Entry *e, char *dn, Slapi_Attr *a);
  1165. /*
  1166. * Initializes the values of an entry with the Slapi_DN and attribute value
  1167. * pairs you supply.
  1168. */
  1169. void slapi_entry_init_ext(Slapi_Entry *e, Slapi_DN *sdn, Slapi_Attr *a);
  1170. /**
  1171. * Frees an entry, its DN, and its attributes from memory.
  1172. *
  1173. * Call this function to free an entry that you have allocated by using the
  1174. * slapi_entry_alloc() function or the slapi_entry_dup() function.
  1175. *
  1176. * \param e Entry that you want to free. If \c NULL, no action occurs.
  1177. * \warning To free entries, always use this function instead of using
  1178. * slapi_ch_free() or free().
  1179. *
  1180. * \see slapi_entry_alloc()
  1181. * \see slapi_entry_dup()
  1182. */
  1183. void slapi_entry_free( Slapi_Entry *e );
  1184. /**
  1185. * Makes a copy of an entry, its DN, and its attributes.
  1186. *
  1187. * This function returns a copy of an existing #Slapi_Entry structure. You can
  1188. * call other front-end functions to change the DN and attributes of this entry.
  1189. *
  1190. * \param e Entry that you want to copy.
  1191. * \return This function returns the new copy of the entry. If the structure
  1192. * cannot be duplicated, for example, if no more virtual memory exists,
  1193. * the \c ns-slapd program terminates.
  1194. * \warning When you are no longer using the entry, free it from memory by
  1195. * calling the slapi_entry_free() function.
  1196. * \see slapi_entry_alloc()
  1197. * \see slapi_entry_free()
  1198. */
  1199. Slapi_Entry *slapi_entry_dup( const Slapi_Entry *e );
  1200. /**
  1201. * Gets the distinguished name (DN) of the specified entry.
  1202. *
  1203. * \param e Entry from which you want to get the DN.
  1204. * \return This function returns the DN of the entry. This returns a pointer
  1205. * to the actual DN in the entry, not a copy of the DN. You should not
  1206. * free the DN unless you plan to replace it by calling slapi_entry_set_dn().
  1207. * \warning Use slapi_ch_free_string() if you are replacing the DN with
  1208. * slapi_entry_set_dn().
  1209. * \see slapi_ch_free_string()
  1210. * \see slapi_entry_set_dn()
  1211. */
  1212. char *slapi_entry_get_dn( Slapi_Entry *e );
  1213. /**
  1214. * Returns the normalized DN from the entry that you specify.
  1215. *
  1216. * \param e Entry from which you want to obtain the normalized DN.
  1217. * \return This function returns the normalized DN from the entry that you
  1218. * specify. If the entry you specify does not contain a normalized DN,
  1219. * one is created through the processing of this function.
  1220. * \warning Never free the returned value.
  1221. * \see slapi_entry_get_dn()
  1222. */
  1223. char *slapi_entry_get_ndn( Slapi_Entry *e );
  1224. /**
  1225. * Returns as a \c const the value of the #Slapi_DN object from the entry
  1226. * that you specify.
  1227. *
  1228. * \param e Entry from which you want to get the #Slapi_DN object.
  1229. * \return Returns as a \c const the #Slapi_DN object from the entry that you
  1230. * specify.
  1231. * \warning Never free the returned value. If you need a copy, use
  1232. * slapi_sdn_dup().
  1233. * \see slapi_sdn_dup()
  1234. * \see slapi_entry_get_sdn()
  1235. */
  1236. const Slapi_DN *slapi_entry_get_sdn_const( const Slapi_Entry *e );
  1237. /**
  1238. * Returns the #Slapi_DN object from the entry that you specify.
  1239. *
  1240. * \param e Entry from which you want to get the #Slapi_DN object.
  1241. * \return Returns the #Slapi_DN object from the entry that you specify.
  1242. * \warning Never free the returned value. If you need a copy, use
  1243. * slapi_sdn_dup().
  1244. * \see slapi_entry_get_sdn_const()
  1245. * \see slapi_sdn_dup()
  1246. */
  1247. Slapi_DN *slapi_entry_get_sdn( Slapi_Entry *e );
  1248. /**
  1249. * Returns as a \c const the value of the #Slapi_RDN from the entry
  1250. * that you specify.
  1251. *
  1252. * \param e Entry from which you want to get the #Slapi_RDN object.
  1253. * \return Returns as a \c const the #Slapi_RDN object from the entry that you
  1254. * specify.
  1255. * \warning Never free the returned value. If you need a copy, use
  1256. * slapi_sdn_dup().
  1257. * \see slapi_sdn_dup()
  1258. * \see slapi_entry_get_sdn()
  1259. */
  1260. const Slapi_RDN *slapi_entry_get_srdn_const( const Slapi_Entry *e );
  1261. /**
  1262. * Returns the #Slapi_RDN object from the entry that you specify.
  1263. *
  1264. * \param e Entry from which you want to get the #Slapi_RDN object.
  1265. * \return Returns the #Slapi_RDN object from the entry that you specify.
  1266. * \warning Never free the returned value. If you need a copy, use
  1267. * slapi_sdn_dup().
  1268. * \see slapi_entry_get_srdn_const()
  1269. * \see slapi_sdn_dup()
  1270. */
  1271. Slapi_RDN * slapi_entry_get_srdn( Slapi_Entry *e );
  1272. /**
  1273. * Returns as a \c const the DN value of the entry that you specify.
  1274. *
  1275. * \param e Entry from which you want to get the DN as a constant.
  1276. * \return This function returns one of the following values:
  1277. * \arg The DN of the entry that you specify. The DN is returned
  1278. * as a const; you are not able to modify the DN value.
  1279. * \arg The NDN value of Slapi_DN if the DN of the Slapi_DN object is NULL.
  1280. * \warning Never free the returned value.
  1281. * \see slapi_entry_set_sdn()
  1282. */
  1283. const char *slapi_entry_get_dn_const( const Slapi_Entry *e );
  1284. /**
  1285. * Returns as a \c const the RDN value of the entry that you specify.
  1286. *
  1287. * \param e Entry from which you want to get the RDN as a constant.
  1288. * \return This function returns one of the following values:
  1289. * \arg The RDN of the entry that you specify. The RDN is returned
  1290. * as a const; you are not able to modify the RDN value.
  1291. * \warning Never free the returned value.
  1292. * \see slapi_entry_set_srdn()
  1293. */
  1294. const char *slapi_entry_get_rdn_const( const Slapi_Entry *e );
  1295. /**
  1296. * Returns as a \c const the Normalized RDN value of the entry that you specify.
  1297. *
  1298. * \param e Entry from which you want to get the Normalized RDN as a constant.
  1299. * \return This function returns one of the following values:
  1300. * \arg The Normalized RDN of the entry that you specify.
  1301. * The Normalized RDN is returned as a const;
  1302. * you are not able to modify the Normalized RDN value.
  1303. * \warning Never free the returned value.
  1304. * \see slapi_entry_set_srdn()
  1305. */
  1306. const char *slapi_entry_get_nrdn_const( const Slapi_Entry *e );
  1307. /**
  1308. * Sets the distinguished name (DN) of an entry.
  1309. *
  1310. * This function sets the DN pointer in the specified entry to the DN that you supply.
  1311. *
  1312. * \param e Entry to which you want to assign the DN.
  1313. * \param dn Distinguished name you want assigned to the entry.
  1314. * \warning The dn will be freed eventually when slapi_entry_free() is called.
  1315. * \warning A copy of dn should be passed. For example:
  1316. * \code
  1317. * char *dn = slapi_ch_strdup(some_dn):
  1318. * slapi_entry_set_dn(e, dn);
  1319. * \endcode
  1320. *
  1321. * \warning The old dn will be freed as a result of this call. Do not pass in
  1322. * a \c NULL value.
  1323. * \see slapi_entry_free()
  1324. * \see slapi_entry_get_dn()
  1325. */
  1326. void slapi_entry_set_dn( Slapi_Entry *e, char *dn );
  1327. /**
  1328. * Sets the normalized distinguished name (DN) of an entry.
  1329. *
  1330. * This function sets the DN pointer in the specified entry to the DN that you supply. The DN should have been normalized.
  1331. *
  1332. * \param e Entry to which you want to assign the DN.
  1333. * \param dn Distinguished name you want assigned to the entry.
  1334. * \warning The dn will be freed eventually when slapi_entry_free() is called.
  1335. * \warning A copy of dn should be passed. For example:
  1336. *
  1337. * \warning The old dn will be freed as a result of this call. Do not pass in
  1338. * a \c NULL value.
  1339. * \see slapi_entry_free()
  1340. * \see slapi_entry_get_dn()
  1341. */
  1342. void slapi_entry_set_normdn( Slapi_Entry *e, char *normdn );
  1343. /**
  1344. * Sets the relative distinguished name (RDN) of an entry.
  1345. *
  1346. * This function sets the RDN pointer in the specified entry to the RDN that
  1347. * you supply.
  1348. *
  1349. * \param e Entry to which you want to assign the RDN.
  1350. * \param rdn Relatie distinguished name you want assigned to the entry.
  1351. * If dn is given here, the first rdn part is set to the RDN.
  1352. * \warning The rdn will be copied in slapi_entry_set_rdn.
  1353. */
  1354. void slapi_entry_set_rdn( Slapi_Entry *e, char *rdn );
  1355. /**
  1356. * Sets the Slapi_DN value in an entry.
  1357. *
  1358. * This function sets the value for the #Slapi_DN object in the entry you specify.
  1359. *
  1360. * \param e Entry to which you want to set the value of the #Slapi_DN.
  1361. * \param sdn The specified #Slapi_DN value that you want to set.
  1362. * \warning This function makes a copy of the \c sdn parameter.
  1363. * \see slapi_entry_get_sdn()
  1364. */
  1365. void slapi_entry_set_sdn( Slapi_Entry *e, const Slapi_DN *sdn );
  1366. /**
  1367. * Sets the Slapi_DN value containing RDN in an entry.
  1368. *
  1369. * This function sets the value for the #Slapi_DN object containing RDN in the entry you specify.
  1370. *
  1371. * \param e Entry to which you want to set the value of the #Slapi_DN.
  1372. * \param srdn The specified #Slapi_DN value that you want to set.
  1373. * \warning This function makes a copy of the \c srdn parameter.
  1374. * \see slapi_entry_get_srdn()
  1375. */
  1376. void slapi_entry_set_srdn( Slapi_Entry *e, const Slapi_RDN *srdn );
  1377. /**
  1378. * Determines if an entry contains the specified attribute.
  1379. *
  1380. * If the entry contains the attribute, the function returns a pointer to
  1381. * the attribute.
  1382. *
  1383. * \param e Entry that you want to check.
  1384. * \param type Name of the attribute that you want to check.
  1385. * \param attr Pointer to the attribute, if the attribute is found in the
  1386. * entry.
  1387. * \return \c 0 if the entry contains the specified attribute.
  1388. * \return \c -1 if the entry does not contain the specified attribute.
  1389. * \warning Do not free the returned \c attr. It is a pointer to the internal
  1390. * entry data structure. It is usually wise to make a copy of the
  1391. * returned attribute, using slapi_attr_dup(), to avoid dangling pointers
  1392. * if the entry is freed while the pointer to attr is still being used.
  1393. * \see slapi_attr_dup()
  1394. */
  1395. int slapi_entry_attr_find( const Slapi_Entry *e, const char *type, Slapi_Attr **attr );
  1396. /**
  1397. * Finds the first attribute in an entry.
  1398. *
  1399. * If you want to iterate through the attributes in an entry, use this function
  1400. * in conjunction with the slapi_entry_next_attr() function.
  1401. *
  1402. * \param e Entry from which you want to get the attribute.
  1403. * \param attr Pointer to the first attribute in the entry.
  1404. * \return Returns 0 when successful; any other value returned signals failure.
  1405. * \warning Do not free the returned \c attr. This is a pointer into the
  1406. * internal entry data structure. If you need a copy, use slapi_attr_dup().
  1407. * \see slapi_entry_next_attr()
  1408. * \see slapi_attr_dup()
  1409. */
  1410. int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr );
  1411. /**
  1412. * Finds the next attribute after \c prevattr in an entry.
  1413. *
  1414. * To iterate through the attributes in an entry, use this function in conjunction
  1415. * with the slapi_entry_first_attr() function.
  1416. *
  1417. * \param e Entry from which you want to get the attribute.
  1418. * \param prevattr Previous attribute in the entry.
  1419. * \param attr Pointer to the next attribute after \c prevattr in the entry.
  1420. * \return \c 0 if successful.
  1421. * \return \c -1 if \c prevattr was the last attribute in the entry.
  1422. * \warning Do not free the returned \c attr. This is a pointer into the
  1423. * internal entry data structure. If you need a copy, use slapi_attr_dup().
  1424. * \see slapi_entry_first_attr()
  1425. * \see slapi_entry_dup()
  1426. */
  1427. int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr );
  1428. /**
  1429. * Gets the unique ID value of the entry.
  1430. *
  1431. * \param e Entry from which you want to obtain the unique ID.
  1432. * \return This function returns the unique ID value of the entry specified.
  1433. * \warning Never free this value. If you need a copy, use slapi_ch_strdup().
  1434. * \see slapi_entry_set_uniqueid()
  1435. * \see slapi_ch_strdup()
  1436. */
  1437. const char *slapi_entry_get_uniqueid( const Slapi_Entry *e );
  1438. /**
  1439. * Replaces the unique ID value of an entry with the unique ID value that you
  1440. * supply.
  1441. *
  1442. * This function replaces the unique ID value of the entry with the \c uniqueid
  1443. * value that you specify. In addition, the function adds #SLAPI_ATTR_UNIQUEID to
  1444. * the attribute list and gives it the unique ID value supplied. If the entry
  1445. * already contains a #SLAPI_ATTR_UNIQUEID attribute, its value is updated with
  1446. * the new value supplied.
  1447. *
  1448. * \param e Entry for which you want to generate a unique ID.
  1449. * \param uniqueid The unique ID value that you want to assign to the entry.
  1450. * \warning Do not free the \c uniqueid after calling this function. The value
  1451. * will eventually be freed when slapi_entry_free() is called.
  1452. *
  1453. * \warning You should pass in a copy of the value because this function will
  1454. * consume the value passed in. For example:
  1455. * \code
  1456. * char *uniqueid = slapi_ch_strdup(some_uniqueid);
  1457. * slapi_entry_set_uniqueid(e, uniqueid);
  1458. * \endcode
  1459. *
  1460. * \warning Do not pass in a \c NULL for \c uniqueid.
  1461. * \see slapi_entry_get_uniqueid()
  1462. * \see slapi_entry_free()
  1463. */
  1464. void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid );
  1465. /**
  1466. * Determines whether the specified entry complies with the schema for its object
  1467. * class.
  1468. *
  1469. * \param pb Parmeter block.
  1470. * \param e Entry that you want to check.
  1471. * \return \c 0 if the entry complies with the schema or if schema checking is
  1472. * turned off. The function also returns \c 0 if the entry has additional
  1473. * attributes not allowed by the schema and has the object class
  1474. * \c extensibleObject.
  1475. * \return \c 1 if the entry is missing the \c objectclass attribute, if it is missing
  1476. * any required attributes, if it has any attributes not allowed by the schema
  1477. * but does not have the object class \c extensibleObject, or if the entry has
  1478. * multiple values for a single-valued attribute.
  1479. * \warning The \c pb argument can be \c NULL. It is only used to get the
  1480. * #SLAPI_IS_REPLICATED_OPERATION flag. If that flag is present, no schema
  1481. * checking is done.
  1482. */
  1483. int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e );
  1484. /**
  1485. * Determines whether the specified entry complies with the schema for its object
  1486. * class.
  1487. *
  1488. * Like slapi_entry_schema_check() with one additional parameter to enforce schema
  1489. * checking for replicated operations.
  1490. * \param check_repl Set to 1 if replicted operations should be checked
  1491. */
  1492. int slapi_entry_schema_check_ext( Slapi_PBlock *pb, Slapi_Entry *e, int check_repl );
  1493. /**
  1494. * Determines whether the specified entry complies with the syntax rules imposed
  1495. * by it's attribute types.
  1496. *
  1497. * \param pb Parameter block.
  1498. * \param e Entry that you want to check.
  1499. * \param override Flag to override the server configuration and force syntax checking
  1500. * to be performed.
  1501. * \return \c 0 if the entry complies with the syntax rules or if syntax checking
  1502. * is disabled.
  1503. * \return \c 1 if the entry has any attribute values that violate the syntax rules
  1504. * imposed by the associated attribute type. If the \c pb parameter was
  1505. * passed in, an error message describing the syntax violations will be
  1506. * set in the #SLAPI_PB_RESULT_TEXT paramter.
  1507. * \warning The \c pb parameter can be \c NULL. It is used to store an error
  1508. * message with details of any syntax violations. The \c pb paramter
  1509. * is also used to check if the #SLAPI_IS_REPLICATED_OPERATION flag is
  1510. * set. If that flag is present, no syntax checking is performed.
  1511. */
  1512. int slapi_entry_syntax_check( Slapi_PBlock *pb, Slapi_Entry *e, int override );
  1513. /**
  1514. * Determines if the DN violates the Distinguished Name syntax rules.
  1515. *
  1516. * \param pb Parameter block.
  1517. * \param dn The dn string you want to check.
  1518. * \param override Flag to override the server configuration and force syntax checking
  1519. * to be performed.
  1520. * \return \c 0 if the DN complies with the Distinguished Name syntax rules or if
  1521. * syntax checking is disabled.
  1522. * \return \c 1 if the DN violates the Distinguished Name syntax rules. If the \c pb
  1523. * parameter was passed in, an error message will be set in the
  1524. * #SLAPI_PB_RESULT_TEXT parameter.
  1525. * \warning The \c pb parameter can be \c NULL. It is used to store an error
  1526. * message with details of any syntax violations. The \c pb paramter
  1527. * is also used to check if the #SLAPI_IS_REPLICATED_OPERATION flag is
  1528. * set. If that flag is present, no syntax checking is performed.
  1529. */
  1530. int slapi_dn_syntax_check( Slapi_PBlock *pb, const char *dn, int override );
  1531. /**
  1532. * Determines if any values being added to an entry violate the syntax rules
  1533. * imposed by the associated attribute type.
  1534. *
  1535. * \param pb Parameter block.
  1536. * \param mods Array of mods that you want to check.
  1537. * \param override Flag to override the server configuration and force syntax checking
  1538. * to be performed.
  1539. * \return \c 0 if the mods comply with the syntax rules or if syntax checking
  1540. * is disabled.
  1541. * \return \c 1 if the mods are adding any new attribute values that violate the
  1542. * syntax rules imposed by the associated attribute type. If the \c pb
  1543. * parameter was passed in, an error message describing the syntax violations
  1544. * will be set in the #SLAPI_PB_RESULT_TEXT paramter.
  1545. * \warning The \c pb parameter can be \c NULL. It is used to store an error
  1546. * message with details of any syntax violations. The \c pb paramter
  1547. * is also used to check if the #SLAPI_IS_REPLICATED_OPERATION flag is
  1548. * set. If that flag is present, no syntax checking is performed.
  1549. */
  1550. int slapi_mods_syntax_check( Slapi_PBlock *pb, LDAPMod **mods, int override );
  1551. /**
  1552. * Determines whether the values in an entry’s relative distinguished name (RDN)
  1553. * are also present as attribute values.
  1554. *
  1555. * For example, if the entry’s RDN is <tt>cn=Barbara Jensen</tt>, the function determines
  1556. * if the entry has the \c cn attribute with the value <tt>Barbara Jensen</tt>.
  1557. *
  1558. * \param e Entry that you want to check for RDN values.
  1559. * \return \c 1 if the values in the RDN are present in the attributes of the entry.
  1560. * \return \c 0 if the values are not present.
  1561. */
  1562. int slapi_entry_rdn_values_present( const Slapi_Entry *e );
  1563. /**
  1564. * Adds the components in an entry’s relative distinguished name (RDN) to the entry
  1565. * as attribute values.
  1566. *
  1567. * For example, if the entry’s RDN is <tt>uid=bjensen</tt>, the function adds
  1568. * <tt>uid=bjensen</tt> to the entry as an attribute value.
  1569. *
  1570. * \param e Entry to which you want to add the RDN attributes.
  1571. * \return \c LDAP_SUCCESS if the values were successfully added to the entry. The
  1572. * function also returns \c LDAP_SUCCESS if the entry is \c NULL, if the
  1573. * entry’s DN is \c NULL, or if the entry’s RDN is \c NULL.
  1574. * \return \c LDAP_INVALID_DN_SYNTAX if the DN of the entry cannot be parsed.
  1575. * \warning Free the entry from memory by using the slapi_entry_free() function, if the
  1576. * entry was allocated by the user.
  1577. * \see slapi_entry_free()
  1578. */
  1579. int slapi_entry_add_rdn_values( Slapi_Entry *e );
  1580. /**
  1581. * Deletes an attribute (and all its associated values) from an entry.
  1582. *
  1583. * \param e Entry from which you want to delete the attribute.
  1584. * \param type Attribute type that you want to delete.
  1585. * \return \c 0 if successful.
  1586. * \return \c 1 if the specified attribute is not part of the entry.
  1587. * \return \c -1 if an error occurred.
  1588. */
  1589. int slapi_entry_attr_delete( Slapi_Entry *e, const char *type );
  1590. /**
  1591. * Gets the values of a multi-valued attribute of an entry.
  1592. *
  1593. * This function is very similar to slapi_entry_attr_get_charptr(), except that it
  1594. * returns a <tt>char **</tt> array for multi-valued attributes. The array and all
  1595. * values are copies. Even if the attribute values are not strings, they will still
  1596. * be \c NULL terminated so that they can be used safely in a string context. If there
  1597. * are no values, \c NULL will be returned. Because the array is \c NULL terminated,
  1598. * the usage should be similar to the sample shown below:
  1599. *
  1600. * \code
  1601. * char **ary = slapi_entry_attr_get_charray(e, someattr);
  1602. * int ii;
  1603. * for (ii = 0; ary && ary[ii]; ++ii) {
  1604. * char *strval = ary[ii];
  1605. * ...
  1606. * }
  1607. * slapi_ch_array_free(ary);
  1608. * \endcode
  1609. *
  1610. * \param e Entry from which you want to get the values.
  1611. * \param type Attribute type from which you want to get the values.
  1612. * \return A copy of all the values of the attribute.
  1613. * \return \c NULL if the entry does not contain the attribute or if the attribute
  1614. * has no values.
  1615. * \warning When you are done working with the values, free them from memory by calling
  1616. * the slapi_ch_array_free() function.
  1617. * \see slapi_entry_attr_get_charptr()
  1618. */
  1619. char **slapi_entry_attr_get_charray(const Slapi_Entry* e, const char *type);
  1620. /**
  1621. * Gets the values of a multi-valued attribute of an entry.
  1622. *
  1623. * This function is very similar to slapi_entry_attr_get_charptr(), except that it
  1624. * returns a <tt>char **</tt> array for multi-valued attributes. The array and all
  1625. * values are copies. Even if the attribute values are not strings, they will still
  1626. * be \c NULL terminated so that they can be used safely in a string context. If there
  1627. * are no values, \c NULL will be returned. Because the array is \c NULL terminated,
  1628. * the usage should be similar to the sample shown below:
  1629. *
  1630. * \code
  1631. * char **ary = slapi_entry_attr_get_charray(e, someattr);
  1632. * int ii;
  1633. * for (ii = 0; ary && ary[ii]; ++ii) {
  1634. * char *strval = ary[ii];
  1635. * ...
  1636. * }
  1637. * slapi_ch_array_free(ary);
  1638. * \endcode
  1639. *
  1640. * \param e Entry from which you want to get the values.
  1641. * \param type Attribute type from which you want to get the values.
  1642. * \param numVals The number of attribute values will be stored in this variable.
  1643. * \return A copy of all the values of the attribute.
  1644. * \return \c NULL if the entry does not contain the attribute or if the attribute
  1645. * has no values.
  1646. * \warning When you are done working with the values, free them from memory by calling
  1647. * the slapi_ch_array_free() function.
  1648. * \see slapi_entry_attr_get_charptr()
  1649. */
  1650. char **slapi_entry_attr_get_charray_ext( const Slapi_Entry* e, const char *type, int *numVals);
  1651. /**
  1652. * Gets the first value of an attribute of an entry as a string.
  1653. *
  1654. * \param e Entry from which you want to get the string value.
  1655. * \param type Attribute type from which you want to get the value.
  1656. * \return A copy of the first value in the attribute.
  1657. * \return \c NULL if the entry does not contain the attribute.
  1658. * \warning When you are done working with this value, free it from memory by calling the
  1659. * slapi_ch_free_string() function.
  1660. * \see slapi_entry_attr_get_charray()
  1661. */
  1662. char *slapi_entry_attr_get_charptr(const Slapi_Entry* e, const char *type);
  1663. /**
  1664. * Gets the first value of an attribute in an entry as an integer.
  1665. *
  1666. * \param e Entry from which you want to get the integer value.
  1667. * \param type Attribute type from which you want to get the value.
  1668. * \return The first value of the attribute converted to an integer.
  1669. * \return \c 0 if the entry does not contain the attribute.
  1670. */
  1671. int slapi_entry_attr_get_int(const Slapi_Entry* e, const char *type);
  1672. /**
  1673. * Gets the first value of an attribute in an entry as an unsigned integer data type.
  1674. *
  1675. * \param e Entry from which you want to get the integer value.
  1676. * \param type Attribute type from which you want to get the value.
  1677. * \return The first value of the attribute converted to an unsigned integer.
  1678. * \return \c 0 if the entry does not contain the attribute.
  1679. */
  1680. unsigned int slapi_entry_attr_get_uint(const Slapi_Entry* e, const char *type);
  1681. /**
  1682. * Gets the first value of an attribute in an entry as a long data type.
  1683. *
  1684. * \param e Entry from which you want to get the long value.
  1685. * \param type Attribute type from which you want to get the value.
  1686. * \return The first value of the attribute converted to a \c long type.
  1687. * \return \c 0 if the entry does not contain the attribute.
  1688. */
  1689. long slapi_entry_attr_get_long( const Slapi_Entry* e, const char *type);
  1690. /**
  1691. * Gets the first value of an attribute in an entry as an unsigned long
  1692. * data type.
  1693. *
  1694. * \param e Entry from which you want to get the unsigned long value.
  1695. * \param type Attribute type from which you want to get the value.
  1696. * \return The first value of the attribute converted to an <tt>
  1697. * unsigned long</tt>.
  1698. * \return \c 0 if the entry does not contain the attribute.
  1699. */
  1700. unsigned long slapi_entry_attr_get_ulong( const Slapi_Entry* e, const char *type);
  1701. /**
  1702. * Gets the first value of an attribute in an entry as a long long data type.
  1703. *
  1704. * \param e Entry from which you want to get the long long value.
  1705. * \param type Attribute type from which you want to get the value.
  1706. * \return The first value of the attribute converted to a <tt>long long</tt>.
  1707. * \return \c 0 if the entry does not contain the attribute.
  1708. */
  1709. long long slapi_entry_attr_get_longlong( const Slapi_Entry* e, const char *type);
  1710. /**
  1711. * Gets the first value of an attribute in an entry as an unsigned
  1712. * long long data type.
  1713. *
  1714. * \param e Entry from which you want to get the unsigned long long value.
  1715. * \param type Attribute type from which you want to get the value.
  1716. * \return The first value of the attribute converted to an <tt>unsigned
  1717. * long long</tt>.
  1718. * \return \c 0 if the entry does not contain the attribute.
  1719. */
  1720. unsigned long long slapi_entry_attr_get_ulonglong( const Slapi_Entry* e, const char *type);
  1721. /**
  1722. * Gets the value of a given attribute of a given entry as a boolean value.
  1723. *
  1724. * Comparisons are case-insensitive (\c TRUE, \c trUe, and \c true are all the
  1725. * same), and unique substrings can be matched (\c t and \c tr will be interpreted
  1726. * as \c true). If the attribute value is a number, then non-zero numbers are
  1727. * interpreted as \c true, and \c 0 is interpreted as \c false.
  1728. *
  1729. * \param e Entry from which you want to get the boolean value.
  1730. * \param type Attribute type from which you want to get the value.
  1731. * \return \c PR_TRUE | \c PR_FALSE
  1732. */
  1733. PRBool slapi_entry_attr_get_bool( const Slapi_Entry* e, const char *type);
  1734. /**
  1735. * Replaces the value or values of an attribute in an entry with a specified string
  1736. * value.
  1737. *
  1738. * \param e Entry in which you want to set the value.
  1739. * \param type Attribute type in which you want to set the value.
  1740. * \param value String value that you want to assign to the attribute.
  1741. * \warning This function makes a copy of the parameter \c value. The \c value
  1742. * parameter can be \c NULL; if so, this function is roughly equivalent
  1743. * to slapi_entry_attr_delete().
  1744. * \see slapi_entry_attr_delete()
  1745. */
  1746. void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value);
  1747. /**
  1748. * Replaces the value or values of an attribute in an entry with a specified integer
  1749. * data value.
  1750. *
  1751. * This function will replace the value or values of an attribute with the
  1752. * integer value that you specify. If the attribute does not exist, it is created
  1753. * with the integer value that you specify.
  1754. *
  1755. * \param e Entry in which you want to set the value.
  1756. * \param type Attribute type in which you want to set the value.
  1757. * \param l Integer value that you want to assign to the attribute.
  1758. */
  1759. void slapi_entry_attr_set_int( Slapi_Entry* e, const char *type, int l);
  1760. /**
  1761. * Replaces the value or values of an attribute in an entry with a specified
  1762. * unsigned integer data type value.
  1763. *
  1764. * This function will replace the value or values of an attribute with the
  1765. * unsigned integer value that you specify. If the attribute does not exist,
  1766. * it is created with the unsigned integer value you specify.
  1767. *
  1768. * \param e Entry in which you want to set the value.
  1769. * \param type Attribute type in which you want to set the value.
  1770. * \param l Unsigned integer value that you want to assign to the attribute.
  1771. */
  1772. void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l);
  1773. /**
  1774. * Replaces the value or values of an attribute in an entry with a specified long data
  1775. * type value.
  1776. *
  1777. * \param e Entry in which you want to set the value.
  1778. * \param type Attribute type in which you want to set the value.
  1779. * \param l Long integer value that you want to assign to the attribute.
  1780. */
  1781. void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
  1782. /**
  1783. * Replaces the value or values of an attribute in an entry with a specified unsigned
  1784. * long data type value.
  1785. *
  1786. * This function will replace the value or values of an attribute with the unsigned
  1787. * long value that you specify. If the attribute does not exist, it is created with the
  1788. * unsigned long value that you specify.
  1789. *
  1790. * \param e Entry in which you want to set the value.
  1791. * \param type Attribute type in which you want to set the value.
  1792. * \param l Unsigned long value that you want to assign to the attribute.
  1793. */
  1794. void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l);
  1795. /**
  1796. * Determines if an attribute in an entry contains a specified value.
  1797. *
  1798. * The syntax of the attribute type is taken into account when checking
  1799. * for the specified value.
  1800. *
  1801. * \param e Entry that you want to check.
  1802. * \param type Attribute type that you want to test for the value specified.
  1803. * \param value Value that you want to find in the attribute.
  1804. * \return \c 1 if the attribute contains the specified value.
  1805. * \return \c 0 if the attribute does not contain the specified value.
  1806. * \warning \c value must not be \c NULL.
  1807. */
  1808. int slapi_entry_attr_has_syntax_value(const Slapi_Entry *e, const char *type, const Slapi_Value *value);
  1809. /**
  1810. * This function determines if the specified entry has child entries.
  1811. *
  1812. * \param e Entry that you want to test for child entries.
  1813. * \return \c 1 if the entry you supply has child entries.
  1814. * \return \c 0 if the entry you supply has child entries.
  1815. */
  1816. int slapi_entry_has_children(const Slapi_Entry *e);
  1817. /**
  1818. * This function determines if an entry is the root DSE.
  1819. *
  1820. * The root DSE is a special entry that contains information about the Directory
  1821. * Server, including its capabilities and configuration.
  1822. *
  1823. * \param dn The DN that you want to test to see if it is the root DSE entry.
  1824. * \return \c 1 if \c dn is the root DSE.
  1825. * \return \c 0 if \c dn is not the root DSE.
  1826. */
  1827. int slapi_is_rootdse( const char *dn );
  1828. /**
  1829. * This function returns the approximate size of an entry, rounded to the nearest 1k.
  1830. *
  1831. * This can be useful for checking cache sizes, estimating storage needs, and so on.
  1832. *
  1833. * When determining the size of an entry, only the sizes of the attribute values are
  1834. * counted; the size of other entry values (such as the size of attribute names,
  1835. * variously-normalized DNs, or any metadata) are not included in the size
  1836. * returned. It is assumed that the size of the metadata, et al., is well enough
  1837. * accounted for by the rounding of the size to the next largest 1k . This holds true
  1838. * especially in larger entries, where the actual size of the attribute values far
  1839. * outweighs the size of the metadata.
  1840. *
  1841. * When determining the size of the entry, both deleted values and deleted
  1842. * attributes are included in the count.
  1843. *
  1844. * \param e Entry from which you want the size returned.
  1845. * \return The size of the entry, rounded to the nearest 1k. The value returned is a
  1846. * size_t data type with a u_long value.
  1847. * \return A size of 1k if the entry is empty.
  1848. * \warning The \c e parameter must not be \c NULL.
  1849. */
  1850. size_t slapi_entry_size(Slapi_Entry *e);
  1851. /**
  1852. * Adds an array of #Slapi_Value data values to the existing attribute values in
  1853. * an entry.
  1854. *
  1855. * If the attribute does not exist, it is created with the #Slapi_Value specified.
  1856. *
  1857. * \param e Entry to which you want to add values.
  1858. * \param type Attribute type to which you want to add values.
  1859. * \param vals \c NULL terminated array of #Slapi_Value data values you want to add.
  1860. * \return This function returns \c 0 if successful; any other value returned
  1861. * signals failure.
  1862. * \warning This function makes a copy of the parameter \c vals. The \c vals
  1863. * parameter can be \c NULL.
  1864. */
  1865. int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1866. /**
  1867. * Adds and array of #Slapi_Value data values to the specified attribute in an entry.
  1868. *
  1869. * This function adds an array of #Slapi_Value data values to an attribute. If the
  1870. * attribute does not exist, it is created and given the value contained in the
  1871. * #Slapi_Value array.
  1872. *
  1873. * \param e Entry to which you want to add values.
  1874. * \param type Attribute type to which you want to add values.
  1875. * \param vals \c NULL terminated array of #Slapi_Value data values you want to add.
  1876. * \return \c LDAP_SUCCESS if the #Slapi_Value array if successfully added to the
  1877. * attribute.
  1878. * \return \c LDAP_TYPE_OR_VALUE_EXISTS if any values you are trying to add duplicate
  1879. * an existing value in the attribute.
  1880. * \return \c LDAP_OPERATIONS_ERROR if there are pre-existing duplicate values in the
  1881. * attribute.
  1882. * \warning This function makes a copy of the parameter \c vals. The \c vals
  1883. * parameter can be \c NULL.
  1884. */
  1885. int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1886. /**
  1887. * Add a Slapi_ValueSet data value to the specified attribute in an entry.
  1888. *
  1889. * This function adds a set of values to an attribute in an entry. The values added
  1890. * are in the form of a #Slapi_ValueSet data type. If the entry does not contain the
  1891. * attribute specified, it is created with the specified #Slapi_ValueSet values.
  1892. *
  1893. * \param e Entry to which you want to add values.
  1894. * \param type Attribute type to which you want to add values.
  1895. * \param vs #Slapi_ValueSet data value that you want to add to the entry.
  1896. * \return \c 0 when successful; any other value returned signals failure.
  1897. * \warning This function makes a copy of the parameter \c vs. The \c vs
  1898. * parameter can be \c NULL.
  1899. */
  1900. int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs);
  1901. /**
  1902. * Removes an array of Slapi_Value data values from an attribute in an entry.
  1903. *
  1904. * This function removes an attribute/valueset from an entry. Both the attribute
  1905. * and its #Slapi_Value data values are removed from the entry. If you supply a
  1906. * #Slapi_Value whose value is \c NULL, the function will delete the specified
  1907. * attribute from the entry. In either case, the function returns \c LDAP_SUCCESS.
  1908. *
  1909. * \param e Entry from which you want to delete values.
  1910. * \param type Attribute type from which you want to delete values.
  1911. * \param vals \c NULL terminated array of #Slapi_Value data values that you
  1912. * want to delete.
  1913. * \return \c LDAP_SUCCESS if the specified attribute and the array of #Slapi_Value
  1914. * data values are deleted from the entry.
  1915. * \return If the specified attribute contains a \c NULL value, the attribute is
  1916. * deleted from the attribute list, and the function returns
  1917. * \c LDAP_NO_SUCH_ATTRIBUTE. As well, if the attribute is not found in the
  1918. * list of attributes for the specified entry, the function returns
  1919. * \c LDAP_NO_SUCH_ATTRIBUTE.
  1920. * \return If there is an operational error during the processing of this call such
  1921. * as a duplicate value found, the function will return
  1922. * \c LDAP_OPERATIONS_ERROR.
  1923. * \warning The \c vals parameter can be \c NULL, in which case this function does
  1924. * nothing.
  1925. */
  1926. int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1927. /**
  1928. * Merges (adds) and array of #Slapi_Value data values to a specified attribute in
  1929. * an entry.
  1930. *
  1931. * This function adds additional #Slapi_Value data values to the existing values
  1932. * contained in an attribute. If the attribute type does not exist, it is created.
  1933. *
  1934. * If the specified attribute exists in the entry, the function merges the value
  1935. * specified and returns \c LDAP_SUCCESS. If the attribute is not found in the entry,
  1936. * the function creates it with the #Slapi_Value specified and returns \c
  1937. * LDAP_NO_SUCH_ATTRIBUTE.
  1938. *
  1939. * If this function fails, it leaves the values for \c type within a pointer to
  1940. * \c e in an indeterminate state. The present valueset may be truncated.
  1941. *
  1942. * \param e Entry into which you want to merge values.
  1943. * \param type Attribute type that you want to merge the values into.
  1944. * \param vals \c NULL terminated array of #Slapi_Value values that you want to merge
  1945. * into the entry.
  1946. * \return \c LDAP_SUCCESS
  1947. * \return \c LDAP_NO_SUCH_ATTRIBUTE
  1948. * \warning This function makes a copy of \c vals. The \c vals parameter
  1949. * can be \c NULL.
  1950. */
  1951. int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1952. /**
  1953. * Replaces the values of an attribute with the #Slapi_Value data value you specify.
  1954. *
  1955. * This function replaces existing attribute values in a specified entry with a single
  1956. * #Slapi_Value data value. The function first deletes the existing attribute from the
  1957. * entry, then replaces it with the new value specified.
  1958. *
  1959. * \param e Entry in which you want to replace values.
  1960. * \param type Attribute type which will receive the replaced values
  1961. * \param vals \c NULL terminated array of #Slapi_Value valyes that should replace
  1962. * the existing values of the attribute.
  1963. * \return \c 0 when successful; any other value returned signals failure.
  1964. * \warning This function makes a copy of \c vals. The \c vals parameter
  1965. * can be \c NULL.
  1966. */
  1967. int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1968. /**
  1969. * Adds a specified #Slapi_Value data value to an attribute in an entry.
  1970. *
  1971. * This function adds a #Slapi_Value data value to the existing attribute values in an
  1972. * entry. If the specified attribute does not exist in the entry, the attribute is
  1973. * created with the #Slapi_Value specified. The function doesn’t check for duplicate
  1974. * values, meaning it does not check if the value being added is already there.
  1975. *
  1976. * \param e Entry to which you want to add a value.
  1977. * \param type Attribute to which you want to add a value.
  1978. * \param value The #Slapi_Value data value you want to add to the entry.
  1979. * \return \c 0 when successful; any other value returned signals failure.
  1980. * \warning This function makes a copy of \c value. The \c value parameter
  1981. * can be \c NULL.
  1982. */
  1983. int slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value);
  1984. /**
  1985. * Adds a string value to an attribute in an entry.
  1986. *
  1987. * This function adds a string value to the existing attribute values in an entry. If
  1988. * the specified attribute does not exist in the entry, the attribute is created with
  1989. * the string value specified. The function doesn’t check for duplicate values; it
  1990. * does not check if the string value being added is already there.
  1991. *
  1992. * \param e Entry to which you want to add a string value.
  1993. * \param type Attribute to which you want to add a string value.
  1994. * \param value String value you want to add.
  1995. * \return \c 0 when successful; any other value returned signals failure.
  1996. * \warning This function makes a copy of \c value. The \c value parameter
  1997. * can be \c NULL.
  1998. */
  1999. int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value);
  2000. /**
  2001. * Deletes a string value from an attribute in an entry.
  2002. *
  2003. * \param e Entry from which you want the string deleted.
  2004. * \param type Attribute type from which you want the string deleted.
  2005. * \param value Value of string to delete.
  2006. * \return \c 0 when successful; any other value returned signals failure.
  2007. */
  2008. int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value);
  2009. /**
  2010. * Find differences between two entries.
  2011. *
  2012. * Compares two #Slapi_Entry entries and determines the difference between them. The
  2013. * differences are returned as the modifications needed to the first entry to make it
  2014. * match the second entry.
  2015. *
  2016. * \param smods An empty #Slapi_Mods that will be filled in with the modifications
  2017. * needed to make \c e1 the same as \c e2.
  2018. * \param e1 The first entry you want to compare.
  2019. * \param e2 The second entry you want to compare.
  2020. * \param diff_ctrl Allows you to skip comparing operational attributes by passing
  2021. * #SLAPI_DUMP_NOOPATTRS. Pass \c 0 if you want to compare the
  2022. * operational attributes.
  2023. * \warning The caller must allocate the #Slapi_Mods that is passed in as \c smods.
  2024. * This must be an empty #Slapi_Mods, otherwise the contents will be leaked.
  2025. * \warning It is up to the caller to free \c smods when they are finished using them
  2026. * by calling slapi_mods_free() or slapi_mods_done() if \c smods was allocated
  2027. * on the stack.
  2028. */
  2029. void slapi_entry_diff(Slapi_Mods *smods, Slapi_Entry *e1, Slapi_Entry *e2, int diff_ctrl);
  2030. /**
  2031. * Applies an array of \c LDAPMod modifications to a Slapi_Entry.
  2032. *
  2033. * \param e Entry to which you want to apply the modifications.
  2034. * \param mods \c NULL terminated array of \c LDAPMod modifications that you
  2035. * want to apply to the specified entry.
  2036. * \return \c LDAP_SUCCESS if the mods applied to the entry cleanly, otherwise an
  2037. * LDAP error is returned.
  2038. * \warning It is up to the caller to free the \c LDAPMod array after the mods have
  2039. * been applied.
  2040. */
  2041. int slapi_entry_apply_mods(Slapi_Entry *e, LDAPMod **mods);
  2042. /**
  2043. * Applies a single \c LDAPMod modification to a Slapi_Entry.
  2044. *
  2045. * \param e Entry to which you want to apply the modification.
  2046. * \param mod A pointer to the \c LDAPMod modification that you
  2047. * want to apply to the specified entry.
  2048. * \return \c LDAP_SUCCESS if the mod applied to the entry cleanly, otherwise
  2049. * an LDAP error is returned.
  2050. * \warning It is up to the caller to free the \c LDAPMod after the mod has
  2051. * been applied.
  2052. */
  2053. int slapi_entry_apply_mod(Slapi_Entry *e, LDAPMod *mod);
  2054. /**
  2055. * Renames a Slapi_Entry.
  2056. *
  2057. * This function will rename an existing \c Slapi_Entry, similar to what
  2058. * would happen with a \c MODRDN operation. New RDN values will be added
  2059. * as attributes to the entry and old RDN values will be deleted if requested.
  2060. *
  2061. * \param e Entry that you want to rename.
  2062. * \param newrdn The new RDN value to be used for renaming the entry. This must
  2063. * not be \c NULL.
  2064. * \param deleteoldrdn Will delete the old RDN values from the entry if set to \c 1.
  2065. * \param newsuperior The new superior DN to use when renaming the entry. Set this
  2066. * to \c NULL if you do not want to move the entry.
  2067. * \return \c LDAP_SUCCESS if the rename was successful, otherwise an LDAP error
  2068. * is returned.
  2069. */
  2070. int slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, Slapi_DN *newsuperior);
  2071. /*------------------------
  2072. * Entry flags.
  2073. *-----------------------*/
  2074. /**
  2075. * Flag that signifies that an entry is a tombstone entry
  2076. *
  2077. * \see slapi_entry_flag_is_set()
  2078. * \see slapi_entry_set_flag()
  2079. * \see slapi_entry_clear_flag()
  2080. */
  2081. #define SLAPI_ENTRY_FLAG_TOMBSTONE 1
  2082. /**
  2083. * Determines if certain flags are set for a specified entry.
  2084. *
  2085. * \param e Entry for which you want to check for the specified flag.
  2086. * \param flag The flag whose presense you want to check for. Valid flags are:
  2087. * \arg #SLAPI_ENTRY_FLAG_TOMBSTONE
  2088. * \return \c 0 if the flag is not set.
  2089. * \return The value of the flag if it is set.
  2090. * \see slapi_entry_clear_flag()
  2091. * \see slapi_entry_set_flag()
  2092. */
  2093. int slapi_entry_flag_is_set( const Slapi_Entry *e, unsigned char flag );
  2094. /**
  2095. * Sets a flag for a specified entry.
  2096. *
  2097. * \param e Entry for which you want to set the flag.
  2098. * \param flag Flag that you want to set. Valid flags are:
  2099. * \arg #SLAPI_ENTRY_FLAG_TOMBSTONE
  2100. * \see slapi_entry_clear_flag()
  2101. * \see slapi_entry_flag_is_set()
  2102. */
  2103. void slapi_entry_set_flag( Slapi_Entry *e, unsigned char flag);
  2104. /**
  2105. * Clears a flag for a specified entry.
  2106. *
  2107. * \param e Entry for which you want to clear the flag.
  2108. * \param flag Flag that you want to clear. Valid flags are:
  2109. * \arg #SLAPI_ENTRY_FLAG_TOMBSTONE
  2110. * \see slapi_entry_flag_is_set()
  2111. * \see slapi_entry_set_flag()
  2112. */
  2113. void slapi_entry_clear_flag( Slapi_Entry *e, unsigned char flag);
  2114. /*------------------------------
  2115. * exported vattrcache routines
  2116. *------------------------------*/
  2117. /**
  2118. * Check if an entry is current in the virtual attribute cache.
  2119. *
  2120. * \param e The entry for which you want to check the virtual attribute cache
  2121. * validity.
  2122. * \return \c 1 if the entry is valid in the cache.
  2123. * \return \c 0 if the entry is invalid in the cache.
  2124. */
  2125. int slapi_entry_vattrcache_watermark_isvalid(const Slapi_Entry *e);
  2126. /**
  2127. * Mark an entry as valid in the virtual attribute cache.
  2128. *
  2129. * \param e The entry that you want to mark as valid.
  2130. */
  2131. void slapi_entry_vattrcache_watermark_set(Slapi_Entry *e);
  2132. /**
  2133. * Mark an entry as invalid in the virtual attribute cache.
  2134. *
  2135. * \param e The entry that you want to mark as invalid.
  2136. */
  2137. void slapi_entry_vattrcache_watermark_invalidate(Slapi_Entry *e);
  2138. /**
  2139. * Apply mod and store the result in the entry extension
  2140. *
  2141. * \param e The entry to apply mod.
  2142. * \param mod The mod to apply on entry.
  2143. * \param modcnt The count of values in mod.
  2144. *
  2145. * \return \c 1 if mod is applied and stored in extension.
  2146. * \return \c -1 if mod is applied and failed
  2147. * \return \c 0 if mod is nothing to do with extension
  2148. */
  2149. int slapi_entry_apply_mod_extension(Slapi_Entry *e, const LDAPMod *mod, int modcnt);
  2150. /**
  2151. * Invalidate all entries in the virtual attribute cache.
  2152. */
  2153. void slapi_entrycache_vattrcache_watermark_invalidate(void);
  2154. /*
  2155. * Slapi_DN routines
  2156. */
  2157. /**
  2158. * Creates a new \c Slapi_DN structure.
  2159. *
  2160. * This function will allocate the necessary memory for a \c Slapi_DN
  2161. * and initialize both the DN and normalized DN values to \c NULL.
  2162. *
  2163. * \return A pointer to the newly allocated, and still empty,
  2164. * \c Slapi_DN structure.
  2165. * \see slapi_sdn_free()
  2166. * \see slapi_sdn_copy()
  2167. * \see slapi_sdn_done()
  2168. */
  2169. Slapi_DN *slapi_sdn_new( void );
  2170. /**
  2171. * Creates a new \c Slapi_DN structure and intializes it's DN to a requested value.
  2172. *
  2173. * The DN of the new structure will point to a copy of the string pointed to by \c dn.
  2174. * The DN value is passed in to the parameter by value.
  2175. *
  2176. * \param dn The DN value to be set in the new \c Slapi_DN structure.
  2177. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2178. * a DN value set to the content of \c dn.
  2179. * \warning The \c dn value is copied by the function itself. The caller
  2180. * is still responsible for the memory used by \c dn.
  2181. * \see slapi_sdn_new_dn_byref()
  2182. * \see slapi_sdn_new_dn_passin()
  2183. * \see slapi_sdn_free()
  2184. * \see slapi_sdn_copy()
  2185. * \see slapi_sdn_done()
  2186. */
  2187. Slapi_DN *slapi_sdn_new_dn_byval(const char *dn);
  2188. /**
  2189. * Creates a new \c Slapi_DN structure and intializes it's normalized DN to a requested value.
  2190. *
  2191. * The normalized DN of the new structure will point to a copy of the string pointed to by
  2192. * \c ndn. The normalized DN value is passed in to the parameter by value.
  2193. *
  2194. * \param ndn The normalized DN value to be set in the new \c Slapi_DN structure.
  2195. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2196. * the normalized DN value set to the content of \c ndn.
  2197. * \warning The \c ndn value is copied by the function itself. The caller
  2198. * is still responsible for the memory used by \c ndn.
  2199. * \see slapi_sdn_new_ndn_byref()
  2200. * \see slapi_sdn_new_ndn_passin()
  2201. * \see slapi_sdn_free()
  2202. * \see slapi_sdn_copy()
  2203. * \see slapi_sdn_done()
  2204. */
  2205. Slapi_DN *slapi_sdn_new_ndn_byval(const char *ndn);
  2206. /**
  2207. * Creates a new \c Slapi_DN structure and intializes it's DN to a requested value.
  2208. *
  2209. * The DN of the new structure will point to the same string pointed to by \c dn.
  2210. * The DN value is passed in to the parameter by reference.
  2211. *
  2212. * \param dn The DN value to be set in the new \c Slapi_DN structure.
  2213. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2214. * a DN value set to the content of \c dn.
  2215. * \warning The caller is still responsible for the memory used by \c dn. This
  2216. * memory should not be freed until the returned \c Slapi_DN has been
  2217. * disposed of or reinitialized.
  2218. * \see slapi_sdn_new_dn_byval()
  2219. * \see slapi_sdn_new_dn_passin()
  2220. * \see slapi_sdn_free()
  2221. * \see slapi_sdn_copy()
  2222. * \see slapi_sdn_done()
  2223. */
  2224. Slapi_DN *slapi_sdn_new_dn_byref(const char *dn);
  2225. /**
  2226. * Creates a new \c Slapi_DN structure and intializes it's normalized and case ignored DN to a requested value.
  2227. *
  2228. * The normalized and case ignored DN of the new structure will point to the same string pointed to by \c ndn.
  2229. * The normalized and case ignored DN value is passed in to the parameter by reference.
  2230. *
  2231. * \param ndn The normalized and case ignored DN value to be set in the new \c Slapi_DN structure.
  2232. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2233. * the normalized and case ignored DN value set to the content of \c ndn.
  2234. * \warning The caller is still responsible for the memory used by \c ndn. This
  2235. * memory should not be freed until the returned \c Slapi_DN has been
  2236. * disposed of or reinitialized.
  2237. * \see slapi_sdn_new_ndn_byval()
  2238. * \see slapi_sdn_new_ndn_passin()
  2239. * \see slapi_sdn_free()
  2240. * \see slapi_sdn_copy()
  2241. * \see slapi_sdn_done()
  2242. */
  2243. Slapi_DN *slapi_sdn_new_ndn_byref(const char *ndn);
  2244. /**
  2245. * Creates a new \c Slapi_DN structure and intializes it's normalized and case ignored DN to a requested value.
  2246. *
  2247. * The normalized and case ignored DN of the new structure will point to the same string pointed to by \c ndn.
  2248. * Ownership of the memory pointed to by \c ndn is tranferred to the Slapi_DN.
  2249. *
  2250. * \param ndn The normalized and case ignored DN value to be set in the new \c Slapi_DN structure.
  2251. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2252. * the normalized and case ignored DN value set to the content of \c ndn.
  2253. * \see slapi_sdn_new_ndn_byval()
  2254. * \see slapi_sdn_new_ndn_byref()
  2255. * \see slapi_sdn_free()
  2256. * \see slapi_sdn_copy()
  2257. * \see slapi_sdn_done()
  2258. */
  2259. Slapi_DN *slapi_sdn_new_ndn_passin(const char *ndn);
  2260. /**
  2261. * Creates a new \c Slapi_DN structure and intializes it's DN to a requested value.
  2262. *
  2263. * The DN of the new structure will point to the same string pointed to by \c dn.
  2264. * Ownership of the memory pointed to by \c dn is tranferred to the Slapi_DN.
  2265. *
  2266. * \param dn The DN value to be set in the new \c Slapi_DN structure.
  2267. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2268. * a DN value set to the content of \c dn.
  2269. * \warning The caller is no longer responsible for the memory used by \c dn.
  2270. * This memory should not be freed directly. It will be freed when
  2271. * the \c Slapi_DN is properly disposed of.
  2272. * \see slapi_sdn_new_dn_byval()
  2273. * \see slapi_sdn_new_dn_byref()
  2274. * \see slapi_sdn_free()
  2275. * \see slapi_sdn_copy()
  2276. * \see slapi_sdn_done()
  2277. */
  2278. Slapi_DN *slapi_sdn_new_dn_passin(const char *dn);
  2279. /**
  2280. * Creates a new \c Slapi_DN structure and intializes it's normalized DN to a requested value.
  2281. *
  2282. * The DN of the new structure will point to the same string pointed to by \c normdn.
  2283. * The normalized DN value is passed in to the parameter by reference.
  2284. *
  2285. * \param normdn The normalized DN value to be set in the new \c Slapi_DN structure.
  2286. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2287. * the normalized DN value set to the content of \c normdn.
  2288. * \warning The caller is still responsible for the memory used by \c normdn.
  2289. * This memory should not be freed until the returned \c Slapi_DN
  2290. * has been disposed of or reinitialized.
  2291. * \see slapi_sdn_free()
  2292. * \see slapi_sdn_copy()
  2293. * \see slapi_sdn_done()
  2294. */
  2295. Slapi_DN *slapi_sdn_new_normdn_byref(const char *normdn);
  2296. /**
  2297. * Creates a new \c Slapi_DN structure and intializes it's normalized DN to a requested value.
  2298. *
  2299. * The DN of the new structure will point to the same string pointed to by \c normdn.
  2300. * Ownership of the memory pointed to by \c normdn is tranferred to the Slapi_DN.
  2301. *
  2302. * \param normdn The DN value to be set in the new \c Slapi_DN structure.
  2303. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2304. * a DN value set to the content of \c dn.
  2305. * \warning The caller is no longer responsible for the memory used by \c dn.
  2306. * This memory should not be freed directly. It will be freed when
  2307. * the \c Slapi_DN is properly disposed of.
  2308. * \see slapi_sdn_free()
  2309. * \see slapi_sdn_copy()
  2310. * \see slapi_sdn_done()
  2311. */
  2312. Slapi_DN *slapi_sdn_new_normdn_passin(const char *dn);
  2313. /**
  2314. * Creates a new \c Slapi_DN structure and intializes it's normalized DN to a requested value.
  2315. *
  2316. * The DN of the new structure will point to the duplicated string of \c normdn.
  2317. * Ownership of the memory pointed to by \c normdn is tranferred to the Slapi_DN.
  2318. *
  2319. * \param normdn The copy of the DN value to be set in the new \c Slapi_DN structure.
  2320. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2321. * a DN value set to the content of \c dn.
  2322. * \warning The caller is no longer responsible for the memory used by \c dn.
  2323. * This memory should not be freed directly. It will be freed when
  2324. * the \c Slapi_DN is properly disposed of.
  2325. * \see slapi_sdn_free()
  2326. * \see slapi_sdn_copy()
  2327. * \see slapi_sdn_done()
  2328. */
  2329. Slapi_DN *slapi_sdn_new_normdn_byval(const char *dn);
  2330. /**
  2331. * Sets a DN value in a \c Slapi_DN structure.
  2332. *
  2333. * The DN of the structure will point to a copy of the string pointed to by
  2334. * \c dn. The DN value is passed in to the parameter by value.
  2335. *
  2336. * \param sdn The target \c Slapi_DN structure.
  2337. * \param dn The DN value to be set in \c sdn.
  2338. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2339. * \warning The \c dn value is copied by the function itself. The caller
  2340. * is still responsible for the memory used by \c dn.
  2341. * \see slapi_sdn_set_dn_byref()
  2342. * \see slapi_sdn_set_dn_passin()
  2343. */
  2344. Slapi_DN *slapi_sdn_set_dn_byval(Slapi_DN *sdn, const char *dn);
  2345. /**
  2346. * Sets a DN value in a \c Slapi_DN structure.
  2347. *
  2348. * The DN of the structure will point to the same string pointed to by \c dn.
  2349. * The DN value is passed in to the parameter by reference.
  2350. *
  2351. * \param sdn The target \c Slapi_DN structure.
  2352. * \param dn The DN value to be set in \c sdn.
  2353. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2354. * \warning The caller is still responsible for the memory used by \c dn. This
  2355. * memory should not be freed until the returned \c Slapi_DN has been
  2356. * disposed of or reinitialized.
  2357. * \see slapi_sdn_set_dn_byval()
  2358. * \see slapi_sdn_set_dn_passin()
  2359. */
  2360. Slapi_DN *slapi_sdn_set_dn_byref(Slapi_DN *sdn, const char *dn);
  2361. /**
  2362. * Sets a DN value in a \c Slapi_DN structure.
  2363. *
  2364. * The DN of the structure will point to the same string pointed to by \c dn.
  2365. * Ownership of the memory pointed to by \c dn is tranferred to the Slapi_DN.
  2366. *
  2367. * \param sdn The target \c Slapi_DN structure.
  2368. * \param dn The DN value to be set in \c sdn.
  2369. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2370. * \warning The caller is no longer responsible for the memory used by \c dn.
  2371. * This memory should not be freed directly. It will be freed when
  2372. * the \c Slapi_DN is properly disposed of.
  2373. * \see slapi_sdn_set_dn_byval()
  2374. * \see slapi_sdn_set_dn_byref()
  2375. */
  2376. Slapi_DN *slapi_sdn_set_dn_passin(Slapi_DN *sdn, const char *dn);
  2377. /**
  2378. * Sets a normalized DN value in a \c Slapi_DN structure.
  2379. *
  2380. * The DN of the structure will point to the same string pointed to by \c normdn.
  2381. * The normalized DN value is passed in to the parameter by reference.
  2382. *
  2383. * \param sdn The target \c Slapi_DN structure.
  2384. * \param normdn The normalized DN value to be set in \c sdn.
  2385. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2386. * \warning The caller is still responsible for the memory used by \c normdn.
  2387. * This memory should not be freed until the returned \c Slapi_DN
  2388. * has been disposed of or reinitialized.
  2389. * \see slapi_sdn_set_dn_byref()
  2390. */
  2391. Slapi_DN *slapi_sdn_set_normdn_byref(Slapi_DN *sdn, const char *normdn);
  2392. /**
  2393. * Sets a normalized DN value in a \c Slapi_DN structure.
  2394. *
  2395. * The DN of the structure will point to the same string pointed to by \c normdn.
  2396. * Ownership of the memory pointed to by \c normdn is tranferred to the Slapi_DN.
  2397. *
  2398. * \param sdn The target \c Slapi_DN structure.
  2399. * \param normdn The normalized DN value to be set in \c sdn.
  2400. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2401. * \warning The caller is no longer responsible for the memory used by \c normdn.
  2402. * This memory should not be freed directly. It will be freed when
  2403. * the \c Slapi_DN is properly disposed of.
  2404. * \see slapi_sdn_set_dn_passin()
  2405. */
  2406. Slapi_DN *slapi_sdn_set_normdn_passin(Slapi_DN *sdn, const char *dn);
  2407. /**
  2408. * Sets a normalized DN value in a \c Slapi_DN structure.
  2409. *
  2410. * The normalized DN of the structure will point to a copy of the string
  2411. * pointed to by \c dn. The normalized DN value is passed in to the parameter
  2412. * by value.
  2413. * Ownership of the memory pointed to by \c normdn is tranferred to the Slapi_DN.
  2414. *
  2415. * \param sdn The target \c Slapi_DN structure.
  2416. * \param normdn The normalized DN value to be set in \c sdn.
  2417. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2418. * \warning The caller is no longer responsible for the memory used by \c normdn.
  2419. * This memory should not be freed directly. It will be freed when
  2420. * the \c Slapi_DN is properly disposed of.
  2421. * \see slapi_sdn_set_dn_passin()
  2422. */
  2423. Slapi_DN *slapi_sdn_set_normdn_byval(Slapi_DN *sdn, const char *dn);
  2424. /**
  2425. * Sets a normalized and case ignored DN value in a \c Slapi_DN structure.
  2426. *
  2427. * The normalized DN of the structure will point to a copy of the string
  2428. * pointed to by \c ndn. The normalized DN value is passed in to the parameter
  2429. * by value.
  2430. *
  2431. * \param sdn The target \c Slapi_DN structure.
  2432. * \param ndn The normalized DN value to be set in \c sdn.
  2433. * \return A pointer to the \c Slapi_DN structure containing the new normalized DN value.
  2434. * \warning The \c ndn value is copied by the function itself. The caller
  2435. * is still responsible for the memory used by \c ndn.
  2436. * \see slapi_sdn_set_ndn_byref()
  2437. * \see slapi_sdn_set_ndn_passin()
  2438. */
  2439. Slapi_DN *slapi_sdn_set_ndn_byval(Slapi_DN *sdn, const char *ndn);
  2440. /**
  2441. * Sets a normalized DN value in a \c Slapi_DN structure.
  2442. *
  2443. * The normalized DN of the structure will point to the same string pointed to
  2444. * by \c ndn. The normalized DN value is passed in to the parameter by reference.
  2445. *
  2446. * \param sdn The target \c Slapi_DN structure.
  2447. * \param ndn The normalized DN value to be set in \c sdn.
  2448. * \return A pointer to the \c Slapi_DN structure containing the new normalized DN value.
  2449. * \warning The caller is still responsible for the memory used by \c ndn. This
  2450. * memory should not be freed until the returned \c Slapi_DN has been
  2451. * disposed of or reinitialized.
  2452. * \see slapi_sdn_set_ndn_byval()
  2453. * \see slapi_sdn_set_ndn_passin()
  2454. */
  2455. Slapi_DN *slapi_sdn_set_ndn_byref(Slapi_DN *sdn, const char *ndn);
  2456. /**
  2457. * Sets a normalized DN value in a \c Slapi_DN structure.
  2458. *
  2459. * The normalized DN of the structure will point to the same string pointed to
  2460. * by \c ndn.
  2461. * Ownership of the memory pointed to by \c ndn is tranferred to the Slapi_DN.
  2462. *
  2463. * \param sdn The target \c Slapi_DN structure.
  2464. * \param ndn The normalized DN value to be set in \c sdn.
  2465. * \return A pointer to the \c Slapi_DN structure containing the new normalized DN value.
  2466. * \see slapi_sdn_set_ndn_byval()
  2467. * \see slapi_sdn_set_ndn_byref()
  2468. */
  2469. Slapi_DN *slapi_sdn_set_ndn_passin(Slapi_DN *sdn, const char *ndn);
  2470. /**
  2471. * Clears the contents of a Slapi_DN structure.
  2472. *
  2473. * Both the DN and the normalized DN are freed if the \c Slapi_DN structure
  2474. * owns the memory. Both pointers are then set to \c NULL.
  2475. *
  2476. * \param sdn Pointer to the \c Slapi_DN to clear.
  2477. * \see slapi_sdn_free()
  2478. */
  2479. void slapi_sdn_done(Slapi_DN *sdn);
  2480. /**
  2481. * Frees a \c Slapi_DN structure.
  2482. *
  2483. * Both the DN and the normalized DN are freed if the \c Slapi_DN structure
  2484. * owns the memory. The \c Slapi_DN structure itself is then freed.
  2485. *
  2486. * \param sdn Pointer to the pointer of the \c Slapi_DN structure to be freed.
  2487. * \see slapi_sdn_done()
  2488. * \see slapi_sdn_new()
  2489. */
  2490. void slapi_sdn_free(Slapi_DN **sdn);
  2491. /**
  2492. * Retrieves the normalized DN value of a \c Slapi_DN structure.
  2493. *
  2494. * If the structure does not contain a normalized DN yet, it will normalize
  2495. * the un-normalized DN and set it in the structure.
  2496. *
  2497. * \param sdn The \c Slapi_DN strucure containing the DN value.
  2498. * \return A pointer to the DN value if one is set.
  2499. * \return A pointer to the normalized and case ignored DN value if one is set and no
  2500. * DN value is set.
  2501. * \return \c NULL if no normalized DN or normalized and case ignored DN value is set.
  2502. * \warning The pointer returned is the actual value from the structure, not a copy.
  2503. * \see slapi_sdn_get_ndn()
  2504. * \see slapi_sdn_get_udn()
  2505. */
  2506. const char * slapi_sdn_get_dn(const Slapi_DN *sdn);
  2507. /**
  2508. * Retrieves the normalized and case ignored DN value of a \c Slapi_DN structure.
  2509. *
  2510. * If the structure does not contain a normalized and case ignored DN yet,
  2511. * it will normalize and case ignore the DN and set it in the structure.
  2512. *
  2513. * \param sdn The \c Slapi_DN strucure containing the normalized and case ignored DN value.
  2514. * \return The normalized DN value.
  2515. * \return \c NULL if no DN or normalized DN value is set.
  2516. * \warning The pointer returned is the actual value from the structure, not a copy.
  2517. * \see slapi_sdn_get_dn()
  2518. * \see slapi_sdn_get_udn()
  2519. */
  2520. const char * slapi_sdn_get_ndn(const Slapi_DN *sdn);
  2521. /**
  2522. * Retrieves the un-normalized DN value of a \c Slapi_DN structure.
  2523. *
  2524. * \param sdn The \c Slapi_DN strucure containing the DN value.
  2525. * \return A pointer to the DN value if one is set.
  2526. * \return A pointer to the normalized DN value if one is set and no
  2527. * DN value is set.
  2528. * \return \c NULL if no DN or normalized DN value is set.
  2529. * \warning The pointer returned is the actual value from the structure, not a copy.
  2530. * \see slapi_sdn_get_dn()
  2531. * \see slapi_sdn_get_ndn()
  2532. */
  2533. const char * slapi_sdn_get_udn(const Slapi_DN *sdn);
  2534. /**
  2535. * Fills in an existing \c Slapi_DN structure with the parent DN of the passed in \c Slapi_DN.
  2536. *
  2537. * \param sdn Pointer to the \c Slapi_DN structure containing the DN whose parent is desired.
  2538. * \param sdn_parent Pointer to the \c Slapi_DN structure where the parent DN is returned.
  2539. * The existing contents (if any) will be cleared before the new DN value is set.
  2540. * \warning A \c Slapi_DN structure for \c sdn_parent must be allocated before calling this function.
  2541. * \see slapi_sdn_get_backend_parent()
  2542. */
  2543. void slapi_sdn_get_parent(const Slapi_DN *sdn,Slapi_DN *sdn_parent);
  2544. /**
  2545. * Fills in an existing \c Slapi_DN structure with the parent DN of the passed in \c Slapi_DN.
  2546. *
  2547. * \param sdn Pointer to the \c Slapi_DN structure containing the DN whose parent is desired.
  2548. * \param sdn_parent Pointer to the \c Slapi_DN structure where the parent DN is returned.
  2549. * The existing contents (if any) will be cleared before the new DN value is set.
  2550. * \param is_tombstone If non-zero, the special leaf rdn "nsuniqueid=.." is ignored.
  2551. * \warning A \c Slapi_DN structure for \c sdn_parent must be allocated before calling this function.
  2552. * \see slapi_sdn_get_backend_parent()
  2553. */
  2554. void slapi_sdn_get_parent_ext(const Slapi_DN *sdn,Slapi_DN *sdn_parent,int is_tombstone);
  2555. /**
  2556. * Fills in an existing \c Slapi_DN structure with the parent DN of an entry within a specific backend.
  2557. *
  2558. * The parent DN is returned in \c sdn_parent, unless \c sdn is empty or is a suffix of the backend
  2559. * itself. In this case, \c sdn_parent is empty.
  2560. *
  2561. * \param sdn Pointer to the \c Slapi_DN structure containing the DN whose parent is desired.
  2562. * \param sdn_parent Pointer to the \c Slapi_DN structure where the parent DN is returned.
  2563. * The existing contents (if any) will be cleared before the new DN value is set.
  2564. * \param backend Backend to search for the parent of \c sdn.
  2565. * \warning A \c Slapi_DN structure for \c sdn_parent must be allocated before calling this function.
  2566. * \see slapi_sdn_get_parent()
  2567. */
  2568. void slapi_sdn_get_backend_parent(const Slapi_DN *sdn,Slapi_DN *sdn_parent,const Slapi_Backend *backend);
  2569. /**
  2570. * Fills in an existing \c Slapi_DN structure with the parent DN of an entry within a specific backend.
  2571. *
  2572. * The parent DN is returned in \c sdn_parent, unless \c sdn is empty or is a suffix of the backend
  2573. * itself. In this case, \c sdn_parent is empty.
  2574. *
  2575. * \param sdn Pointer to the \c Slapi_DN structure containing the DN whose parent is desired.
  2576. * \param sdn_parent Pointer to the \c Slapi_DN structure where the parent DN is returned.
  2577. * The existing contents (if any) will be cleared before the new DN value is set.
  2578. * \param backend Backend to search for the parent of \c sdn.
  2579. * \param is_tombstone If non-zero, the special leaf rdn "nsuniqueid=.." is ignored.
  2580. * \warning A \c Slapi_DN structure for \c sdn_parent must be allocated before calling this function.
  2581. * \see slapi_sdn_get_parent()
  2582. */
  2583. void slapi_sdn_get_backend_parent_ext(const Slapi_DN *sdn,Slapi_DN *sdn_parent,const Slapi_Backend *backend,int is_tombstone);
  2584. /**
  2585. * Return the size of a \c Slapi_DN structure.
  2586. *
  2587. * \param sdn Pointer to the \c Slapi_DN structure to get the size.
  2588. */
  2589. size_t slapi_sdn_get_size(const Slapi_DN *sdn);
  2590. /**
  2591. * Duplicates a \c Slapi_DN structure.
  2592. *
  2593. * \param sdn Pointer to the \c Slapi_DN structure to duplicate.
  2594. * \return A pointer to a duplicate of \c sdn.
  2595. * \see slapi_sdn_copy()
  2596. * \see slapi_sdn_new()
  2597. * \see slapi_sdn_free()
  2598. */
  2599. Slapi_DN * slapi_sdn_dup(const Slapi_DN *sdn);
  2600. /**
  2601. * Copies the contents of a \c Slapi_DN to another \c existing Slapi_DN.
  2602. *
  2603. * \param from A pointer to the \c Slapi_DN structure to copy from.
  2604. * \param to A pointer to the \c Slapi_DN structure to copy to.
  2605. * \warning You must allocate \c to before calling this function.
  2606. * \see slapi_sdn_dup()
  2607. */
  2608. void slapi_sdn_copy(const Slapi_DN *from, Slapi_DN *to);
  2609. /**
  2610. * Compares two \c Slapi_DN structures.
  2611. *
  2612. * Performs a case-sensitive comparison of two \c Slapi_DN structures.
  2613. *
  2614. * \param sdn1 A pointer to the first \c Slapi_DN structure to compare.
  2615. * \param sdn2 A pointer to the second \c Slapi_DN structure to compare.
  2616. * \return \c 0 if \c sdn1 is equal to \c sdn2.
  2617. * \return \c -1 if \c sdn1 is \c NULL.
  2618. * \return \c 1 if \c sdn2 is \c NULL and \c sdn1 is not \c NULL.
  2619. */
  2620. int slapi_sdn_compare( const Slapi_DN *sdn1, const Slapi_DN *sdn2 );
  2621. /**
  2622. * Checks if a DN or normalized DN is set in a \c Slapi_DN.
  2623. *
  2624. * \param sdn A pointer to the \c Slapi_DN structure to check.
  2625. * \return \c 1 if there is no DN or normalized DN set in \c sdn.
  2626. * \return \c 0 if \c sdn is not empty.
  2627. * \see slapi_sdn_done()
  2628. */
  2629. int slapi_sdn_isempty( const Slapi_DN *sdn);
  2630. /**
  2631. * Checks whether a \c Slapi_DN structure contains a suffix of another \c Slapi_DN structure.
  2632. *
  2633. * \param sdn A pointer to the \c Slapi_DN structure to check.
  2634. * \param suffixsdn A pointer to the \c Slapi_DN structure of the suffix.
  2635. * \return \c 1 if the DN in \c suffixsdn is a suffix of \c sdn.
  2636. * \return \c 0 if the DN in \c suffixsdn is not a suffix of \c sdn.
  2637. * \see slapi_sdn_isparent()
  2638. * \see slapi_sdn_isgrandparent()
  2639. */
  2640. int slapi_sdn_issuffix(const Slapi_DN *sdn, const Slapi_DN *suffixsdn);
  2641. /**
  2642. * Checks whether a DN is the parent of a given DN.
  2643. *
  2644. * \param parent A pointer to the \c Slapi_DN structure containing the DN
  2645. * which claims to be the parent of the DN in \c child.
  2646. * \param child A pointer to the Slapi_DN structure containing the DN of the
  2647. * supposed child of the DN in the structure pointed to by \c parent.
  2648. * \return \c 1 if the DN in \c parent is the parent of the DN in \c child.
  2649. * \return \c 0 if the DN in \c parent is not the parent of the DN in \c child.
  2650. * \see slapi_sdn_isgrandparent()
  2651. * \see slapi_sdn_issuffix()
  2652. * \see slapi_sdn_get_parent()
  2653. */
  2654. int slapi_sdn_isparent( const Slapi_DN *parent, const Slapi_DN *child );
  2655. /**
  2656. * Checks whether a DN is the grandparent of a given DN.
  2657. *
  2658. * \param parent A pointer to the \c Slapi_DN structure containing the DN
  2659. * which claims to be the grandparent of the DN in \c child.
  2660. * \param child A pointer to the Slapi_DN structure containing the DN of the
  2661. * supposed grandchild of the DN in the structure pointed to by \c parent.
  2662. * \return \c 1 if the DN in \c parent is the grandparent of the DN in \c child.
  2663. * \return \c 0 if the DN in \c parent is not the grandparent of the DN in \c child.
  2664. * \see slapi_sdn_isparent()
  2665. * \see slapi_sdn_issuffix()
  2666. * \see slapi_sdn_get_parent()
  2667. */
  2668. int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child );
  2669. /**
  2670. * Gets the length of the normalized DN of a Slapi_DN structure.
  2671. *
  2672. * This function normalizes \c sdn if it has not already been normalized.
  2673. *
  2674. * \param sdn A pointer to the \c Slapi_DN structure containing the DN value.
  2675. * \return The length of the normalized DN.
  2676. */
  2677. int slapi_sdn_get_ndn_len(const Slapi_DN *sdn);
  2678. /**
  2679. * Checks if a DN is within a specified scope under a specified base DN.
  2680. *
  2681. * \param dn A pointer to the \c Slapi_DN structure to test.
  2682. * \param base The base DN against which \c dn is going to be tested.
  2683. * \param scope The scope tested. Valid scopes are:
  2684. * \arg \c LDAP_SCOPE_BASE
  2685. * \arg \c LDAP_SCOPE_ONELEVEL
  2686. * \arg \c LDAP_SCOPE_SUBTREE
  2687. * \return non-zero if \c dn matches the scoping criteria given by \c base and \c scope.
  2688. * \see slapi_sdn_compare()
  2689. * \see slapi_sdn_isparent()
  2690. * \see slapi_sdn_issuffix()
  2691. */
  2692. int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope );
  2693. /**
  2694. * Checks if a DN is within a specified scope under a specified base DN.
  2695. * This api adjusts tombstoned DN when comparing with the base dn.
  2696. *
  2697. * \param dn A pointer to the \c Slapi_DN structure to test.
  2698. * \param base The base DN against which \c dn is going to be tested.
  2699. * \param scope The scope tested. Valid scopes are:
  2700. * \arg \c LDAP_SCOPE_BASE
  2701. * \arg \c LDAP_SCOPE_ONELEVEL
  2702. * \arg \c LDAP_SCOPE_SUBTREE
  2703. * \param flags 0 or SLAPI_ENTRY_FLAG_TOMBSTONE
  2704. * \return non-zero if \c dn matches the scoping criteria given by \c base and \c scope.
  2705. * \see slapi_sdn_compare()
  2706. * \see slapi_sdn_isparent()
  2707. * \see slapi_sdn_issuffix()
  2708. */
  2709. int slapi_sdn_scope_test_ext( const Slapi_DN *dn, const Slapi_DN *base, int scope, int flags );
  2710. /**
  2711. * Retreives the RDN from a given DN.
  2712. *
  2713. * This function takes the DN stored in the \c Slapi_DN structure pointed to
  2714. * by \c sdn and fills in it's RDN within the \c Slapi_RDN structure pointed
  2715. * to by \c rdn.
  2716. *
  2717. * \param sdn A pointer to the \c Slapi_DN structure containing the DN.
  2718. * \param rdn A pointer to the \c Slapi_RDN structure where the RDN is filled in.
  2719. * \warning The caller must allocate \c rdn before calling this function.
  2720. * \see slapi_sdn_get_dn()
  2721. * \see slapi_sdn_set_rdn()
  2722. * \see slapi_sdn_add_rdn()
  2723. * \see slapi_sdn_is_rdn_component()
  2724. */
  2725. void slapi_sdn_get_rdn(const Slapi_DN *sdn,Slapi_RDN *rdn);
  2726. /**
  2727. * Sets a new RDN for a given DN.
  2728. *
  2729. * This function changes the RDN of \c sdn by adding the value from
  2730. * \c rdn to the parent DN of \c sdn.
  2731. *
  2732. * \param sdn The DN that you want to rename.
  2733. * \param rdn The new RDN.
  2734. * \return A pointer to the \c Slapi_DN structure that has been renamed.
  2735. * \see slapi_sdn_get_rdn()
  2736. */
  2737. Slapi_DN *slapi_sdn_set_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
  2738. /**
  2739. * Sets a new parent for a given DN.
  2740. *
  2741. * This function keeps the RDN of the original DN and adds it to the
  2742. * specified parent DN.
  2743. *
  2744. * \param sdn The \c Slapi_DN structure containing the DN whose parent you want to change.
  2745. * \param parentdn The \c Slapi_DN structure containing the new parent DN.
  2746. * \return A pointer to the \c Slapi_DN structure that contains the new DN.
  2747. * \see slapi_sdn_isparent()
  2748. * \see slapi_sdn_get_parent()
  2749. */
  2750. Slapi_DN *slapi_sdn_set_parent(Slapi_DN *sdn, const Slapi_DN *parentdn);
  2751. /**
  2752. * Builds a new DN out of a new RDN and the DN of the new parent.
  2753. *
  2754. * The new DN is worked out by adding the new RDN in \c newrdn to a
  2755. * parent DN. The parent will be the value in \c newsuperiordn if different
  2756. * from \c NULL, and will otherwise be taken from \c dn_olddn by removing
  2757. * the old RDN (the parent of the entry will still be the same as the new DN).
  2758. *
  2759. * \param dn_olddn The old DN value.
  2760. * \param newrdn The new RDN value.
  2761. * \param newsuperiordn If not \c NULL, will be the DN of the future superior
  2762. * entry of the new DN, which will be worked out by adding the value
  2763. * in \c newrdn in front of the content of this parameter.
  2764. * \return The new DN for the entry whose previous DN was \c dn_olddn.
  2765. */
  2766. char * slapi_moddn_get_newdn(Slapi_DN *dn_olddn, const char *newrdn, const char *newsuperiordn);
  2767. Slapi_DN *slapi_sdn_add_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
  2768. /*
  2769. * Slapi_RDN functions
  2770. */
  2771. /**
  2772. * Creates a new \c Slapi_RDN structure.
  2773. *
  2774. * Allocates the necessary memory and initializes both the
  2775. * RDN value and the array of split RDNs to \c NULL.
  2776. *
  2777. * \return A pointer to the newly allocated, and still empty, \c Slapi_RDN structure.
  2778. * \warning You must free the returned \c Slapi_RDN structure by calling \c slapi_rdn_free()
  2779. * when you are finished using it.
  2780. * \see slapi_rdn_init()
  2781. * \see slapi_rdn_done()
  2782. * \see slapi_rdn_free()
  2783. */
  2784. Slapi_RDN *slapi_rdn_new( void );
  2785. /**
  2786. * Creates a new \c Slapi_RDN structure and initializes it from a string.
  2787. *
  2788. * \param dn The DN value whose RDN will be used to initialize the new
  2789. * \c Slapi_RDN structure.
  2790. * \return A pointer to the newly allocated and initialized \c Slapi_RDN structure.
  2791. * \warning You must free the returned \c Slapi_RDN structure by calling \c slapi_rdn_free()
  2792. * when you are finished using it.
  2793. * \see slapi_rdn_new_sdn()
  2794. * \see slapi_rdn_new_rdn()
  2795. * \see slapi_rdn_free()
  2796. */
  2797. Slapi_RDN *slapi_rdn_new_dn(const char *dn);
  2798. /**
  2799. * Creates a new \c Slapi_RDN structure and initializes it from a \c Slapi_DN.
  2800. *
  2801. * \param sdn The \c Slapi_DN structure whose RDN will be used to initialize
  2802. * the new \c Slapi_RDN structure.
  2803. * \return A pointer to the newly allocated and initialized \c Slapi_RDN structure.
  2804. * \warning You must free the returned \c Slapi_RDN structure by calling \c slapi_rdn_free()
  2805. * when you are finished using it.
  2806. * \see slapi_rdn_new_dn()
  2807. * \see slapi_rdn_new_rdn()
  2808. * \see slapi_rdn_free()
  2809. */
  2810. Slapi_RDN *slapi_rdn_new_sdn(const Slapi_DN *sdn);
  2811. /**
  2812. * Creates a new \c Slapi_RDN structure and initializes it from a \c Slapi_RDN.
  2813. *
  2814. * \param fromrdn The \c Slapi_RDN structure whose RDN will be used to initialize
  2815. * the new \c Slapi_RDN structure.
  2816. * \return A pointer to the newly allocated and initialized \c Slapi_RDN structure.
  2817. * \warning You must free the returned \c Slapi_RDN structure by calling \c slapi_rdn_free()
  2818. * when you are finished using it.
  2819. * \see slapi_rdn_new_dn()
  2820. * \see slapi_rdn_new_sdn()
  2821. * \see slapi_rdn_free()
  2822. */
  2823. Slapi_RDN *slapi_rdn_new_rdn(const Slapi_RDN *fromrdn);
  2824. /**
  2825. * Clears out a \c Slapi_RDN structure.
  2826. *
  2827. * Sets both the RDN value and the array of split RDNs to \c NULL.
  2828. *
  2829. * \param rdn The \c Slapi_RDN structure to be initialized.
  2830. * \warning The previous contents of \c rdn are not freed. It is
  2831. * up to the caller to do this first if necessary.
  2832. * \see slapi_rdn_new()
  2833. * \see slapi_rdn_free()
  2834. * \see slapi_rdn_done()
  2835. */
  2836. void slapi_rdn_init(Slapi_RDN *rdn);
  2837. /**
  2838. * Initializes a \c Slapi_RDN structure from a string.
  2839. *
  2840. * \param rdn The \c Slapi_RDN structure to be initialized.
  2841. * \param dn The DN value whose RDN will be used to initialize \c rdn.
  2842. * \warning The previous contents of \c rdn are not freed. It is
  2843. * up to the caller to do this first if necessary.
  2844. * \see slapi_rdn_done()
  2845. * \see slapi_rdn_init_sdn()
  2846. * \see slapi_rdn_init_rdn()
  2847. */
  2848. void slapi_rdn_init_dn(Slapi_RDN *rdn,const char *dn);
  2849. /**
  2850. * Initializes a \c Slapi_RDN structure from a \c Slapi_DN.
  2851. *
  2852. * \param rdn The \c Slapi_RDN structure to be initialized.
  2853. * \param sdn The \c Slapi_DN whose RDN will be used to initialize \c rdn.
  2854. * \warning The previous contents of \c rdn are not freed. It is
  2855. * up to the caller to do this first if necessary.
  2856. * \see slapi_rdn_done()
  2857. * \see slapi_rdn_init_dn()
  2858. * \see slapi_rdn_init_rdn()
  2859. */
  2860. void slapi_rdn_init_sdn(Slapi_RDN *rdn,const Slapi_DN *sdn);
  2861. /**
  2862. * Initializes a \c Slapi_RDN structure from another \c Slapi_RDN.
  2863. *
  2864. * \param rdn The \c Slapi_RDN structure to be initialized.
  2865. * \param fromrdn The \c Slapi_RDN structure that will be used to
  2866. * initialize \c rdn.
  2867. * \warning The previous contents of \c rdn are not freed. It is
  2868. * up to the caller to do this first if necessary.
  2869. * \see slapi_rdn_done()
  2870. * \see slapi_rdn_init_dn()
  2871. * \see slapi_rdn_init_sdn()
  2872. */
  2873. void slapi_rdn_init_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn);
  2874. /**
  2875. * Sets the RDN value in a \c Slapi_RDN structure from a string.
  2876. *
  2877. * The previous contents of the \c rdn are freed before
  2878. * the new RDN is set.
  2879. *
  2880. * \param rdn The target \c Slapi_RDN structure.
  2881. * \param dn The DN value whose RDN will be set in \c rdn.
  2882. * \see slapi_rdn_set_sdn()
  2883. * \see slapi_rdn_set_rdn()
  2884. */
  2885. void slapi_rdn_set_dn(Slapi_RDN *rdn,const char *dn);
  2886. Slapi_RDN *slapi_rdn_new_all_dn(const char *dn);
  2887. int slapi_rdn_init_all_dn(Slapi_RDN *rdn, const char *dn);
  2888. int slapi_rdn_init_all_sdn(Slapi_RDN *rdn, const Slapi_DN *sdn);
  2889. /**
  2890. * Sets the RDN value in a \c Slapi_RDN structure from a \c Slapi_DN.
  2891. *
  2892. * The previous contents of the \c rdn are freed before
  2893. * the new RDN is set.
  2894. *
  2895. * \param rdn The target \c Slapi_RDN structure.
  2896. * \param sdn The \c Slapi_DN value whose RDN will be set in \c rdn.
  2897. * \see slapi_rdn_set_dn()
  2898. * \see slapi_rdn_set_rdn()
  2899. */
  2900. void slapi_rdn_set_sdn(Slapi_RDN *rdn,const Slapi_DN *sdn);
  2901. /**
  2902. * Sets the RDN value in a \c Slapi_RDN structure from a \c Slapi_RDN.
  2903. *
  2904. * The previous contents of the \c rdn are freed before
  2905. * the new RDN is set.
  2906. *
  2907. * \param rdn The target \c Slapi_RDN structure.
  2908. * \param fromrdn The \c Slapi_RDN value whose RDN will be set in \c rdn.
  2909. * \see slapi_rdn_set_dn()
  2910. * \see slapi_rdn_set_sdn()
  2911. */
  2912. void slapi_rdn_set_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn);
  2913. /**
  2914. * Frees a \c Slapi_RDN structure and it's contents from memory.
  2915. *
  2916. * \param rdn A pointer to a pointer of the \c Slapi_RDN strucure to be freed.
  2917. * \see slapi_rdn_new()
  2918. * \see slapi_rdn_done()
  2919. */
  2920. void slapi_rdn_free(Slapi_RDN **rdn);
  2921. /**
  2922. * Checks if the value of ipAddress is a IPv6 address
  2923. *
  2924. * \param ipAddress is a string that is either an IPv4 or IPv6 address
  2925. * \return 1 if address is an IPv6 address
  2926. * \return 0 if address is an IPv4 address
  2927. */
  2928. int slapi_is_ipv6_addr( const char *ipAddress);
  2929. /**
  2930. * Returns the length of a ber-encoded ldap operation
  2931. *
  2932. * \param bv is the berval of the encoded ldap operation
  2933. * \param strict set to 0 if "bv" does not contain the entire LDAP encoding
  2934. * \return -1 if the length can not be determined
  2935. * \return length
  2936. */
  2937. ber_len_t slapi_berval_get_msg_len(struct berval *bv, int strict);
  2938. /**
  2939. * Frees and clears the contents of a \c Slapi_RDN structure from memory.
  2940. *
  2941. * Both the RDN value and the array of split RDNs are freed. Those pointers
  2942. * are then set to \c NULL.
  2943. *
  2944. * \param rdn A pointer to the \c Slapi_RDN strucure to clear.
  2945. * \see slapi_rdn_free()
  2946. * \see slapi_rdn_init()
  2947. */
  2948. void slapi_rdn_done(Slapi_RDN *rdn);
  2949. /**
  2950. * Gets the first RDN stored in a \c Slapi_RDN structure.
  2951. *
  2952. * The type and the value of the first RDN are retrieved.
  2953. *
  2954. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  2955. * \param type Address to return a pointer to the type of the first RDN. If
  2956. * this is \c NULL at the return of the function, it means that \c rdn
  2957. * is empty.
  2958. * \param value Address to return a pointer to the value of the first RDN.
  2959. * If this is \c NULL at the return of the function, it means that
  2960. * \c rdn is empty.
  2961. * \return \c -1 if \c rdn is empty.
  2962. * \return \c 1 if the operation is successful.
  2963. * \warning Do not free the returned type or value.
  2964. * \see slapi_rdn_get_next()
  2965. * \see slapi_rdn_get_rdn()
  2966. */
  2967. int slapi_rdn_get_first(Slapi_RDN *rdn, char **type, char **value);
  2968. /**
  2969. * Gets the next RDN stored in a \c Slapi_RDN structure.
  2970. *
  2971. * The type/value pair for the RDN at the position following that indicated
  2972. * by \c index will be retrieved.
  2973. *
  2974. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  2975. * \param index Indicates the position that precedes that of the desired RDN.
  2976. * For example, pass 1 if you would like the second RDN.
  2977. * \param type Address to return a pointer to the type of the next RDN. If
  2978. * this is \c NULL at the return of the function, it means that \c rdn
  2979. * is empty.
  2980. * \param value Address to return a pointer to the value of the next RDN.
  2981. * If this is \c NULL at the return of the function, it means that
  2982. * \c rdn is empty.
  2983. * \return \c -1 if no RDN exists at the index position.
  2984. * \return The position (\c index + \c 1) of the retrieved RDN if the operation is successful.
  2985. * \see slapi_rdn_get_first()
  2986. * \see slapi_rdn_get_rdn()
  2987. */
  2988. int slapi_rdn_get_next(Slapi_RDN *rdn, int index, char **type, char **value);
  2989. /**
  2990. * Finds a RDN in a \c Slapi_RDN structure and returns it's index.
  2991. *
  2992. * The \c Slapi_RDN structure will be searched for a RDN matching
  2993. * the given type and value.
  2994. *
  2995. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  2996. * \param type Type (\c cn, \c o, \c ou, etc.) of the RDN that is searched for.
  2997. * \param value Value of the RDN that is searched for.
  2998. * \param length Gives the length of the value that should be taken into
  2999. * account for the string comparisons when searching for the RDN.
  3000. * \return The index of the RDN that matches \c type and \c value.
  3001. * \return \c -1 if no RDN stored in \c rdn matches \c type and \c value.
  3002. * \see slapi_rdn_get_index_attr()
  3003. * \see slapi_rdn_contains()
  3004. */
  3005. int slapi_rdn_get_index(Slapi_RDN *rdn, const char *type, const char *value,size_t length);
  3006. /**
  3007. * Finds a RDN for a given type in a \c Slapi_RDN structure and returns it's index.
  3008. *
  3009. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  3010. * \param type Type (\c cn, \c o, \c ou, etc.) of the RDN that is searched for.
  3011. * \param value Address to return a pointer to the value of the next RDN.
  3012. * If this is \c NULL at the return of the function, it means that
  3013. * no matching RDN exist in \c rdn.
  3014. * \return The index of the RDN that matches \c type.
  3015. * \return \c -1 if no RDN stored in \c rdn matches \c type.
  3016. * \see slapi_rdn_get_index()
  3017. */
  3018. int slapi_rdn_get_index_attr(Slapi_RDN *rdn, const char *type, char **value);
  3019. /**
  3020. * Checks if a RDN exists in a \c Slapi_RDN structure.
  3021. *
  3022. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  3023. * \param type Type (\c cn, \c o, \c ou, etc.) of the RDN that is searched for.
  3024. * \param value Value of the RDN that is searched for.
  3025. * \param length Gives the length of the value that should be taken into
  3026. * account for the string comparisons when searching for the RDN.
  3027. * \return \c 1 if \c rdn contains a RDN that matches \c type and \c value.
  3028. * \return \c 0 if no RDN stored in \c rdn matches \c type and \c value.
  3029. * \see slapi_rdn_get_index()
  3030. * \see slapi_rdn_contains_attr()
  3031. */
  3032. int slapi_rdn_contains(Slapi_RDN *rdn, const char *type, const char *value,size_t length);
  3033. /**
  3034. * Checks if a RDN for a given type exists in a \c Slapi_RDN structure.
  3035. *
  3036. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  3037. * \param type Type (\c cn, \c o, \c ou, etc.) of the RDN that is searched for.
  3038. * \param value Address to return a pointer to the value of the next RDN.
  3039. * If this is \c NULL at the return of the function, it means that
  3040. * no matching RDN exist in \c rdn.
  3041. * \return \c 1 if \c rdn contains a RDN that matches \c type.
  3042. * \return \c 0 if no RDN stored in \c rdn matches \c type.
  3043. * \see slapi_rdn_get_index_attr()
  3044. * \see slapi_rdn_contains()
  3045. */
  3046. int slapi_rdn_contains_attr(Slapi_RDN *rdn, const char *type, char **value);
  3047. /**
  3048. * Adds a new RDN to a \c Slapi_RDN structure.
  3049. *
  3050. * A new type/value pair will be added to an existing RDN, or the type/value
  3051. * pair will be set as the new RDN if \c rdn is empty. This function resets the
  3052. * FLAG_RDNS flags, which means that the RDN array with-in the \c Slapi_RDN
  3053. * structure is no longer current with the new RDN.
  3054. *
  3055. * \param rdn The target \c Slapi_RDN structure.
  3056. * \param type The type (\c cn, \c o, \c ou, etc.) of the RDN to be added.
  3057. * This parameter cannot be \c NULL.
  3058. * \param value The value of the RDN to be added. This parameter cannot
  3059. * be \c NULL.
  3060. * \return Always returns 1.
  3061. * \see slapi_rdn_get_num_components()
  3062. */
  3063. int slapi_rdn_add(Slapi_RDN *rdn, const char *type, const char *value);
  3064. /**
  3065. * Removes a RDN from a \c Slapi_RDN structure at a given position.
  3066. *
  3067. * \param rdn The target \c Slapi_RDN structure.
  3068. * \param atindex The index of the RDN type/value pair to remove.
  3069. * \return \c 1 if the RDN is removed from \c rdn.
  3070. * \return \c 0 if no RDN is removed because either \c rdn is empty
  3071. * or \c atindex goes beyond the number of RDNs present.
  3072. * \see slapi_rdn_remove()
  3073. * \see slapi_rdn_remove_attr()
  3074. */
  3075. int slapi_rdn_remove_index(Slapi_RDN *rdn, int atindex);
  3076. /**
  3077. * Removes a RDN from a \c Slapi_RDN structure matching a given type/value pair.
  3078. *
  3079. * \param rdn The target \c Slapi_RDN structure.
  3080. * \param type The type (\c cn, \c o, \c ou, etc.) of the RDN to be removed.
  3081. * \param value The value of the RDN to be removed.
  3082. * \param length Gives the length of the value that should be taken into
  3083. * account for the string comparisons when searching for the RDN.
  3084. * \return \c 1 if the RDN is removed from \c rdn.
  3085. * \return \c 0 if no RDN is removed.
  3086. * \see slapi_rdn_remove_attr()
  3087. * \see slapi_rdn_remove_index()
  3088. */
  3089. int slapi_rdn_remove(Slapi_RDN *rdn, const char *type, const char *value, size_t length);
  3090. /**
  3091. * Removes a RDN from a \c Slapi_RDN structure matching a given type.
  3092. *
  3093. * \param rdn The target \c Slapi_RDN structure.
  3094. * \param type The type (\c cn, \c o, \c ou, etc.) of the RDN to be removed.
  3095. * \return \c 1 if the RDN is removed from \c rdn.
  3096. * \return \c 0 if no RDN is removed.
  3097. * \see slapi_rdn_remove()
  3098. * \see slapi_rdn_remove_index()
  3099. */
  3100. int slapi_rdn_remove_attr(Slapi_RDN *rdn, const char *type);
  3101. /**
  3102. * Checks whether a RDN value is stored in a \c Slapi_RDN structure.
  3103. *
  3104. * \param rdn The target \c Slapi_RDN structure.
  3105. * \return \c 1 if there is no RDN value present.
  3106. * \return \c 0 if rdn contains a value.
  3107. * \see slapi_rdn_init()
  3108. * \see slapi_rdn_done()
  3109. * \see slapi_rdn_free()
  3110. */
  3111. int slapi_rdn_isempty(const Slapi_RDN *rdn);
  3112. /**
  3113. * Gets the number of RDN type/value pairs present in a \c Slapi_RDN structure.
  3114. *
  3115. * \param rdn The target \c Slapi_RDN structure.
  3116. * \return The number of RDN type/value pairs present in \c rdn.
  3117. * \see slapi_rdn_add()
  3118. */
  3119. int slapi_rdn_get_num_components(Slapi_RDN *rdn);
  3120. /**
  3121. * Compares two \c Slapi_RDN structures.
  3122. *
  3123. * For RDNs to be considered equal, the order of their components
  3124. * do not have to be the same.
  3125. *
  3126. * \param rdn1 The first RDN to compare.
  3127. * \param rdn2 The second RDN to compare.
  3128. * \return \c 0 if \c rdn1 and \c rdn2 have the same RDN components.
  3129. * \return \c -1 if they do not have the same components.
  3130. */
  3131. int slapi_rdn_compare(Slapi_RDN *rdn1, Slapi_RDN *rdn2);
  3132. /**
  3133. * Gets the RDN from a \c Slapi_RDN structure.
  3134. *
  3135. * \param rdn The \c Slapi_RDN structure holding the RDN value.
  3136. * \return The RDN value.
  3137. * \warning Do not free the returned RDN value.
  3138. */
  3139. const char *slapi_rdn_get_rdn(const Slapi_RDN *rdn);
  3140. /**
  3141. * Adds a RDN from a \c Slapi_RDN structure to a DN in a \c Slapi_DN structure.
  3142. *
  3143. * The RDN in the \c Slapi_RDN structure will be appended to the DN
  3144. * value in \c sdn.
  3145. *
  3146. * \param sdn \c Slapi_DN structure containing the value to which
  3147. * a new RDN is to be added.
  3148. * \param rdn \c Slapi_RDN structure containing the RDN value
  3149. * that is to be added to the DN value.
  3150. * \return The \c Slapi_DN structure with the new DN.
  3151. * \see slapi_sdn_set_rdn()
  3152. */
  3153. Slapi_DN *slapi_sdn_add_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
  3154. /* Function: slapi_rdn_set_all_dn
  3155. Description: this function sets exploded RDNs of DN to Slapi_RDN
  3156. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3157. dn - distinguished name which is to be exploded into RDNs and
  3158. set to Slapi_RDN
  3159. Return: none
  3160. */
  3161. void slapi_rdn_set_all_dn(Slapi_RDN *rdn,const char *dn);
  3162. /**
  3163. * Gets the normalized RDN from a \c Slapi_RDN structure
  3164. *
  3165. * \param rdn The \c Slapi_RDN structure holding the RDN value.
  3166. * \return The normalized RDN value.
  3167. */
  3168. const char *slapi_rdn_get_nrdn(Slapi_RDN *srdn);
  3169. /* Function: slapi_rdn_get_first_ext
  3170. Description: this function returns the first RDN in RDN array. The RDN
  3171. array is supposed to store all the RDNs of DN.
  3172. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3173. firstrdn - a container to store the address of the first RDN.
  3174. The caller should not free the returned address.
  3175. flag - type of the returned RDN. one of the followings:
  3176. FLAG_ALL_RDNS -- raw (not normalized)
  3177. FLAG_ALL_NRDNS -- normalized
  3178. Return: the index of the first rdn 0, if function succeeds.
  3179. -1, if it fails.
  3180. */
  3181. int slapi_rdn_get_first_ext(Slapi_RDN *srdn, const char **firstrdn, int flag);
  3182. /* Function: slapi_rdn_get_last_ext
  3183. Description: this function returns the last RDN in RDN array. The RDN
  3184. array is supposed to store all the RDNs of DN.
  3185. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3186. lastrdn - a container to store the address of the last RDN.
  3187. The caller should not free the returned address.
  3188. flag - type of the returned RDN. one of the followings:
  3189. FLAG_ALL_RDNS -- raw (not normalized)
  3190. FLAG_ALL_NRDNS -- normalized
  3191. Return: the index of the last rdn, if function succeeds.
  3192. -1, if it fails.
  3193. */
  3194. int slapi_rdn_get_last_ext(Slapi_RDN *srdn, const char **lastrdn, int flag);
  3195. /* Function: slapi_rdn_get_prev_ext
  3196. Description: this function returns the previous RDN of the given index (idx)
  3197. in RDN array.
  3198. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3199. idx - a return value of the previous slapi_rdn_get_last_ext
  3200. or slapi_rdn_get_prev_ext or slapi_rdn_get_next_ext call.
  3201. prevrdn - a container to store the address of the previous RDN.
  3202. The caller should not free the returned address.
  3203. flag - type of the returned RDN. one of the followings:
  3204. FLAG_ALL_RDNS -- raw (not normalized)
  3205. FLAG_ALL_NRDNS -- normalized
  3206. Return: the index of the returned rdn, if function succeeds.
  3207. -1, if it fails.
  3208. */
  3209. int slapi_rdn_get_prev_ext(Slapi_RDN *srdn, int idx, const char **prevrdn, int flag);
  3210. /* Function: slapi_rdn_get_next_ext
  3211. Description: this function returns the next RDN of the given index (idx)
  3212. in RDN array.
  3213. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3214. idx - a return value of the previous slapi_rdn_get_prev_ext
  3215. or slapi_rdn_get_next_ext call.
  3216. nextrdn - a container to store the address of the next RDN.
  3217. The caller should not free the returned address.
  3218. flag - type of the returned RDN. one of the followings:
  3219. FLAG_ALL_RDNS -- raw (not normalized)
  3220. FLAG_ALL_NRDNS -- normalized
  3221. Return: the index of the returned rdn, if function succeeds.
  3222. -1, if it fails.
  3223. */
  3224. int slapi_rdn_get_next_ext(Slapi_RDN *srdn, int idx, const char **nextrdn, int flag);
  3225. /* Function: slapi_rdn_add_rdn_to_all_rdns
  3226. Description: this function appends the given RDN to the RDN array in
  3227. Slapi_RDN.
  3228. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3229. addrdn - an RDN string to append.
  3230. byref - non 0, then the passed addrdn is put in the RDN array.
  3231. 0, then the duplicated addrdn is put in the RDN array.
  3232. Return: 0, if the function succeeds.
  3233. -1, if it fails.
  3234. */
  3235. int slapi_rdn_add_rdn_to_all_rdns(Slapi_RDN *srdn, char *addrdn, int byref);
  3236. /* Function: slapi_rdn_add_srdn_to_all_rdns
  3237. Description: this function appends the given Slapi_RDN to the RDN array in
  3238. Slapi_RDN.
  3239. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3240. addsrdn - Slapi_RDN to append.
  3241. Return: 0, if the function succeeds.
  3242. -1, if it fails.
  3243. */
  3244. int slapi_rdn_add_srdn_to_all_rdns(Slapi_RDN *srdn, Slapi_RDN *addsrdn);
  3245. /* Function: slapi_rdn_get_dn
  3246. Description: this function generates DN string if it stores RDNs in its
  3247. all_rdns field.
  3248. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3249. dn -- a container to store the address of DN; dn is allocated
  3250. in this function.
  3251. Return: 0, if the function succeeds.
  3252. -1, if it fails (e.g., srdn is NULL, dn is NULL, or srdn does not
  3253. have RDN array in it.
  3254. */
  3255. int slapi_rdn_get_dn(Slapi_RDN *srdn, char **dn);
  3256. /* Function: slapi_srdn_copy
  3257. Description: this function copies "from" Slapi_RDN structure to "to"
  3258. Parameters: from - a pointer to source Slapi_RDN
  3259. to -- an address to store the copied Slapi_RDN.
  3260. Return: 0, if the function succeeds.
  3261. -1, if it fails
  3262. */
  3263. int slapi_srdn_copy(const Slapi_RDN *from, Slapi_RDN *to);
  3264. /* Function: slapi_srdn_copy
  3265. Description: this function replaces the rdn in Slapi_RDN with new_rdn
  3266. Parameters: srdn - a pointer to Slapi_RDN
  3267. new_rdn -- new rdn set to Slapi_RDN
  3268. Return: 0, if the function succeeds.
  3269. -1, if it fails
  3270. */
  3271. int slapi_rdn_replace_rdn(Slapi_RDN *srdn, char *new_rdn);
  3272. /* Function: slapi_rdn_partial_dup
  3273. Description: this function partially duplicates "from" Slapi_RDN structure and set it to "to"
  3274. Parameters: from - a pointer to source Slapi_RDN
  3275. to -- an address to store the partially copied Slapi_RDN.
  3276. idx -- index from which the duplicate begins
  3277. Return: 0, if the function succeeds.
  3278. -1, if it fails
  3279. */
  3280. int slapi_rdn_partial_dup(Slapi_RDN *from, Slapi_RDN **to, int idx);
  3281. /**
  3282. * Return the size of the RDN
  3283. *
  3284. * \param srdn A pointer to Slapi_RDN to calculate the size
  3285. * \return The size of the given RDN.
  3286. */
  3287. size_t slapi_rdn_get_size(Slapi_RDN *srdn);
  3288. /**
  3289. * Return a copy of the value of the RDN
  3290. *
  3291. * \param rdn A pointer to rdn to get the value.
  3292. * \return The value of the given RDN.
  3293. */
  3294. char * slapi_rdn_get_value(const char *rdn);
  3295. /**
  3296. * Return a pointer to the value of the RDN
  3297. *
  3298. * \param rdn A pointer to rdn to get the value.
  3299. * \return The value of the given RDN.
  3300. */
  3301. char * slapi_rdn_get_value_by_ref(const char *rdn);
  3302. /*
  3303. * utility routines for dealing with DNs
  3304. */
  3305. /**
  3306. * Does nothing. (DEPRECATED)
  3307. *
  3308. * \param dn The DN to normalize.
  3309. * \return The normalized DN.
  3310. * \deprecated Use slapi_dn_normalized_ext.
  3311. */
  3312. char *slapi_dn_normalize( char *dn );
  3313. /**
  3314. * Does nothing. (DEPRECATED)
  3315. *
  3316. * \param dn The DN value to normalize.
  3317. * \param end Pointer to the end of what will be normalized from the DN
  3318. * value in \c dn. If this parameter is \c NULL, the DN value
  3319. * will be wholly normalized.
  3320. * \return The normalized DN.
  3321. * \deprecated Use slapi_dn_normalized_ext.
  3322. */
  3323. char *slapi_dn_normalize_to_end( char *dn, char *end );
  3324. /**
  3325. * Normalizes a DN.
  3326. *
  3327. * \param src The DN to normalize.
  3328. * \param src_len The length of src DN to normalize. If 0 is given, strlen(src) is used.
  3329. * \param dest The normalized DN.
  3330. * \param dest The length of the normalized DN dest.
  3331. * \return \c 0 if successful. The dest DN is normalized in line. Caller must not free dest.
  3332. * \return \c 1 if successful. The dest DN is allocated. Caller must free dest.
  3333. * \return \c -1 if an error occurs (for example, if the src DN cannot be normalized)
  3334. */
  3335. int slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len);
  3336. /**
  3337. * Normalizes a DN (in lower-case characters).
  3338. *
  3339. * \param src The DN to normalize.
  3340. * \param src_len The length of src DN to normalize. If 0 is given, strlen(src) is used internally.
  3341. * \param dest The normalized DN with the cases lowered.
  3342. * \param dest_len The length of the normalized DN dest.
  3343. * \return \c 0 if successful. The dest DN is normalized in line. Caller must not free dest. The string is NOT NULL terminated.
  3344. * \return \c 1 if successful. The dest DN is allocated. Caller must free dest.
  3345. * \return \c -1 if an error occurs (for example, if src DN cannot be normalized)
  3346. */
  3347. int slapi_dn_normalize_case_ext(char *src, size_t src_len, char **dest, size_t *dest_len);
  3348. /**
  3349. * Generate a valid DN string.
  3350. *
  3351. * \param fmt The format used to generate a DN string.
  3352. * \param ... The arguments to generate a DN string.
  3353. * \return A pointer to the generated DN.
  3354. * \return NULL if failed.
  3355. * \note When a DN needs to be internally created, this function is supposed to be called. This function allocates the enough memory for the normalized DN and returns it filled with the normalized DN.
  3356. */
  3357. char *slapi_create_dn_string(const char *fmt, ...);
  3358. /**
  3359. * Generates a valid DN string (in lower-case characters).
  3360. *
  3361. * \param fmt The format used to generate a DN string.
  3362. * \param ... The arguments to generate a DN string.
  3363. * \return A pointer to the generated DN.
  3364. * \return NULL if failed.
  3365. */
  3366. char *slapi_create_dn_string_case(const char *fmt, ...);
  3367. /**
  3368. * Generates a valid value of RDN string
  3369. *
  3370. * \param fmt The format used to generate a value of RDN string.
  3371. * \param ... The arguments to generate an RDN string.
  3372. * \return A pointer to the generated RDN value.
  3373. * \return NULL if failed.
  3374. */
  3375. char *slapi_create_rdn_value(const char *fmt, ...);
  3376. /**
  3377. * Converts a DN to lowercase.
  3378. *
  3379. * \param dn The DN to convert.
  3380. * \return A pointer to the converted DN.
  3381. * \deprecated Use slapi_sdn_get_ndn() instead to normalize the case,
  3382. * or use slapi_sdn_compare() to compare regardless of case.
  3383. */
  3384. char *slapi_dn_ignore_case( char *dn );
  3385. /**
  3386. * Converts a DN to canonical format and converts all characters to lowercase.
  3387. *
  3388. * \param dn DN that you want to normalize and convert to lowercase.
  3389. * \return The normalized and converted DN.
  3390. * \note The \c dn parameter is converted in place.
  3391. */
  3392. char *slapi_dn_normalize_case( char *dn );
  3393. /**
  3394. * Get a copy of the parent DN of a DN.
  3395. *
  3396. * \param pb A parameter block with the backend set.
  3397. * \param dn The DN whose parent is desired.
  3398. * \return A pointer to the parent DN of \c dn.
  3399. * \return \c NULL if the DN is a suffix of the backend.
  3400. * \warning The caller must free the returned DN when finished with it.
  3401. * \deprecated Use slapi_sdn_get_backend_parent() instead.
  3402. */
  3403. char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn );
  3404. /**
  3405. * Finds the parent DN of a DN within the same string.
  3406. *
  3407. * \param dn The DN whose parent DN is desired.
  3408. * \return A pointer to the parent DN within \c dn.
  3409. */
  3410. const char *slapi_dn_find_parent( const char *dn );
  3411. /**
  3412. * Finds the parent DN of a DN within the same string.
  3413. *
  3414. * \param dn The DN whose parent DN is desired.
  3415. * \param is_tombstone If non-zero, the special leaf rdn "nsuniqueid=.." is ignored.
  3416. * \return A pointer to the parent DN within \c dn.
  3417. */
  3418. const char *slapi_dn_find_parent_ext( const char *dn, int is_tombstone );
  3419. /**
  3420. * Gets the parent DN of a given DN.
  3421. *
  3422. * \param dn The DN whose parent is desired.
  3423. * \return A pointer to the parent DN of \c dn.
  3424. * \warning The caller must free the returned DN when finished with it.
  3425. * \deprecated Use slapi_sdn_get_parent() instead.
  3426. */
  3427. char *slapi_dn_parent( const char *dn );
  3428. /**
  3429. * Gets the parent DN of a given DN.
  3430. *
  3431. * \param dn The DN whose parent is desired.
  3432. * \param is_tombstone If non-zero, the special leaf rdn "nsuniqueid=.." is ignored.
  3433. * \return A pointer to the parent DN of \c dn.
  3434. * \warning The caller must free the returned DN when finished with it.
  3435. * \deprecated Use slapi_sdn_get_parent() instead.
  3436. */
  3437. char *slapi_dn_parent_ext( const char *dn, int is_tombstone );
  3438. /**
  3439. * Checks if a DN belongs to a suffix.
  3440. *
  3441. * \param dn The DN to check.
  3442. * \param suffix The suffix to check.
  3443. * \return \c 1 if \c dn belongs to \c suffix
  3444. * \return \c 0 if \c dn does not belong to \c suffix.
  3445. * \warning Both \c dn and \c suffix must be normalized before calling this function.
  3446. * \deprecated Use slapi_sdn_issuffix() instead.
  3447. */
  3448. int slapi_dn_issuffix( const char *dn, const char *suffix );
  3449. /**
  3450. * Checks if a DN is the parent of another DN.
  3451. *
  3452. * \param parentdn The DN of the supposed parent.
  3453. * \param childdn The DN of the supposed child.
  3454. * \return non-zero if \c parentdn is the parent of \c childdn.
  3455. * \return \c 0 if \c parentdn is not the paret of \c childdn.
  3456. * \deprecated Use slapi_sdn_isparent() instead.
  3457. */
  3458. int slapi_dn_isparent( const char *parentdn, const char *childdn );
  3459. /**
  3460. * Determines is a DN is the root DN.
  3461. *
  3462. * \param dn The DN to check
  3463. * \return \c 1 if the DN is the root DN.
  3464. * \return \c 0 if the DN is not the root DN.
  3465. * \warning You must normalize \c dn before calling this function.
  3466. */
  3467. int slapi_dn_isroot( const char *dn );
  3468. /**
  3469. * Checks if a DN is the backend suffix.
  3470. *
  3471. * \param pb A parameter block with the backend set.
  3472. * \param dn The DN to check.
  3473. * \return \c 1 if \c dn is the backend suffix.
  3474. * \return \c 0 if \c dn is not the backend suffix.
  3475. * \deprecated slapi_be_issuffix()
  3476. */
  3477. int slapi_dn_isbesuffix( Slapi_PBlock *pb, const char *dn );
  3478. /**
  3479. * Checks if writes to a particular DN need to send a referral.
  3480. *
  3481. * \param target_sdn The target DN that you want to check.
  3482. * \param referral The address of a pointer to receive a referral
  3483. * if one is needed.
  3484. * \return \c 1 if a referral needs to be sent.
  3485. * \return \c 0 if no referral is needed.
  3486. * \warning The referral entry must be freed when it is no longer
  3487. * being used.
  3488. */
  3489. int slapi_dn_write_needs_referral(Slapi_DN *target_sdn, Slapi_Entry **referral);
  3490. /**
  3491. * Converts the second RDN type value to the berval value.
  3492. *
  3493. * Returns the new RDN value as a berval value in \c bv. This function
  3494. * can be used for creating the RDN as an attribute value since it returns
  3495. * the value of the RDN in the berval structure.
  3496. *
  3497. * \param rdn Second RDN value.
  3498. * \param type Address of a pointer to receive the attribute type
  3499. * of the second RDN.
  3500. * \param bv A pointer to the berval structure to receive the value.
  3501. */
  3502. int slapi_rdn2typeval( char *rdn, char **type, struct berval *bv );
  3503. /**
  3504. * Adds a RDN to a DN.
  3505. *
  3506. * \param dn The DN to add the RDN to.
  3507. * \param rdn the new RDN to add to the DN.
  3508. * \return A pointer to the new DN.
  3509. * \warning The caller must free the returnd DN when finished with it.
  3510. * \deprecated Use slapi_sdn_add_rdn() instead.
  3511. */
  3512. char *slapi_dn_plus_rdn(const char *dn, const char *rdn);
  3513. /**
  3514. * Create an Slapi_DN that is a common ancestor of given 2 Slapi_DN's
  3515. *
  3516. * \param dn1 The first DN
  3517. * \param dn2 the second DN
  3518. * \return A pointer to the new Slapi_DN that is a common ancestor of dn1 and dn2
  3519. * \warning The caller must free the returnd Slapi_DN
  3520. */
  3521. Slapi_DN *slapi_sdn_common_ancestor(Slapi_DN *dn1, Slapi_DN *dn2);
  3522. /*
  3523. * thread safe random functions
  3524. */
  3525. /**
  3526. * Generate a pseudo-random integer with optional seed.
  3527. *
  3528. * \param seed A seed to use when generating the pseudo random number.
  3529. * \return A pseudo random number.
  3530. * \see slapi_rand()
  3531. * \see slapi_rand_array()
  3532. */
  3533. int slapi_rand_r(unsigned int * seed);
  3534. /* Generate a pseudo-random integer in an array.
  3535. *
  3536. * \param randx The array you want filled with the random number.
  3537. * \param len The length of the array you want filled with the random number.
  3538. * \see slapi_rand()
  3539. * \see slapi_rand_r()
  3540. */
  3541. void slapi_rand_array(void *randx, size_t len);
  3542. /**
  3543. * Generate a pseudo-random integer.
  3544. *
  3545. * \return A pseudo random number.
  3546. * \see slapi_rand_r()
  3547. * \see slapi_rand_array()
  3548. */
  3549. int slapi_rand(void);
  3550. /**
  3551. * Escape special characters in a search filter value
  3552. *
  3553. * \param filter_str A ldap search filter value (cn=VALUE_TO_BE_ESCAPED)
  3554. * \param len length of the search filter value. -1 indicates the string is null terminated
  3555. * \param buf the buffer to store the escaped filter value string
  3556. * \return the escaped filter value string
  3557. */
  3558. char* slapi_escape_filter_value(char* filter_str, int len);
  3559. #define ESC_NEXT_VAL "__ESC__NEXT__VAL__"
  3560. #define NORM_NEXT_VAL "__NORM__NEXT__VAL__"
  3561. #define ESC_AND_NORM_NEXT_VAL "__ESC__AND__NORM__NEXT__VAL__"
  3562. char* slapi_filter_sprintf(const char *fmt, ...);
  3563. /*
  3564. * attribute routines
  3565. */
  3566. /**
  3567. * Create a new empty attribute.
  3568. *
  3569. * \return A pointer to the newly created attribute.
  3570. * \warning You must free the returned attribute using slapi_attr_free().
  3571. * \see slapi_attr_init()
  3572. * \see slapi_attr_dup()
  3573. * \see slapi_attr_free()
  3574. */
  3575. Slapi_Attr *slapi_attr_new( void );
  3576. /**
  3577. * Initializes an attribute with an attribute type.
  3578. *
  3579. * \param a The attribute to initialize.
  3580. * \param type The attribute type to set.
  3581. * \return A pointer to the initialized attribute.
  3582. */
  3583. Slapi_Attr *slapi_attr_init(Slapi_Attr *a, const char *type);
  3584. /**
  3585. * Frees an attribute from memory.
  3586. *
  3587. * \param a Address of a pointer to the attribute to be freed.
  3588. * \see slapi_attr_init()
  3589. * \see slapi_attr_dup()
  3590. * \see slapi_attr_new()
  3591. */
  3592. void slapi_attr_free( Slapi_Attr **a );
  3593. /**
  3594. * Make a copy of an attribute.
  3595. *
  3596. * \param attr The attribute to be duplicated.
  3597. * \return The newly created copy of the attribute.
  3598. * \warning You must free the returned attribute using slapi_attr_free().
  3599. * \see slapi_attr_new()
  3600. * \see slapi_attr_init()
  3601. * \see slapi_attr_free()
  3602. */
  3603. Slapi_Attr *slapi_attr_dup(const Slapi_Attr *attr);
  3604. /**
  3605. * Adds a value to an attribute.
  3606. *
  3607. * \param a The attribute that will contain the values.
  3608. * \param v Value to be added to the attribute.
  3609. * \return Always returns 0.
  3610. * \see slapi_attr_first_value()
  3611. * \see slapi_attr_next_value()
  3612. * \see slapi_attr_get_numvalues()
  3613. * \see slapi_attr_value_cmp()
  3614. * \see slapi_attr_value_find()
  3615. */
  3616. int slapi_attr_add_value(Slapi_Attr *a, const Slapi_Value *v);
  3617. /**
  3618. * Find syntax plugin associated with an attribute type.
  3619. *
  3620. * \param type Type of attribute for which you want to get the plugin.
  3621. * \param pi Address to receive a pointer to the plugin structure.
  3622. * \return \c 0 if successful.
  3623. * \return \c -1 if the plugin is not found.
  3624. * \deprecated This function was necessary in order to call syntax plugin
  3625. * filter and indexing functions - there are new functions
  3626. * to use instead, such as slapi_attr_values2keys, etc.
  3627. * This function is still used by internal APIs, but new
  3628. * code should not use this function
  3629. * \see slapi_attr_get_type()
  3630. * \see slapi_attr_type_cmp()
  3631. * \see slapi_attr_types_equivalent()
  3632. * \see slapi_attr_basetype()
  3633. */
  3634. int slapi_attr_type2plugin( const char *type, void **pi );
  3635. /**
  3636. * Get the name of the attribute type from a specified attribute.
  3637. *
  3638. * \param attr Attribute for which you want to get the type.
  3639. * \param type Address to receive a pointer to the attribute type.
  3640. * \return Always returns \c 0.
  3641. * \warning Do not free the returned attribute type. The type is a part
  3642. * if the actual attribute data, not a copy.
  3643. * \see slapi_attr_type2plugin()
  3644. * \see slapi_attr_type_cmp()
  3645. * \see slapi_attr_types_equivalent()
  3646. * \see slapi_attr_basetype()
  3647. */
  3648. int slapi_attr_get_type( Slapi_Attr *attr, char **type );
  3649. /**
  3650. * Get the attribute type OID of a particular attribute.
  3651. *
  3652. * \param attr Attribute that contains the desired OID.
  3653. * \param oidp Address to receive a pointer to a copy of the
  3654. * attribute type OID.
  3655. * \return \c 0 if the attribute type is found.
  3656. * \return \c -1 if the attribute type is not found.
  3657. * \warning The returned OID should be freed by calling the
  3658. * slapi_ch_free_string() function.
  3659. * \see slapi_attr_get_syntax_oid_copy()
  3660. */
  3661. int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp );
  3662. /*
  3663. * Get the syntax OID of a particular attribute.
  3664. *
  3665. * \param a Attribute that contains the desired OID.
  3666. * \param oidp Address to receive a pointer to a copy of the
  3667. * syntax OID.
  3668. * \return \c 0 if the syntax OID is found.
  3669. * \return \c -1 if the syntax OID is not found.
  3670. * \warning The returned OID should be freed by calling the
  3671. * slapi_ch_free_string() function.
  3672. * \see slapi_attr_get_oid_copy()
  3673. */
  3674. int slapi_attr_get_syntax_oid_copy( const Slapi_Attr *a, char **oidp );
  3675. /**
  3676. * Checks if the attribute uses a DN syntax or not.
  3677. *
  3678. * \param attr The attribute to be checked.
  3679. * \return \c non 0 if the attribute uses a DN syntax.
  3680. * \return \c 0 if the attribute does not use a DN syntax.
  3681. */
  3682. int slapi_attr_is_dn_syntax_attr(Slapi_Attr *attr);
  3683. int slapi_attr_is_dn_syntax_type(char *type);
  3684. /**
  3685. * Get the flags associated with a particular attribute.
  3686. *
  3687. * Valid flags are:
  3688. * \arg #SLAPI_ATTR_FLAG_SINGLE
  3689. * \arg #SLAPI_ATTR_FLAG_OPATTR
  3690. * \arg #SLAPI_ATTR_FLAG_READONLY
  3691. * \arg #SLAPI_ATTR_FLAG_OBSOLETE
  3692. * \arg #SLAPI_ATTR_FLAG_COLLECTIVE
  3693. * \arg #SLAPI_ATTR_FLAG_NOUSERMOD
  3694. * \arg #SLAPI_ATTR_FLAG_NORMALIZED
  3695. * \arg #SLAPI_ATTR_FLAG_NOEXPOSE
  3696. *
  3697. * \param attr Attribute for which you want to get the flags.
  3698. * \param flags Address of an integer that you want to reveive the flags.
  3699. * \return \c Always returns 0.
  3700. * \see slapi_attr_flag_is_set()
  3701. */
  3702. int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags );
  3703. /**
  3704. * Checks if certain flags are set for a particular attribute.
  3705. *
  3706. * Valid flags are:
  3707. * \arg #SLAPI_ATTR_FLAG_SINGLE
  3708. * \arg #SLAPI_ATTR_FLAG_OPATTR
  3709. * \arg #SLAPI_ATTR_FLAG_READONLY
  3710. * \arg #SLAPI_ATTR_FLAG_OBSOLETE
  3711. * \arg #SLAPI_ATTR_FLAG_COLLECTIVE
  3712. * \arg #SLAPI_ATTR_FLAG_NOUSERMOD
  3713. * \arg #SLAPI_ATTR_FLAG_NORMALIZED
  3714. * \arg #SLAPI_ATTR_FLAG_NOEXPOSE
  3715. *
  3716. * \param attr Attribute that you want to check.
  3717. * \param flag Flags to check in the attribute.
  3718. * \return \c 1 if the specified flags are set.
  3719. * \return \c 0 if the specified flags are not set.
  3720. * \see slapi_attr_get_flags()
  3721. */
  3722. int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag );
  3723. /**
  3724. * Comare two bervals for a given attribute.
  3725. *
  3726. * \param attr Attribute used to determine how these values are compared; for
  3727. * example, the syntax of the attribute may perform case-insensitive
  3728. * comparisons.
  3729. * \param v1 Pointer to the \c berval structure containing the first value
  3730. * that you want to compare.
  3731. * \param v2 Pointer to the \c berval structure containing the second value
  3732. * that you want to compare.
  3733. * \return \c 0 if the values are equal.
  3734. * \return \c -1 if the values are not equal.
  3735. * \see slapi_attr_add_value()
  3736. * \see slapi_attr_first_value()
  3737. * \see slapi_attr_next_value()
  3738. * \see slapi_attr_get_numvalues()
  3739. * \see slapi_attr_value_find()
  3740. */
  3741. int slapi_attr_value_cmp( const Slapi_Attr *attr, const struct berval *v1, const struct berval *v2 );
  3742. /**
  3743. * Comare two values for a given attribute.
  3744. *
  3745. * \param attr Attribute used to determine how these values are compared; for
  3746. * example, the syntax of the attribute may perform case-insensitive
  3747. * comparisons.
  3748. * \param v1 Pointer to the \c Slapi_Value structure containing the first value
  3749. * that you want to compare.
  3750. * \param v2 Pointer to the \c Slapi_Value structure containing the second value
  3751. * that you want to compare.
  3752. * \return \c 0 if the values are equal.
  3753. * \return \c -1 if the values are not equal.
  3754. * \see slapi_attr_add_value()
  3755. * \see slapi_attr_first_value()
  3756. * \see slapi_attr_next_value()
  3757. * \see slapi_attr_get_numvalues()
  3758. * \see slapi_attr_value_find()
  3759. * \see slapi_attr_value_cmp()
  3760. */
  3761. int slapi_attr_value_cmp_ext(const Slapi_Attr *a, Slapi_Value *v1, Slapi_Value *v2);
  3762. /**
  3763. * Determine if an attribute contains a given value.
  3764. *
  3765. * \param a Attribute that you want to check.
  3766. * \param v Pointer to the \c berval structure containing the value for
  3767. * which you want to search.
  3768. * \return \c 0 if the attribute contains the specified value.
  3769. * \return \c -1 if the attribute does not contain the specified value.
  3770. * \see slapi_attr_add_value()
  3771. * \see slapi_attr_first_value()
  3772. * \see slapi_attr_next_value()
  3773. * \see slapi_attr_get_numvalues()
  3774. * \see slapi_attr_value_cmp()
  3775. */
  3776. int slapi_attr_value_find( const Slapi_Attr *a, const struct berval *v );
  3777. /**
  3778. * Compare two attribute types.
  3779. *
  3780. * \param t1 Name of the first attribute type to compare.
  3781. * \param t2 Name of the second attribute type to compare.
  3782. * \param opt One of the following options:
  3783. * \arg #SLAPI_TYPE_CMP_EXACT
  3784. * \arg #SLAPI_TYPE_CMP_BASE
  3785. * \arg #SLAPI_TYPE_CMP_SUBTYPE
  3786. * \arg #SLAPI_TYPE_CMP_SUBTYPES
  3787. * \return \c 0 if the type names are equal.
  3788. * \return A non-zero value if the type names are not equal.
  3789. * \see slapi_attr_type2plugin()
  3790. * \see slapi_attr_get_type()
  3791. * \see slapi_attr_types_equivalent()
  3792. * \see slapi_attr_basetype()
  3793. */
  3794. int slapi_attr_type_cmp( const char *t1, const char *t2, int opt );
  3795. /* Mode of operation (opt) values for slapi_attr_type_cmp() */
  3796. /**
  3797. * Compare the types as-is.
  3798. *
  3799. * \see slapi_attr_type_cmp()
  3800. */
  3801. #define SLAPI_TYPE_CMP_EXACT 0
  3802. /**
  3803. * Compare only the base names of the types.
  3804. *
  3805. * \see slapi_attr_type_cmp()
  3806. */
  3807. #define SLAPI_TYPE_CMP_BASE 1
  3808. /**
  3809. * Ignore any subtypes in the second type that are not in the first subtype.
  3810. *
  3811. * \see slapi_attr_type_cmp()
  3812. */
  3813. #define SLAPI_TYPE_CMP_SUBTYPE 2
  3814. /**
  3815. * Compare types including subtypes in the both args.
  3816. *
  3817. * \see slapi_attr_type_cmp()
  3818. */
  3819. #define SLAPI_TYPE_CMP_SUBTYPES 3
  3820. /**
  3821. * Compare two attribute names to determine if they represent the same value.
  3822. *
  3823. * \param t1 Pointer to the first attribute you want to compare.
  3824. * \param t2 Pointer to the second attribute you want to compare.
  3825. * \return \c 1 if \c t1 and \c t2 represent the same attribute.
  3826. * \return \c 0 if \c t1 and \c t2 do not represent the same attribute.
  3827. * \see slapi_attr_type_cmp()
  3828. * \see slapi_attr_get_type()
  3829. * \see slapi_attr_basetype()
  3830. */
  3831. int slapi_attr_types_equivalent(const char *t1, const char *t2);
  3832. /**
  3833. * Get the base type of an attribute.
  3834. *
  3835. * For example, if given \c cn;lang-jp, returns \c cn.
  3836. *
  3837. * \param type Attribute type from which you want to get the base type.
  3838. * \param buf Buffer to hold the returned base type.
  3839. * \param bufsiz Size of the buffer.
  3840. * \return \c NULL if the base type fits in the buffer.
  3841. * \return A pointer to a newly allocated base type if the buffer is
  3842. * too small to hold it.
  3843. * \warning If a base type is returned, if should be freed by calling
  3844. * slapi_ch_free_string().
  3845. * \see slapi_attr_get_type()
  3846. * \see slapi_attr_type_cmp()
  3847. * \see slapi_attr_types_equivalent()
  3848. */
  3849. char *slapi_attr_basetype( const char *type, char *buf, size_t bufsiz );
  3850. /**
  3851. * Get the first value of an attribute.
  3852. *
  3853. * This is part of a set of functions to enumerate over a
  3854. * \c Slapi_Attr structure.
  3855. *
  3856. * \param a Attribute containing the desired value.
  3857. * \param v Holds the first value of the attribute.
  3858. * \return \c 0, which is the index of the first value.
  3859. * \return \c -1 if \c NULL or if the value is not found.
  3860. * \warning Do not free the returned value. It is a part
  3861. * of the attribute structure and not a copy.
  3862. * \see slapi_attr_next_value()
  3863. * \see slapi_attr_get_num_values()
  3864. */
  3865. int slapi_attr_first_value( Slapi_Attr *a, Slapi_Value **v );
  3866. /**
  3867. * Get the next value of an attribute.
  3868. *
  3869. * The value of an attribute associated with an index is placed into
  3870. * a value. This is pare of a set of functions to enumerate over a
  3871. * \c Slapi_Attr structure.
  3872. *
  3873. * \param a Attribute containing the desired value.
  3874. * \param hint Index of the value to be returned.
  3875. * \param v Holds the value of the attribute.
  3876. * \return \c hint plus \c 1 if the value is found.
  3877. * \return \c -1 if \c NULL or if a value at \c hint is not found.
  3878. * \warning Do not free the returned value. It is a part
  3879. * of the attribute structure and not a copy.
  3880. * \see slapi_attr_first_value()
  3881. * \see slapi_attr_get_num_values()
  3882. */
  3883. int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v );
  3884. /**
  3885. * Get the number of values present in an attribute.
  3886. *
  3887. * Counts the number of values in an attribute and places that
  3888. * count in an integer.
  3889. *
  3890. * \param a Attribute containing the values to be counted.
  3891. * \param numValues Integer to hold the counted values.
  3892. * \see slapi_attr_first_value()
  3893. * \see slapi_attr_next_value()
  3894. */
  3895. int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues);
  3896. /**
  3897. * Copy existing values contained in an attribute into a valueset.
  3898. *
  3899. * \param a Attribute containing the values to be placed into
  3900. * a valueset.
  3901. * \param vs Receives the values from the attribute.
  3902. * \return Always returns \c 0.
  3903. * \warning Free the returned valueset with slapi_valueset_free()
  3904. * when finished using it.
  3905. * \see slapi_entry_add_valueset()
  3906. * \see slapi_valueset_new()
  3907. * \see slapi_valueset_free()
  3908. * \see slapi_valueset_init()
  3909. * \see slapi_valueset_done()
  3910. * \see slapi_valueset_add_value()
  3911. * \see slapi_valueset_first_value()
  3912. * \see slapi_valueset_next_value()
  3913. * \see slapi_valueset_count()
  3914. */
  3915. int slapi_attr_get_valueset(const Slapi_Attr *a, Slapi_ValueSet **vs);
  3916. /**
  3917. * Sets the valueset in an attribute.
  3918. *
  3919. * Intializes a valueset in a \c Slapi_Attr structure from a specified
  3920. * \c Slapi_ValueSet structure. The valueset in the \c Slapi_Attr
  3921. * will be \c vs, not a copy.
  3922. *
  3923. * \param a The attribute to set the valueset in.
  3924. * \param vs The valueset that you want to set in the attribute.
  3925. * \return Always returns \c 0.
  3926. * \warning Do not free \c vs. Ownership of \c vs is tranferred to
  3927. * the attribute.
  3928. * \see slapi_valueset_set_valueset()
  3929. */
  3930. int slapi_attr_set_valueset(Slapi_Attr *a, const Slapi_ValueSet *vs);
  3931. /**
  3932. * Set the attribute type of an attribute.
  3933. *
  3934. * \param a The attribute whose type you want to set.
  3935. * \param type The attribute type you want to set.
  3936. * \return \c 0 if the type was set.
  3937. * \return \c -1 if the type was not set.
  3938. * \warning The passed in type is copied, so ownership of \c type
  3939. * remains with the caller.
  3940. * \see slapi_attr_get_type()
  3941. */
  3942. int slapi_attr_set_type(Slapi_Attr *a, const char *type);
  3943. /**
  3944. * Copy the values from an attribute into a berval array.
  3945. *
  3946. * \param a Attribute that contains the desired values.
  3947. * \param vals Pointer to an array of berval structure pointers to
  3948. * hold the desired values.
  3949. * \return \c 0 if values are found.
  3950. * \return \c -1 if \c NULL.
  3951. * \warning You should free the array using ber_bvecfree() from the
  3952. * Mozilla LDAP C SDK.
  3953. */
  3954. int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals );
  3955. /**
  3956. * Normalize an attribute type.
  3957. *
  3958. * The attribute type will be looked up in the defined syntaxes to
  3959. * get the normalized form. If it is not found, the passed in type
  3960. * will be normalized.
  3961. *
  3962. * \param s The attribute type that you want to normalize.
  3963. * \return A normalized copy of the passed in attribute type.
  3964. * \warning You should free the returned string using slapi_ch_free_string().
  3965. * \see slapi_ch_free_string()
  3966. */
  3967. char * slapi_attr_syntax_normalize( const char *s );
  3968. /**
  3969. * Normalize an attribute type.
  3970. *
  3971. * The attribute type will be looked up in the defined syntaxes to
  3972. * get the normalized form. If it is not found, the passed in type
  3973. * will be normalized. If ATTR_SYNTAX_NORM_ORIG_ATTR is set to flags,
  3974. * the upper and lower cases are kept but trailing spaces are chopped
  3975. * from the original attribute type.
  3976. *
  3977. * \param s The attribute type that you want to normalize.
  3978. * \param flags 0 or ATTR_SYNTAX_NORM_ORIG_ATTR
  3979. * \return A normalized copy of the passed in attribute type.
  3980. * \warning You should free the returned string using slapi_ch_free_string().
  3981. * \see slapi_ch_free_string()
  3982. */
  3983. char * slapi_attr_syntax_normalize_ext( char *s, int flags );
  3984. /*
  3985. * value routines
  3986. */
  3987. /**
  3988. * Create a new empty \c Slapi_Value structure.
  3989. *
  3990. * \return A pointer to the newly allocated \c Slapi_Value structure.
  3991. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  3992. * \warning When you are no longer using the value, free it from memory
  3993. * by calling slapi_value_free()
  3994. * \see slapi_value_free()
  3995. * \see slapi_value_dup()
  3996. * \see slapi_value_new_berval()
  3997. * \see slapi_value_new_string()
  3998. * \see slapi_value_new_string_passin()
  3999. */
  4000. Slapi_Value *slapi_value_new( void );
  4001. /**
  4002. * Create a new \c Slapi_value structure and initialize it's value.
  4003. *
  4004. * \param bval Pointer to the \c berval structure used to initialize
  4005. * the newly allocated \c Slapi_value.
  4006. * \return A pointer to the newly allocated and initialized value.
  4007. * \warning The passed in \c berval structure will be copied. Ownership
  4008. * of \c bval remains with the caller.
  4009. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  4010. * \warning When you are no longer using the value, free it from memory
  4011. * by calling slapi_value_free()
  4012. * \see slapi_value_free()
  4013. * \see slapi_value_new()
  4014. * \see slapi_value_new_string()
  4015. * \see slapi_value_new_string_passin()
  4016. * \see slapi_value_dup()
  4017. */
  4018. Slapi_Value *slapi_value_new_berval(const struct berval *bval);
  4019. /**
  4020. * Duplicate a \c Slapi_Value structure.
  4021. *
  4022. * \param v The value to duplicate.
  4023. * \return A pointer to the copy of the value.
  4024. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  4025. * \warning When you are no longer using the value, free it from memory
  4026. * by calling slapi_value_free()
  4027. * \warning This function is identical to slapi_value_dup().
  4028. * \see slapi_value_dup()
  4029. * \see slapi_value_free()
  4030. */
  4031. Slapi_Value *slapi_value_new_value(const Slapi_Value *v);
  4032. /**
  4033. * Create a new \c Slapi_value structure and initialize it's value.
  4034. *
  4035. * \param s A \c NULL terminated string used to initialize
  4036. * the newly allocated \c Slapi_value.
  4037. * \return A pointer to the newly allocated and initialized value.
  4038. * \warning The passed in string will be copied. Ownership of \c s
  4039. * remains with the caller.
  4040. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  4041. * \warning When you are no longer using the value, free it from memory
  4042. * by calling slapi_value_free()
  4043. * \see slapi_value_free()
  4044. * \see slapi_value_new()
  4045. * \see slapi_value_new_berval()
  4046. \see slapi_value_new_string_passin()
  4047. * \see slapi_value_dup()
  4048. */
  4049. Slapi_Value *slapi_value_new_string(const char *s);
  4050. /**
  4051. * Create a new \c Slapi_value structure and initialize it's value.
  4052. *
  4053. * \param s A \c NULL terminated string used to initialize
  4054. * the newly allocated \c Slapi_value.
  4055. * \return A pointer to the newly allocated and initialized value.
  4056. * \warning The passed in string will be used directly as the value.
  4057. * It will not be copied. Ownership of \c s is transferred
  4058. * to the new \c Slapi_Value structure, so it should not be
  4059. * freed by the caller.
  4060. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  4061. * \warning When you are no longer using the value, free it from memory
  4062. * by calling slapi_value_free()
  4063. * \see slapi_value_free()
  4064. * \see slapi_value_new()
  4065. * \see slapi_value_new_berval()
  4066. * \see slapi_value_new_string()
  4067. * \see slapi_value_dup()
  4068. */
  4069. Slapi_Value *slapi_value_new_string_passin(char *s);
  4070. /**
  4071. * Initialize a \c Slapi_Value structure.
  4072. *
  4073. * All fields of the passed in \c Slapi_Value will be reset to zero.
  4074. *
  4075. * \param v The value to initialize.
  4076. * \return A pointer to the initialized value.
  4077. * \warning The passed in value must not be \c NULL.
  4078. * \see slapi_value_init_berval()
  4079. * \see slapi_value_init_string()
  4080. * \see slapi_value_init_string_passin()
  4081. */
  4082. Slapi_Value *slapi_value_init(Slapi_Value *v);
  4083. /**
  4084. * Initialize a \c Slapi_Value structure from the value contained in a \c berval structure.
  4085. *
  4086. * \param v The value to initialize.
  4087. * \param bval The \c berval structure to be used to intialize the value.
  4088. * \return A pointer to the initialized value.
  4089. * \warning The passed in \c Slapi_Value must not be \c NULL.
  4090. * \warning The content of the \c berval structure is duplicated. It is up
  4091. * to the caller to manage the memory used by the \c berval.
  4092. * \see slapi_value_init()
  4093. * \see slapi_value_init_string()
  4094. * \see slapi_value_init_string_passin()
  4095. */
  4096. Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval);
  4097. /**
  4098. * Initialize a \c Slapi_Value with a copy of the value contained in a string.
  4099. *
  4100. * \param v The value to initialize.
  4101. * \param s The null-terminated string to be used to initialize the value.
  4102. * \return A pointer to the initialized value.
  4103. * \warning The passed in \c Slapi_Value must not be \c NULL.
  4104. * \warning The passed in string is duplicated. It is up to the caller to
  4105. * manage the memory used by the passed in string.
  4106. * \see slapi_value_init()
  4107. * \see slapi_value_init_berval()
  4108. * \see slapi_value_init_string_passin()
  4109. */
  4110. Slapi_Value *slapi_value_init_string(Slapi_Value *v,const char *s);
  4111. /* Initialize a \c Slapi_Value with the value contained in a string.
  4112. *
  4113. * \param v The value to initialize.
  4114. * \param s The null-terminated string to be used to initialize the value.
  4115. * \return A pointer to the initialized value.
  4116. * \warning The passed in \c Slapi_Value must not be \c NULL.
  4117. * \warning The passed in string is not duplicated. Responsibility for the
  4118. * memory used by the string is handed over to the \c Slapi_Value
  4119. * structure.
  4120. * \warning The passed in string must not be freed. It will be freed when
  4121. * the \c Slapi_Value structure is freed by calling \c slapi_value_free().
  4122. * \see slapi_value_free()
  4123. * \see slapi_value_init()
  4124. * \see slapi_value_init_berval()
  4125. * \see slapi_value_init_string()
  4126. */
  4127. Slapi_Value *slapi_value_init_string_passin(Slapi_Value *v, char *s);
  4128. /**
  4129. * Duplicate a \c Slapi_Value structure.
  4130. *
  4131. * \param v The value to duplicate.
  4132. * \return A pointer to the copy of the value.
  4133. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  4134. * \warning When you are no longer using the value, free it from memory
  4135. * by calling slapi_value_free()
  4136. * \warning This function is identical to slapi_value_new_value().
  4137. * \see slapi_value_new_value()
  4138. * \see slapi_value_free()
  4139. */
  4140. Slapi_Value *slapi_value_dup(const Slapi_Value *v);
  4141. /**
  4142. * Sets the flags in a \c Slapi_Value structure.
  4143. *
  4144. * Valid flags are:
  4145. * \arg #SLAPI_ATTR_FLAG_NORMALIZED
  4146. *
  4147. * \param v Pointer to the \c Slapi_Value structure for which to
  4148. * set the flags.
  4149. * \param flags The flags you want to set.
  4150. * \warning The flags support bit-wise operations.
  4151. * \see slapi_values_set_flags()
  4152. * \see slapi_value_get_flags()
  4153. */
  4154. void slapi_value_set_flags(Slapi_Value *v, unsigned long flags);
  4155. /**
  4156. * Sets the flags in an array of \c Slapi_Value structures.
  4157. *
  4158. * Valid flags are:
  4159. * \arg #SLAPI_ATTR_FLAG_NORMALIZED
  4160. *
  4161. * \param vs Pointer to the \c Slapi_Value array for which you
  4162. * want to set the flags.
  4163. * \param flags The flags you want to set.
  4164. * \warning The flags support bit-wise operations.
  4165. * \see slapi_value_set_flags()
  4166. * \see slapi_value_get_flags()
  4167. */
  4168. void slapi_values_set_flags(Slapi_Value **vs, unsigned long flags);
  4169. /**
  4170. * Retrieves the flags from a \c Slapi_Value structure.
  4171. *
  4172. * \param v Pointer to the \c Slapi_Value structure from which the
  4173. * flags are to be retrieved.
  4174. * \return The flags that are set in the value.
  4175. * \see slapi_value_set_flags()
  4176. * \see slapi_values_set_flags()
  4177. */
  4178. unsigned long slapi_value_get_flags(Slapi_Value *v);
  4179. /**
  4180. * Frees a \c Slapi_Value structure from memory.
  4181. *
  4182. * The contents of the value will be freed along with the \c Slapi_Value
  4183. * structure itself. The pointer will also be set to \c NULL.
  4184. *
  4185. * \param value Address of the pointer to the \c Slapi_Value structure
  4186. * you wish to free.
  4187. * \see slapi_value_new()
  4188. */
  4189. void slapi_value_free(Slapi_Value **value);
  4190. /**
  4191. * Gets the \c berval structure of the value.
  4192. *
  4193. * \param value Pointer to the \c Slapi_Value of which you wish
  4194. * to get the \c berval.
  4195. * \return A pointer to the \c berval structure contained in the
  4196. * \c Slapi_Value.
  4197. * \warning The returned pointer point to the actual \c berval structure
  4198. * inside of the value, not a copy.
  4199. * \warning You should not free the returned \c berval structure unless
  4200. * you plan to replace it by calling \c slapi_value_set_berval().
  4201. * \see slapi_value_set_berval()
  4202. */
  4203. const struct berval *slapi_value_get_berval( const Slapi_Value *value );
  4204. /**
  4205. * Sets the value of a \c Slapi_Value structure from a \c berval structure.
  4206. *
  4207. * The value is duplicated from the passed in \c berval structure.
  4208. *
  4209. * \param value Pointer to the \c Slapi_Value structure in which to
  4210. * set the value.
  4211. * \param bval Pointer to the \c berval value to be copied.
  4212. * \return Pointer to the \c Slapi_Value structure passed in as \c value.
  4213. * \return NULL if the passed in value was \c NULL.
  4214. * \warning If the pointer to the \c Slapi_Value structure is \c NULL,
  4215. * nothing is done, and the function returns \c NULL.
  4216. * \warning If the \c Slapi_Value structure already contains a value, it
  4217. * is freed from memory before the new one is set.
  4218. * \warning When you are no longer using the \c Slapi_Value structure, you
  4219. * should free it from memory by valling \c slapi_value_free().
  4220. * \see slapi_value_free()
  4221. * \see slapi_value_get_berval()
  4222. */
  4223. Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bval );
  4224. /**
  4225. * Sets the value of a \c Slapi_Value structure from another \c Slapi_Value structure.
  4226. *
  4227. * The value is duplicated from the supplied \c Slapi_value structure.
  4228. *
  4229. * \param value Pointer to the \c Slapi_Value structure in which to set
  4230. * the value.
  4231. * \param vfrom Pointer to the \c Slapi_Value structure from which to
  4232. * get the value.
  4233. * \return Pointer to the \c Slapi_Value structure passed as the \c value paramter.
  4234. * \return \c NULL if the \c value parameter was \c NULL.
  4235. * \warning The \c vfrom parameter must not be \c NULL.
  4236. * \warning If the pointer to the \c Slapi_Value structure is \c NULL,
  4237. * nothing is done, and the function returns \c NULL.
  4238. * \warning If the \c Slapi_Value structure already contains a value, it
  4239. * is freed from memory before the new one is set.
  4240. * \warning When you are no longer using the \c Slapi_Value structure, you
  4241. * should free it from memory by valling \c slapi_value_free().
  4242. * \see slapi_value_free()
  4243. */
  4244. Slapi_Value *slapi_value_set_value( Slapi_Value *value, const Slapi_Value *vfrom);
  4245. /**
  4246. * Sets the value of a \c Slapi_Value structure.
  4247. *
  4248. * The value is a duplicate of the data pointed to by \c val and the
  4249. * length \c len.
  4250. *
  4251. * \param value Pointer to the \c Slapi_Value structure in which to set
  4252. * the value.
  4253. * \param val Pointer to the value.
  4254. * \param len Length of the value.
  4255. * \return Pointer to the \c Slapi_Value structure with the value set.
  4256. * \return \c NULL if the supplied \c Slapi_Value is \c NULL.
  4257. * \warning If the pointer to the \c Slapi_Value structure is \c NULL,
  4258. * nothing is done, and the function returns \c NULL.
  4259. * \warning If the \c Slapi_Value structure already contains a value, it
  4260. * is freed from memory before the new one is set.
  4261. * \warning When you are no longer using the \c Slapi_Value structure, you
  4262. * should free it from memory by valling \c slapi_value_free().
  4263. * \see slapi_value_free()
  4264. */
  4265. Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len);
  4266. /**
  4267. * Sets the value of a \c Slapi_Value structure from a string.
  4268. *
  4269. * The value is duplicated from a supplied string.
  4270. *
  4271. * \param value Pointer to the \c Slapi_Value structure in which to set
  4272. * the value.
  4273. * \param strVal The string containing the value to set.
  4274. * \return \c 0 if the value is set.
  4275. * \return \c -1 if the pointer to the \c Slapi_Value is \c NULL.
  4276. * \warning If the pointer to the \c Slapi_Value structure is \c NULL,
  4277. * nothing is done, and the function returns \c -1.
  4278. * \warning If the \c Slapi_Value structure already contains a value, it
  4279. * is freed from memory before the new one is set.
  4280. * \warning When you are no longer using the \c Slapi_Value structure, you
  4281. * should free it from memory by valling \c slapi_value_free().
  4282. * \see slapi_value_free()
  4283. * \see slapi_value_set_string_passin()
  4284. */
  4285. int slapi_value_set_string(Slapi_Value *value, const char *strVal);
  4286. /**
  4287. * Sets the value of a \c Slapi_Value structure from a string.
  4288. *
  4289. * The supplied string is used as the value within the \c Slapi_Value
  4290. * structure.
  4291. *
  4292. * \param value Pointer to the \c Slapi_Value structure in which to set
  4293. * the value.
  4294. * \param strVal The string containing the value to set.
  4295. * \return \c 0 if the value is set.
  4296. * \return \c -1 if the pointer to the \c Slapi_Value is \c NULL.
  4297. * \warning Do not free the passed in string pointer to by \c strVal.
  4298. * Responsibility for the memory used by the string is handed
  4299. * over to the \c Slapi_Value structure.
  4300. * \warning When you are no longer using the \c Slapi_Value structure, you
  4301. * should free it from memory by valling \c slapi_value_free().
  4302. * \see slapi_value_free()
  4303. * \see slapi_value_set_string()
  4304. */
  4305. int slapi_value_set_string_passin(Slapi_Value *value, char *strVal);
  4306. /**
  4307. * Sets the value of a \c Slapi_Value structure from an integer.
  4308. *
  4309. * \param value Pointer to the \c Slapi_Value structure in which to set
  4310. * the value.
  4311. * \param intVal The integer containing the value to set.
  4312. * \return \c 0 if the value is set.
  4313. * \return \c -1 if the pointer to the \c Slapi_Value is \c NULL.
  4314. * \warning If the pointer to the \c Slapi_Value structure is \c NULL,
  4315. * nothing is done, and the function returns \c -1.
  4316. * \warning If the \c Slapi_Value structure already contains a value, it
  4317. * is freed from memory before the new one is set.
  4318. * \warning When you are no longer using the \c Slapi_Value structure, you
  4319. * should free it from memory by valling \c slapi_value_free().
  4320. * \see slapi_value_free()
  4321. */
  4322. int slapi_value_set_int(Slapi_Value *value, int intVal);
  4323. /**
  4324. * Retrieves the value of a \c Slapi_Value structure as a string.
  4325. *
  4326. * \param value Pointer to the value you wish to get as a string.
  4327. * \return A string containing the value.
  4328. * \return \c NULL if there is no value.
  4329. * \warning The returned string is the actual value, not a copy. You
  4330. * should not free the returned string unless you plan to
  4331. * replace it by calling slapi_value_set_string().
  4332. * \see slapi_value_set_string()
  4333. */
  4334. const char*slapi_value_get_string(const Slapi_Value *value);
  4335. /**
  4336. * Retrieves the value of a \c Slapi_Value structure as an integer.
  4337. *
  4338. * \param value Pointer to the value you wish to get as an integer.
  4339. * \return An integer that corresponds to the value stored in the
  4340. * \c Slapi_Value structure.
  4341. * \return \c 0 if there is no value.
  4342. * \see slapi_value_get_uint()
  4343. * \see slapi_value_get_long()
  4344. * \see slapi_value_get_ulong()
  4345. * \see slapi_value_get_longlong()
  4346. * \see slapi_value_get_ulonglong()
  4347. */
  4348. int slapi_value_get_int(const Slapi_Value *value);
  4349. /**
  4350. * Retrieves the value of a \c Slapi_Value structure as an unsigned integer.
  4351. *
  4352. * \param value Pointer to the value you wish to get as an unsigned integer.
  4353. * \return An unsigned integer that corresponds to the value stored in
  4354. * the \c Slapi_Value structure.
  4355. * \return \c 0 if there is no value.
  4356. * \see slapi_value_get_int()
  4357. * \see slapi_value_get_long()
  4358. * \see slapi_value_get_ulong()
  4359. * \see slapi_value_get_longlong()
  4360. * \see slapi_value_get_ulonglong()
  4361. */
  4362. unsigned int slapi_value_get_uint(const Slapi_Value *value);
  4363. /**
  4364. * Retrieves the value of a \c Slapi_Value structure as a long integer.
  4365. *
  4366. * \param value Pointer to the value you wish to get as a long integer.
  4367. * \return A long integer that corresponds to the value stored in the
  4368. * \c Slapi_Value structure.
  4369. * \return \c 0 if there is no value.
  4370. * \see slapi_value_get_int()
  4371. * \see slapi_value_get_uint()
  4372. * \see slapi_value_get_ulong()
  4373. * \see slapi_value_get_longlong()
  4374. * \see slapi_value_get_ulonglong()
  4375. */
  4376. long slapi_value_get_long(const Slapi_Value *value);
  4377. /**
  4378. * Retrieves the value of a \c Slapi_Value structure as an unsigned long integer.
  4379. *
  4380. * \param value Pointer to the value you wish to get as an unsigned long integer.
  4381. * \return An unsigned long integer that corresponds to the value stored in the
  4382. * \c Slapi_Value structure.
  4383. * \return \c 0 if there is no value.
  4384. * \see slapi_value_get_int()
  4385. * \see slapi_value_get_uint()
  4386. * \see slapi_value_get_long()
  4387. * \see slapi_value_get_longlong()
  4388. * \see slapi_value_get_ulonglong()
  4389. */
  4390. unsigned long slapi_value_get_ulong(const Slapi_Value *value);
  4391. /**
  4392. * Retrieves the value of a \c Slapi_Value structure as a long long integer.
  4393. *
  4394. * \param value Pointer to the value you wish to get as a long long integer.
  4395. * \return A long long integer that corresponds to the value stored in the
  4396. * \c Slapi_Value structure.
  4397. * \return \c 0 if there is no value.
  4398. * \see slapi_value_get_int()
  4399. * \see slapi_value_get_uint()
  4400. * \see slapi_value_get_long()
  4401. * \see slapi_value_get_ulong()
  4402. * \see slapi_value_get_ulonglong()
  4403. */
  4404. long long slapi_value_get_longlong(const Slapi_Value *value);
  4405. /**
  4406. * Retrieves the value of a \c Slapi_Value structure as an unsigned long long integer.
  4407. *
  4408. * \param value Pointer to the value you wish to get as an unsigned long long integer.
  4409. * \return An unsigned long long integer that corresponds to the value stored in the
  4410. * \c Slapi_Value structure.
  4411. * \return \c 0 if there is no value.
  4412. * \see slapi_value_get_int()
  4413. * \see slapi_value_get_uint()
  4414. * \see slapi_value_get_long()
  4415. * \see slapi_value_get_ulong()
  4416. * \see slapi_value_get_longlong()
  4417. */
  4418. unsigned long long slapi_value_get_ulonglong(const Slapi_Value *value);
  4419. /**
  4420. * Retrieves the value of a \c Slapi_Value structure as a long integer.
  4421. *
  4422. * \param value Pointer to the value you wish to get as a long integer.
  4423. * The value could end with D or d for days, H or h for hours,
  4424. * M or m for minutes, S or s for seconds, or no extension.
  4425. * \return A long integer that corresponds to the value stored in the
  4426. * \c Slapi_Value structure.
  4427. * \return \c 0 if there is no value.
  4428. * \return \c -1 if the given value is invalid.
  4429. * \see slapi_value_get_int()
  4430. * \see slapi_value_get_uint()
  4431. * \see slapi_value_get_ulong()
  4432. * \see slapi_value_get_longlong()
  4433. * \see slapi_value_get_ulonglong()
  4434. */
  4435. long slapi_value_get_timelong(const Slapi_Value *value);
  4436. /**
  4437. * Gets the length of a value contained in a \c Slapi_Value structure.
  4438. *
  4439. * \param value Pointer to the value of which you wish to get the length.
  4440. * \return The length of the value.
  4441. * \return \c 0 if there is no value.
  4442. */
  4443. size_t slapi_value_get_length(const Slapi_Value *value);
  4444. /**
  4445. * Compares two \c Slapi_Value structures
  4446. *
  4447. * The matching rule associated with the supplied attribute \c a is used
  4448. * to compare the two values.
  4449. *
  4450. * \param a A pointer to an attribute used to determine how the
  4451. * two values will be compared.
  4452. * \param v1 Pointer to the \c Slapi_Value structure containing the first
  4453. * value to compare.
  4454. * \param v2 Pointer to the \c Slapi_Value structure containing the second
  4455. * value to compare.
  4456. * \return \c 0 if the two values are equal.
  4457. * \return \c -1 if \c v1 is smaller than \c v2.
  4458. * \return \c 1 if \c v1 is greater than \c v2.
  4459. */
  4460. int slapi_value_compare(const Slapi_Attr *a,const Slapi_Value *v1,const Slapi_Value *v2);
  4461. /**
  4462. * Free and initialize the contents of the berval without freeing the
  4463. * struct berval * itself. This is useful when you use struct berval
  4464. * which are allocated on the stack e.g.
  4465. * \code
  4466. * struct berval bv = {0, NULL};
  4467. * slapi_ber_bvcpy(&bv, someotherbvp);
  4468. * // use bv
  4469. * slapi_ber_bvdone(&bv);
  4470. * \endcode
  4471. * You must only call slapi_ber_bvdone() if the bv_val member has been
  4472. * allocated with malloc() or is NULL.
  4473. *
  4474. * \param bvp A struct berval * you want to free the contents of
  4475. * \return \c void
  4476. */
  4477. void slapi_ber_bvdone(struct berval *bvp);
  4478. /**
  4479. * Copy the contents of the berval without allocating a new struct berval*
  4480. * This is useful when you use struct berval which are allocated on the stack e.g.
  4481. * \code
  4482. * struct berval bv = {0, NULL};
  4483. * slapi_ber_bvcpy(&bv, someotherbvp);
  4484. * // use bv
  4485. * slapi_ber_bvdone(&bv);
  4486. * \endcode
  4487. * The bvs source berval to copy from can either be allocated on the heap
  4488. * or the stack.
  4489. *
  4490. * \param bvd A struct berval * you want copy to
  4491. * \param bvs A struct berval * you want to copy from
  4492. * \return \c void
  4493. */
  4494. void slapi_ber_bvcpy(struct berval *bvd, const struct berval *bvs);
  4495. /*
  4496. * Valueset functions.
  4497. */
  4498. /**
  4499. * Flag that indicates that the value should be used by reference.
  4500. *
  4501. * \see slapi_valueset_add_value_ext()
  4502. */
  4503. #define SLAPI_VALUE_FLAG_PASSIN 0x1
  4504. #define SLAPI_VALUE_FLAG_IGNOREERROR 0x2
  4505. #define SLAPI_VALUE_FLAG_PRESERVECSNSET 0x4
  4506. #define SLAPI_VALUE_FLAG_USENEWVALUE 0x8 /* see valueset_remove_valuearray */
  4507. #define SLAPI_VALUE_FLAG_DUPCHECK 0x10 /* used in valueset_add... */
  4508. /**
  4509. * Creates an empty \c Slapi_ValueSet structure.
  4510. *
  4511. * \return Pointer to the newly allocated \c Slapi_ValueSet structure.
  4512. * \warning If no space can be allocated (for example, if no more virtual
  4513. * memory exists), the \c ns-slapd program terminates.
  4514. * \warning When you are no longer using the valueset, you should free it
  4515. * from memory by calling \c slapi_valueset_free().
  4516. * \see slapi_valueset_free()
  4517. */
  4518. Slapi_ValueSet *slapi_valueset_new( void );
  4519. /**
  4520. * Free a \c Slapi_ValueSet structure from memory.
  4521. *
  4522. * Call this function when you are done working with the structure.
  4523. * All members of the valueset will be freed as well if they are not
  4524. * \c NULL.
  4525. *
  4526. * \param vs Pointer to the \c Slapi_ValueSet to free.
  4527. * \see slapi_valueset_done()
  4528. */
  4529. void slapi_valueset_free(Slapi_ValueSet *vs);
  4530. /**
  4531. * Initializes a \c Slapi_ValueSet structure.
  4532. *
  4533. * All values inside of the structure will be cleared (set to \c 0).
  4534. * The values will not be freed by this function. To free the values
  4535. * first, call \c slapi_valueset_done().
  4536. *
  4537. * \param vs Pointer to the \c Slapi_ValueSet to initialize.
  4538. * \warning When you are no longer using the \c Slapi_ValueSet structure,
  4539. * you should free it from memory by calling \c slapi_valueset_free().
  4540. * \see slapi_valueset_done()
  4541. * \see slapi_valueset_free()
  4542. */
  4543. void slapi_valueset_init(Slapi_ValueSet *vs);
  4544. /**
  4545. * Frees the values contained in a \c Slapi_ValueSet structure.
  4546. *
  4547. * \param vs Pointer to the \c Slapi_ValueSet structure from which
  4548. * you want to free its values.
  4549. * \warning Use this function when you are no longer using the values
  4550. * but you want to re-use the \c Slapi_ValueSet structure for
  4551. * a new set of values.
  4552. * \see slapi_valueset_init()
  4553. */
  4554. void slapi_valueset_done(Slapi_ValueSet *vs);
  4555. /**
  4556. * Adds a value to a \c Slapi_ValueSet structure.
  4557. *
  4558. * \param vs Pointer to the \c Slapi_ValueSet structure to which to
  4559. * add the value.
  4560. * \param addval Pointer to the \c Slapi_Value structure to add to
  4561. * the \c Slapi_ValueSet.
  4562. * \warning The value is duplicated from the \c Slapi_Value structure,
  4563. * which can be freed frmo memory without altering the
  4564. * \c Slapi_ValueSet structure.
  4565. * \warning This function does not verify if the value is already present
  4566. * in the \c Slapi_ValueSet structure. You can manually check
  4567. * this using \c slapi_valueset_first_value() and
  4568. * \c slapi_valueset_next_value().
  4569. * \see slapi_valueset_first_value()
  4570. * \see slapi_valueset_next_value()
  4571. */
  4572. void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval);
  4573. /**
  4574. * Adds a value to a \c Slapi_ValueSet structure with optional flags.
  4575. *
  4576. * This function is similar to \c slapi_valueset_add_value(), but it
  4577. * allows optional flags to be specified to allow the new value to be
  4578. * used by reference.
  4579. *
  4580. * \param vs Pointer to the \c Slapi_ValueSet structure to which to
  4581. * add the value.
  4582. * \param addval Pointer to the \c Slapi_Value structure to add to
  4583. * the \c Slapi_ValueSet.
  4584. * \param flags If #SLAPI_VALUE_FLAG_PASSIN bit is set in the flags,
  4585. * the function will take over the ownership of the new value
  4586. * to be added without duplicating it.
  4587. * \warning This function does not verify if the value is already present
  4588. * in the \c Slapi_ValueSet structure. You can manually check
  4589. * this using \c slapi_valueset_first_value() and
  4590. * \c slapi_valueset_next_value().
  4591. * \see slapi_valueset_add_value()
  4592. * \see slapi_valueset_first_value()
  4593. * \see slapi_valueset_next_value()
  4594. */
  4595. void slapi_valueset_add_value_ext(Slapi_ValueSet *vs, const Slapi_Value *addval, unsigned long flags);
  4596. int slapi_valueset_add_attr_value_ext(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *addval, unsigned long flags);
  4597. /**
  4598. * Gets the first value in a \c Slapi_ValueSet structure.
  4599. *
  4600. * This function can be used with \c slapi_valueset_next_value() to
  4601. * iterate through all values in a \c Slapi_ValueSet structure.
  4602. *
  4603. * \param vs Pointer to the \c Slapi_ValueSet structure from which
  4604. * you wish to get the value.
  4605. * \param v Address of the pointer to the \c Slapi_Value structure
  4606. * for the returned value.
  4607. * \return The index of the value in the Slapi_ValueSet structure.
  4608. * \return \c -1 if there was no value.
  4609. * \warning This function gives a pointer to the actual value within
  4610. * the \c Slapi_ValueSet structure. You should not free it
  4611. * from memory.
  4612. * \warning You will need to pass this index to slapi_valueset_next_value()
  4613. * if you wish to iterate through all values in the valueset.
  4614. * \see slapi_valueset_next_value().
  4615. */
  4616. int slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v );
  4617. /**
  4618. * Gets the next value in a \c Slapi_ValueSet structure.
  4619. *
  4620. * This is part of a pair of iterator functions. It should be
  4621. * called after first calling \c slapi_valueset_first_value().
  4622. *
  4623. * \param vs Pointer to the \c Slapi_ValueSet structure from which
  4624. * you wish to get the value.
  4625. * \param index Value returned by the previous call to \c slapi_valueset_first_value()
  4626. * or \c slapi_valueset_next_value().
  4627. * \param v Address of the pointer to the \c Slapi_Value structure
  4628. * for the returned value.
  4629. * \return The index of the value in the Slapi_ValueSet structure.
  4630. * \return \c -1 if there was no value.
  4631. * \warning This function gives a pointer to the actual value within
  4632. * the \c Slapi_ValueSet structure. You should not free it
  4633. * from memory.
  4634. * \warning You will need to pass this index to slapi_valueset_next_value()
  4635. * if you wish to iterate through all values in the valueset.
  4636. * \see slapi_valueset_first_value()
  4637. */
  4638. int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v);
  4639. /**
  4640. * Returns the number of values contained in a \c Slapi_ValueSet structure.
  4641. *
  4642. * \param vs Pointer to the \c Slapi_ValueSet structure of which
  4643. * you wish to get the count.
  4644. * \return The number of values contained in the \c Slapi_ValueSet structure.
  4645. */
  4646. int slapi_valueset_count( const Slapi_ValueSet *vs);
  4647. /**
  4648. * Checks if a \c Slapi_ValueSet structure has values
  4649. *
  4650. * \param vs Pointer to the \c Slapi_ValueSet structure of which
  4651. * you wish to get the count.
  4652. * \return 1 if there are no values contained in the \c Slapi_ValueSet structure.
  4653. * \return 0 if there are values contained in the \c Slapi_ValueSet structure.
  4654. */
  4655. int slapi_valueset_isempty( const Slapi_ValueSet *vs);
  4656. /**
  4657. * Initializes a \c Slapi_ValueSet with copies of the values of a \c Slapi_Mod structure.
  4658. *
  4659. * \param vs Pointer to the \c Slapi_ValueSet structure into which
  4660. * you wish to copy the values.
  4661. * \param smod Pointer to the \c Slapi_Mod structure from which you
  4662. * want to copy the values.
  4663. * \warning This function does not verify that the \c Slapi_ValueSet
  4664. * structure already contains values, so it is your responsibility
  4665. * to verify that there are no values prior to calling this function.
  4666. * If you do not verify this, the allocated memory space will leak.
  4667. * You can free existing values by calling slapi_valueset_done().
  4668. * \see slapi_valueset_done()
  4669. */
  4670. void slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod);
  4671. /**
  4672. * Initializes a \c Slapi_ValueSet with copies of the values of another \c Slapi_ValueSet.
  4673. *
  4674. * \param vs1 Pointer to the \c Slapi_ValueSet structure into which
  4675. * you wish to copy the values.
  4676. * \param vs2 Pointer to the \c Slapi_ValueSet structure from which
  4677. * you want to copy the values.
  4678. * \warning This function does not verify that the \c Slapi_ValueSet
  4679. * structure already contains values, so it is your responsibility
  4680. * to verify that there are no values prior to calling this function.
  4681. * If you do not verify this, the allocated memory space will leak.
  4682. * You can free existing values by calling slapi_valueset_done().
  4683. * \see slapi_valueset_done()
  4684. */
  4685. void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
  4686. void slapi_valueset_join_attr_valueset(const Slapi_Attr *a, Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
  4687. /**
  4688. * Finds a requested value in a valueset.
  4689. *
  4690. * The syntax of a supplied attribute will be used to compare the values.
  4691. * This function can be used to check for duplicate values in a valueset.
  4692. *
  4693. * \param a Pointer to the attribute. This is used to determine the
  4694. * syntax of the values and how to match them.
  4695. * \param vs Pointer to the \c Slapi_ValueSet structure from which
  4696. * you wish to find the value.
  4697. * \param v Pointer to the \c Slapi_Value structure containing the
  4698. * value that you wish to find.
  4699. * \return Pointer to the value in the valueset if the value was found.
  4700. * \return \c NULL if the value was not found.
  4701. * \warning The returned pointer points to the actual value in the
  4702. * \c Slapi_ValueSet structure. It should not be freed.
  4703. */
  4704. Slapi_Value *slapi_valueset_find(const Slapi_Attr *a, const Slapi_ValueSet *vs, const Slapi_Value *v);
  4705. /* TODO - Pickup Doxygen work here */
  4706. /*
  4707. * operation routines
  4708. */
  4709. int slapi_op_abandoned( Slapi_PBlock *pb );
  4710. unsigned long slapi_op_get_type(Slapi_Operation * op);
  4711. void slapi_operation_set_flag(Slapi_Operation *op, unsigned long flag);
  4712. void slapi_operation_clear_flag(Slapi_Operation *op, unsigned long flag);
  4713. int slapi_operation_is_flag_set(Slapi_Operation *op, unsigned long flag);
  4714. int slapi_op_reserved(Slapi_PBlock *pb);
  4715. void slapi_operation_set_csngen_handler ( Slapi_Operation *op, void *callback );
  4716. void slapi_operation_set_replica_attr_handler ( Slapi_Operation *op, void *callback );
  4717. int slapi_operation_get_replica_attr ( Slapi_PBlock *pb, Slapi_Operation *op, const char *type, void *value );
  4718. char *slapi_op_type_to_string(unsigned long type);
  4719. int slapi_op_internal( Slapi_PBlock *pb );
  4720. /*
  4721. * connection routines
  4722. */
  4723. int slapi_connection_acquire(Slapi_Connection *conn);
  4724. int slapi_connection_remove_operation( Slapi_PBlock *pb, Slapi_Connection *conn, Slapi_Operation *op, int release);
  4725. /*
  4726. * LDAPMod manipulation routines
  4727. */
  4728. Slapi_Mods* slapi_mods_new( void );
  4729. void slapi_mods_init(Slapi_Mods *smods, int initCount);
  4730. void slapi_mods_init_byref(Slapi_Mods *smods, LDAPMod **mods);
  4731. void slapi_mods_init_passin(Slapi_Mods *smods, LDAPMod **mods);
  4732. void slapi_mods_free(Slapi_Mods **smods);
  4733. void slapi_mods_done(Slapi_Mods *smods);
  4734. void slapi_mods_insert_at(Slapi_Mods *smods, LDAPMod *mod, int pos);
  4735. void slapi_mods_insert_smod_at(Slapi_Mods *smods, Slapi_Mod *smod, int pos);
  4736. void slapi_mods_insert_before(Slapi_Mods *smods, LDAPMod *mod);
  4737. void slapi_mods_insert_smod_before(Slapi_Mods *smods, Slapi_Mod *smod);
  4738. void slapi_mods_insert_after(Slapi_Mods *smods, LDAPMod *mod);
  4739. void slapi_mods_insert_after(Slapi_Mods *smods, LDAPMod *mod);
  4740. void slapi_mods_add( Slapi_Mods *smods, int modtype, const char *type, unsigned long len, const char *val);
  4741. void slapi_mods_add_ldapmod(Slapi_Mods *smods, LDAPMod *mod);
  4742. void slapi_mods_add_modbvps( Slapi_Mods *smods, int modtype, const char *type, struct berval **bvps );
  4743. void slapi_mods_add_mod_values( Slapi_Mods *smods, int modtype, const char *type, Slapi_Value **va );
  4744. void slapi_mods_add_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  4745. void slapi_mods_add_string( Slapi_Mods *smods, int modtype, const char *type, const char *val);
  4746. void slapi_mods_remove(Slapi_Mods *smods);
  4747. LDAPMod *slapi_mods_get_first_mod(Slapi_Mods *smods);
  4748. LDAPMod *slapi_mods_get_next_mod(Slapi_Mods *smods);
  4749. Slapi_Mod *slapi_mods_get_first_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  4750. Slapi_Mod *slapi_mods_get_next_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  4751. void slapi_mods_iterator_backone(Slapi_Mods *smods);
  4752. LDAPMod **slapi_mods_get_ldapmods_byref(Slapi_Mods *smods);
  4753. LDAPMod **slapi_mods_get_ldapmods_passout(Slapi_Mods *smods);
  4754. int slapi_mods_get_num_mods(const Slapi_Mods *smods);
  4755. void slapi_mods_dump(const Slapi_Mods *smods, const char *text);
  4756. Slapi_Mod* slapi_mod_new( void );
  4757. void slapi_mod_init(Slapi_Mod *smod, int initCount);
  4758. void slapi_mod_init_byval(Slapi_Mod *smod, const LDAPMod *mod);
  4759. void slapi_mod_init_byref(Slapi_Mod *smod, LDAPMod *mod);
  4760. void slapi_mod_init_passin(Slapi_Mod *smod, LDAPMod *mod);
  4761. /* init a mod and set the mod values to be a copy of the given valueset */
  4762. void slapi_mod_init_valueset_byval(Slapi_Mod *smod, int op, const char *type, const Slapi_ValueSet *svs);
  4763. void slapi_mod_add_value(Slapi_Mod *smod, const struct berval *val);
  4764. void slapi_mod_remove_value(Slapi_Mod *smod);
  4765. struct berval *slapi_mod_get_first_value(Slapi_Mod *smod);
  4766. struct berval *slapi_mod_get_next_value(Slapi_Mod *smod);
  4767. const char *slapi_mod_get_type(const Slapi_Mod *smod);
  4768. int slapi_mod_get_operation(const Slapi_Mod *smod);
  4769. void slapi_mod_set_type(Slapi_Mod *smod, const char *type);
  4770. void slapi_mod_set_operation(Slapi_Mod *smod, int op);
  4771. int slapi_mod_get_num_values(const Slapi_Mod *smod);
  4772. const LDAPMod *slapi_mod_get_ldapmod_byref(const Slapi_Mod *smod);
  4773. LDAPMod *slapi_mod_get_ldapmod_passout(Slapi_Mod *smod);
  4774. void slapi_mod_free(Slapi_Mod **smod);
  4775. void slapi_mod_done(Slapi_Mod *mod);
  4776. int slapi_mod_isvalid(const Slapi_Mod *mod);
  4777. void slapi_mod_dump(LDAPMod *mod, int n);
  4778. /* helper functions to translate between entry and a set of mods */
  4779. int slapi_mods2entry(Slapi_Entry **e, const char *dn, LDAPMod **attrs);
  4780. int slapi_entry2mods(const Slapi_Entry *e, char **dn, LDAPMod ***attrs);
  4781. #if defined(USE_OLD_UNHASHED)
  4782. int is_type_forbidden(const char *type);
  4783. #endif
  4784. /*
  4785. * routines for dealing with filters
  4786. */
  4787. int slapi_filter_get_choice( Slapi_Filter *f );
  4788. int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
  4789. int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type );
  4790. int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
  4791. char ***any, char **final );
  4792. Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
  4793. Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
  4794. Slapi_Filter *slapi_str2filter( char *str );
  4795. Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1,
  4796. Slapi_Filter *f2 );
  4797. Slapi_Filter *slapi_filter_join_ex( int ftype, Slapi_Filter *f1,
  4798. Slapi_Filter *f2, int recurse_always );
  4799. void slapi_filter_free( Slapi_Filter *f, int recurse );
  4800. int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  4801. int verify_access );
  4802. int slapi_vattr_filter_test( Slapi_PBlock *pb, Slapi_Entry *e,
  4803. struct slapi_filter *f, int verify_access);
  4804. int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f);
  4805. char *slapi_find_matching_paren( const char *str );
  4806. int slapi_filter_test_ext( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  4807. int verify_access , int only_test_access);
  4808. int slapi_vattr_filter_test_ext( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  4809. int verify_access , int only_test_access);
  4810. int slapi_filter_compare(struct slapi_filter *f1, struct slapi_filter *f2);
  4811. Slapi_Filter *slapi_filter_dup(Slapi_Filter *f);
  4812. int slapi_filter_changetype(Slapi_Filter *f, const char *newtype);
  4813. /**
  4814. * Normalize in-place the given filter. Normalizes the attribute types always.
  4815. * If norm_values is true, will also normalize the values.
  4816. *
  4817. * \param f the filter to normalize
  4818. * \param norm_values if true, normalize the values in addition to the type names
  4819. */
  4820. void slapi_filter_normalize(Slapi_Filter *f, PRBool norm_values);
  4821. /**
  4822. * Check whether a given attribute type is defined in schema or not
  4823. *
  4824. * \param attribute type name to be checked
  4825. * \return \c 0 if the attribute type is not defined in schema
  4826. * \return non-0 if the attribute type is defined in schema
  4827. */
  4828. int slapi_attr_syntax_exists(const char *type);
  4829. /**
  4830. * Reload internally registered attribute syntaxes.
  4831. *
  4832. * \param none
  4833. * \return \c 0 if the reload was successful.
  4834. * \return non-0 if the reload failed.
  4835. */
  4836. int slapi_reload_internal_attr_syntax(void);
  4837. /*
  4838. * slapi_filter_apply() is used to apply a function to each simple filter
  4839. * component within a complex filter. A 'simple filter' is anything other
  4840. * than AND, OR or NOT.
  4841. */
  4842. typedef int (*FILTER_APPLY_FN)( Slapi_Filter *f, void *arg);
  4843. int slapi_filter_apply( struct slapi_filter *f, FILTER_APPLY_FN fn, void *arg,
  4844. int *error_code );
  4845. /*
  4846. * Possible return values for slapi_filter_apply() and FILTER_APPLY_FNs.
  4847. * Note that a FILTER_APPLY_FN should return _STOP or _CONTINUE only.
  4848. */
  4849. #define SLAPI_FILTER_SCAN_STOP -1 /* premature abort */
  4850. #define SLAPI_FILTER_SCAN_ERROR -2 /* an error occurred */
  4851. #define SLAPI_FILTER_SCAN_NOMORE 0 /* success */
  4852. #define SLAPI_FILTER_SCAN_CONTINUE 1 /* continue scanning */
  4853. /* Error codes that slapi_filter_apply() may set in *error_code */
  4854. #define SLAPI_FILTER_UNKNOWN_FILTER_TYPE 2
  4855. /*
  4856. * Bit-Twiddlers
  4857. */
  4858. unsigned char slapi_setbit_uchar(unsigned char f,unsigned char bitnum);
  4859. unsigned char slapi_unsetbit_uchar(unsigned char f,unsigned char bitnum);
  4860. int slapi_isbitset_uchar(unsigned char f,unsigned char bitnum);
  4861. unsigned int slapi_setbit_int(unsigned int f,unsigned int bitnum);
  4862. unsigned int slapi_unsetbit_int(unsigned int f,unsigned int bitnum);
  4863. int slapi_isbitset_int(unsigned int f,unsigned int bitnum);
  4864. /*
  4865. * routines for sending entries and results to the client
  4866. */
  4867. int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e,
  4868. LDAPControl **ectrls, char **attrs, int attrsonly );
  4869. void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched,
  4870. char *text, int nentries, struct berval **urls );
  4871. int slapi_send_ldap_referral( Slapi_PBlock *pb, Slapi_Entry *e,
  4872. struct berval **refs, struct berval ***urls );
  4873. int slapi_send_ldap_intermediate( Slapi_PBlock *pb, LDAPControl **ectrls,
  4874. char *responseName, struct berval *responseValue);
  4875. typedef int (*send_ldap_search_entry_fn_ptr_t)( Slapi_PBlock *pb,
  4876. Slapi_Entry *e, LDAPControl **ectrls, char **attrs, int attrsonly );
  4877. typedef void (*send_ldap_result_fn_ptr_t)( Slapi_PBlock *pb, int err,
  4878. char *matched, char *text, int nentries, struct berval **urls );
  4879. typedef int (*send_ldap_referral_fn_ptr_t)( Slapi_PBlock *pb,
  4880. Slapi_Entry *e, struct berval **refs, struct berval ***urls );
  4881. /*
  4882. * matching rule
  4883. */
  4884. typedef int (*mrFilterMatchFn) (void* filter, Slapi_Entry*, Slapi_Attr* vals);
  4885. /* returns: 0 filter matched
  4886. * -1 filter did not match
  4887. * >0 an LDAP error code
  4888. */
  4889. int slapi_mr_indexer_create(Slapi_PBlock* opb);
  4890. int slapi_mr_filter_index(Slapi_Filter* f, Slapi_PBlock* pb);
  4891. int slapi_berval_cmp(const struct berval* L, const struct berval* R);
  4892. #define SLAPI_BERVAL_EQ(L,R) ((L)->bv_len == (R)->bv_len && \
  4893. ! memcmp ((L)->bv_val, (R)->bv_val, (L)->bv_len))
  4894. typedef struct slapi_matchingRuleEntry {
  4895. char *mr_oid; /* the official oid */
  4896. char *mr_oidalias; /* not currently used */
  4897. char *mr_name; /* the official name */
  4898. char *mr_desc; /* a description */
  4899. char *mr_syntax; /* the assertion syntax OID */
  4900. int mr_obsolete; /* is mr obsolete? */
  4901. char **mr_compat_syntax; /* list of OIDs of other syntaxes that can use this matching rule */
  4902. } slapi_matchingRuleEntry;
  4903. typedef struct slapi_matchingRuleEntry Slapi_MatchingRuleEntry;
  4904. Slapi_MatchingRuleEntry *slapi_matchingrule_new(void);
  4905. void slapi_matchingrule_free(Slapi_MatchingRuleEntry **mrEntry,
  4906. int freeMembers);
  4907. int slapi_matchingrule_get(Slapi_MatchingRuleEntry *mr, int arg, void *value);
  4908. int slapi_matchingrule_set(Slapi_MatchingRuleEntry *mr, int arg, void *value);
  4909. int slapi_matchingrule_register(Slapi_MatchingRuleEntry *mrEntry);
  4910. int slapi_matchingrule_unregister(char *oid);
  4911. /**
  4912. * Is the given matching rule an ordering matching rule and is it
  4913. * compatible with the given syntax?
  4914. *
  4915. * \param name_or_oid Name or OID of a matching rule
  4916. * \param syntax_oid OID of a syntax
  4917. * \return \c TRUE if the matching rule is an ordering rule and can be used by the given syntax
  4918. * \return \c FALSE otherwise
  4919. */
  4920. int slapi_matchingrule_is_ordering(const char *oid_or_name, const char *syntax_oid);
  4921. /**
  4922. * Can the given syntax OID use the given matching rule name/OID? A
  4923. * matching rule can apply to more than one syntax. Use this function
  4924. * to determine if the given syntax can use the given matching rule.
  4925. *
  4926. * \param mr_name_or_oid Name or OID of a matching rule
  4927. * \param syntax_oid OID of a syntax
  4928. * \return \c TRUE if the syntax can be used with the matching rule
  4929. * \return \c FALSE otherwise
  4930. */
  4931. int slapi_matchingrule_is_compat(const char *mr_oid_or_name, const char *syntax_oid);
  4932. /**
  4933. * In certain cases, we can just use a simple compare function to
  4934. * generate index keys. The compare function is usually provided
  4935. * by the syntax plugin. If this is the case, we can skip generating
  4936. * an indexer in the index config code.
  4937. *
  4938. * \param mr_name_or_oid Name or OID of a matching rule
  4939. * \return \c TRUE if the matching rule can use a simple compare function
  4940. * \return \c FALSE otherwise
  4941. */
  4942. int slapi_matchingrule_can_use_compare_fn(const char *mr_oid_or_name);
  4943. /*
  4944. * access control
  4945. */
  4946. int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr,
  4947. struct berval *val, int access );
  4948. int slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e,
  4949. LDAPMod **mods, char **errbuf );
  4950. int slapi_acl_verify_aci_syntax(Slapi_PBlock *pb, Slapi_Entry *e, char **errbuf);
  4951. /*
  4952. * attribute stuff
  4953. */
  4954. int slapi_value_find( void *plugin, struct berval **vals, struct berval *v );
  4955. /*
  4956. * password handling
  4957. */
  4958. #define SLAPI_USERPWD_ATTR "userpassword"
  4959. int slapi_pw_find_sv( Slapi_Value **vals, const Slapi_Value *v );
  4960. /* value encoding encoding */
  4961. /* checks if the value is encoded with any known algorithm*/
  4962. int slapi_is_encoded(char *value);
  4963. /* encode value with the specified algorithm */
  4964. char* slapi_encode(char *value, char *alg);
  4965. /* encode value with the specified algorithm, or with local algorithm if pb
  4966. * and sdn are specified instead, or global algorithm if pb and sdn are null */
  4967. char* slapi_encode_ext(Slapi_PBlock *pb, const Slapi_DN *sdn, char *value, char *alg);
  4968. /* UTF8 related */
  4969. int slapi_has8thBit(unsigned char *s);
  4970. unsigned char *slapi_utf8StrToLower(unsigned char *s);
  4971. void slapi_utf8ToLower(unsigned char *s, unsigned char *d, int *ssz, int *dsz);
  4972. int slapi_utf8isUpper(unsigned char *s);
  4973. unsigned char *slapi_utf8StrToUpper(unsigned char *s);
  4974. void slapi_utf8ToUpper(unsigned char *s, unsigned char *d, int *ssz, int *dsz);
  4975. int slapi_utf8isLower(unsigned char *s);
  4976. int slapi_utf8casecmp(unsigned char *s0, unsigned char *s1);
  4977. int slapi_utf8ncasecmp(unsigned char *s0, unsigned char *s1, int n);
  4978. unsigned char *slapi_UTF8STRTOLOWER(char *s);
  4979. void slapi_UTF8TOLOWER(char *s, char *d, int *ssz, int *dsz);
  4980. int slapi_UTF8ISUPPER(char *s);
  4981. unsigned char *slapi_UTF8STRTOUPPER(char *s);
  4982. void slapi_UTF8TOUPPER(char *s, char *d, int *ssz, int *dsz);
  4983. int slapi_UTF8ISLOWER(char *s);
  4984. int slapi_UTF8CASECMP(char *s0, char *s1);
  4985. int slapi_UTF8NCASECMP(char *s0, char *s1, int n);
  4986. /*
  4987. * Interface to the API broker service
  4988. *
  4989. * The API broker allows plugins to publish an API that may be discovered
  4990. * and used dynamically at run time by other subsystems e.g. other plugins.
  4991. */
  4992. /* Function: slapi_apib_register
  4993. Description: this function allows publication of an interface
  4994. Parameters: guid - a string constant that uniquely identifies the
  4995. interface (must exist for the life of the server)
  4996. api - a vtable for the published api (must exist for the
  4997. life of the server or until the reference count,
  4998. if it exists, reaches zero)
  4999. Return: 0 if function succeeds
  5000. non-zero otherwise
  5001. */
  5002. int slapi_apib_register(char *guid, void **api); /* publish an interface */
  5003. /* Function: slapi_apib_unregister
  5004. Description: this function allows removal of a published interface
  5005. Parameters: guid - a string constant that uniquely identifies the interface
  5006. Return: 0 if function succeeds
  5007. non-zero otherwise
  5008. */
  5009. int slapi_apib_unregister(char *guid); /* remove interface from published list */
  5010. /* Function: slapi_apib_get_interface
  5011. Description: this function allows retrieval of a published interface,
  5012. if the api reference counted, then the reference
  5013. count is incremented
  5014. Parameters: guid - a string constant that uniquely identifies the
  5015. interface requested
  5016. api - the retrieved vtable for the published api (must NOT
  5017. be freed)
  5018. Return: 0 if function succeeds
  5019. non-zero otherwise
  5020. */
  5021. int slapi_apib_get_interface(char *guid, void ***api); /* retrieve an interface for use */
  5022. /* Function: slapi_apib_get_interface_all
  5023. Description: this function allows retrieval of a published interface,
  5024. if the api reference counted, then the reference
  5025. count is incremented
  5026. This will return all published interfaces for a given guid
  5027. Parameters: guid - a string constant that uniquely identifies the
  5028. interface requested
  5029. apilist - the retrieved list of vtables for the published api - caller
  5030. must free the apilist, but not the apilist elements
  5031. Return: 0 if function succeeds
  5032. non-zero otherwise
  5033. */
  5034. int slapi_apib_get_interface_all(char *guid, void ****apilist); /* retrieve all interfaces for guid */
  5035. /* Function: slapi_apib_make_reference_counted
  5036. Description: this function makes an interface a reference counted interface
  5037. it must be called prior to registering the interface
  5038. Parameters: api - the api to make a reference counted api
  5039. callback - if non-zero, this must be a pointer to a function
  5040. which the api broker will call when the ref count for
  5041. the api reaches zero. This function must return 0 if
  5042. it deregisters the api, non-zero otherwise
  5043. api - the retrieved vtable for the published api (must NOT
  5044. be freed)
  5045. Return: 0 if function succeeds
  5046. non-zero otherwise
  5047. */
  5048. typedef int (*slapi_apib_callback_on_zero)(void **api);
  5049. int slapi_apib_make_reference_counted(void **api,
  5050. slapi_apib_callback_on_zero callback);
  5051. /* Function: slapi_apib_addref
  5052. Description: this function adds to the reference count of an api - a
  5053. call to this function should be paired with a call
  5054. to slapi_apib_release
  5055. - ONLY FOR REFERENCE COUNTED APIS
  5056. Parameters: api - the api to add a reference to
  5057. Return: the new reference count
  5058. */
  5059. int slapi_apib_addref(void **api);
  5060. /* Function: slapi_apib_release
  5061. Description: this function adds to the reference count of an api - a
  5062. call to this function should be paired with a prior call
  5063. to slapi_apib_addref or slapi_apib_get_interface
  5064. - ONLY FOR REFERENCE COUNTED APIS
  5065. Parameters: api - the api to add a reference to
  5066. Return: the new reference count
  5067. */
  5068. int slapi_apib_release(void **api);
  5069. /**** End of API broker interface. *******************************************/
  5070. /* thread_data.c */
  5071. int slapi_td_init(int indexType);
  5072. int slapi_td_set_val(int indexType, void *value);
  5073. void slapi_td_get_val(int indexType, void **value);
  5074. int slapi_td_dn_init(void);
  5075. int slapi_td_set_dn(char *dn);
  5076. void slapi_td_get_dn(char **dn);
  5077. /* Thread Local Storage Index Types */
  5078. #define SLAPI_TD_REQUESTOR_DN 1
  5079. /*
  5080. * routines for dealing with controls
  5081. */
  5082. int slapi_control_present( LDAPControl **controls, char *oid,
  5083. struct berval **val, int *iscritical );
  5084. void slapi_register_supported_control( char *controloid,
  5085. unsigned long controlops );
  5086. LDAPControl * slapi_dup_control( LDAPControl *ctrl );
  5087. #define SLAPI_OPERATION_BIND 0x00000001UL
  5088. #define SLAPI_OPERATION_UNBIND 0x00000002UL
  5089. #define SLAPI_OPERATION_SEARCH 0x00000004UL
  5090. #define SLAPI_OPERATION_MODIFY 0x00000008UL
  5091. #define SLAPI_OPERATION_ADD 0x00000010UL
  5092. #define SLAPI_OPERATION_DELETE 0x00000020UL
  5093. #define SLAPI_OPERATION_MODDN 0x00000040UL
  5094. #define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN
  5095. #define SLAPI_OPERATION_COMPARE 0x00000080UL
  5096. #define SLAPI_OPERATION_ABANDON 0x00000100UL
  5097. #define SLAPI_OPERATION_EXTENDED 0x00000200UL
  5098. #define SLAPI_OPERATION_ANY 0xFFFFFFFFUL
  5099. #define SLAPI_OPERATION_NONE 0x00000000UL
  5100. int slapi_get_supported_controls_copy( char ***ctrloidsp,
  5101. unsigned long **ctrlopsp );
  5102. int slapi_build_control( char *oid, BerElement *ber,
  5103. char iscritical, LDAPControl **ctrlp );
  5104. int slapi_build_control_from_berval( char *oid, struct berval *bvp,
  5105. char iscritical, LDAPControl **ctrlp );
  5106. /* Given an array of controls e.g. LDAPControl **ctrls, add the given
  5107. control to the end of the array, growing the array with realloc
  5108. e.g. slapi_add_control_ext(&ctrls, newctrl, 1);
  5109. if ctrls is NULL, the array will be created with malloc
  5110. if copy is true, the given control will be copied
  5111. if copy is false, the given control will be used and owned by the array
  5112. if copy is false, make sure the control can be freed by ldap_controls_free
  5113. */
  5114. void slapi_add_control_ext( LDAPControl ***ctrlsp, LDAPControl *newctrl, int copy );
  5115. /* Given an array of controls e.g. LDAPControl **ctrls, add all of the given
  5116. controls in the newctrls array to the end of ctrls, growing the array with realloc
  5117. if ctrls is NULL, the array will be created with malloc
  5118. if copy is true, each given control will be copied
  5119. if copy is false, each given control will be used and owned by the array
  5120. if copy is false, make sure each control can be freed by ldap_controls_free
  5121. */
  5122. void slapi_add_controls( LDAPControl ***ctrlsp, LDAPControl **newctrls, int copy );
  5123. /*
  5124. * routines for dealing with extended operations
  5125. */
  5126. char **slapi_get_supported_extended_ops_copy( void );
  5127. /*
  5128. * bind, including SASL
  5129. */
  5130. void slapi_register_supported_saslmechanism( char *mechanism );
  5131. char ** slapi_get_supported_saslmechanisms_copy( void );
  5132. void slapi_add_auth_response_control( Slapi_PBlock *pb, const char *binddn );
  5133. int slapi_add_pwd_control( Slapi_PBlock *pb, char *arg, long time );
  5134. int slapi_pwpolicy_make_response_control (Slapi_PBlock *pb, int seconds, int logins, int error);
  5135. /* Password Policy Response Control stuff - the error argument above */
  5136. #define LDAP_PWPOLICY_PWDEXPIRED 0
  5137. #define LDAP_PWPOLICY_ACCTLOCKED 1
  5138. #define LDAP_PWPOLICY_CHGAFTERRESET 2
  5139. #define LDAP_PWPOLICY_PWDMODNOTALLOWED 3
  5140. #define LDAP_PWPOLICY_MUSTSUPPLYOLDPWD 4
  5141. #define LDAP_PWPOLICY_INVALIDPWDSYNTAX 5
  5142. #define LDAP_PWPOLICY_PWDTOOSHORT 6
  5143. #define LDAP_PWPOLICY_PWDTOOYOUNG 7
  5144. #define LDAP_PWPOLICY_PWDINHISTORY 8
  5145. /*
  5146. * Password Policy API
  5147. */
  5148. /**
  5149. * Gets the password policy object for a given entry
  5150. *
  5151. * \param dn The dn of the entry whose password policy object you
  5152. * want returned
  5153. *
  5154. * \return A pointer to an opaque password policy object
  5155. * \return \c NULL if there is a problem getting the policy object
  5156. * \warning The caller should free the returned password policy
  5157. * object when finished by calling the slapi_pwpolicy_free()
  5158. * function.
  5159. * \see slapi_pwpolicy_free()
  5160. */
  5161. Slapi_PWPolicy *slapi_get_pwpolicy(Slapi_DN *dn);
  5162. /**
  5163. * Free a password policy object from memory
  5164. *
  5165. * \param pwpolicy The password policy object that you want to free
  5166. * \see slapi_get_pwpolicy()
  5167. */
  5168. void slapi_pwpolicy_free(Slapi_PWPolicy *pwpolicy);
  5169. /**
  5170. * Checks a password policy object to see if the password is expired
  5171. *
  5172. * \param pwpolicy The password policy object that you want to check
  5173. * \param e The entry that you want to check
  5174. * \param expire_time Fills in the expiration time if the password has not expired yet.
  5175. * You can pass \c NULL if you are not interested in the expiration time.
  5176. * \param remaining_grace Fills in the number of grace logins remaining if the password
  5177. * has already expired. You can pass \c NULL if you are not interested in the
  5178. * number of remaining grace logins.
  5179. *
  5180. * \return \c 1 if the password has expired
  5181. * \return \c 0 if the password has not expired
  5182. */
  5183. int slapi_pwpolicy_is_expired(Slapi_PWPolicy *pwpolicy, Slapi_Entry *e, time_t *expire_time, int *remaining_grace);
  5184. /**
  5185. * Checks a password policy to see if an account is locked
  5186. *
  5187. * \param pwpolicy The password policy object that you want to check
  5188. * \param e The entry that you want to check
  5189. * \param unlock_time Fills in the time the account will be unlocked if the account
  5190. * is currently locked. You can pass \c NULL if you are not interested in the
  5191. * unlock time.
  5192. *
  5193. * \return \c 1 if the account is locked
  5194. * \return \c 0 if the account is not locked
  5195. */
  5196. int slapi_pwpolicy_is_locked(Slapi_PWPolicy *pwpolicy, Slapi_Entry *e, time_t *unlock_time);
  5197. /**
  5198. * Checks a password policy to see if a password has been reset
  5199. *
  5200. * \param pwpolicy The password policy object that you want to check
  5201. * \param e The entry that you want to check
  5202. *
  5203. * \return \c 1 if the password has been reset
  5204. * \return \c 0 if the password has not been reset
  5205. */
  5206. int slapi_pwpolicy_is_reset(Slapi_PWPolicy *pwpolicy, Slapi_Entry *e);
  5207. /**
  5208. * Free an array of strings from memory
  5209. *
  5210. * \param array The array that you want to free
  5211. * \see slapi_ch_array_add()
  5212. * \see slapi_ch_array_dup()
  5213. */
  5214. void slapi_ch_array_free( char **array );
  5215. /**
  5216. * Duplicate an array of strings
  5217. *
  5218. * \param array The array that you want to duplicate
  5219. * \return A newly allocated copy of \c array
  5220. * \return \c NULL if there is a problem duplicating the array
  5221. * \warning The caller should free the returned array when finished
  5222. * by calling the slapi_ch_array_free() function.
  5223. * \see slapi_ch_array_free()
  5224. */
  5225. char ** slapi_ch_array_dup( char **array );
  5226. /**
  5227. * Add a string to an array of strings
  5228. *
  5229. * \param array The array to add the string to
  5230. * \param string The string to add to the array
  5231. * \warning The \c string parameter is not copied. If you do not
  5232. * want to hand the memory used by \c string over to the
  5233. * array, you should duplicate it first by calling the
  5234. * slapi_ch_strdup() function.
  5235. * \warning If \c *a is \c NULL, a new array will be allocated.
  5236. * \see slapi_ch_array_free()
  5237. */
  5238. void slapi_ch_array_add( char ***array, char *string );
  5239. /**
  5240. * Add a string to an array of strings
  5241. *
  5242. * \param array The array to add the string to
  5243. * \param string The string to add to the array
  5244. * \warning The \c string parameter is not copied. If you do not
  5245. * want to hand the memory used by \c string over to the
  5246. * array, you should duplicate it first by calling the
  5247. * slapi_ch_strdup() function.
  5248. * \warning If \c *a is \c NULL, a new array will be allocated.
  5249. * \see slapi_ch_array_free()
  5250. * \return the total number of elements in the array.
  5251. */
  5252. int slapi_ch_array_add_ext(char ***array, char *string);
  5253. /**
  5254. * Find a string in an array of strings
  5255. *
  5256. * \param array The array of strings
  5257. * \param string The string to look for in the array
  5258. * \return NULL if there is no match
  5259. * \return 1 if there is a match
  5260. */
  5261. int slapi_ch_array_utf8_inlist(char **array, char *string);
  5262. /**
  5263. * Returns the error string of an ldap result code, but it can also handle
  5264. * library errors(negative result codes)
  5265. *
  5266. * \param result The result code
  5267. * \return The error text string of the result code
  5268. */
  5269. char *slapi_err2string(int result);
  5270. /**
  5271. * Check if the server has started shutting down
  5272. *
  5273. * \return 1 if the server is shutting down
  5274. */
  5275. int slapi_is_shutting_down(void);
  5276. /*
  5277. * checking routines for allocating and freeing memory
  5278. */
  5279. char * slapi_ch_malloc( unsigned long size );
  5280. char * slapi_ch_realloc( char *block, unsigned long size );
  5281. char * slapi_ch_calloc( unsigned long nelem, unsigned long size );
  5282. char * slapi_ch_strdup( const char *s );
  5283. void slapi_ch_free( void **ptr );
  5284. void slapi_ch_free_string( char **s );
  5285. struct berval* slapi_ch_bvdup(const struct berval*);
  5286. struct berval** slapi_ch_bvecdup(struct berval**);
  5287. void slapi_ch_bvfree(struct berval** v);
  5288. char * slapi_ch_smprintf(const char *fmt, ...)
  5289. #ifdef __GNUC__
  5290. __attribute__ ((format (printf, 1, 2)));
  5291. #else
  5292. ;
  5293. #endif
  5294. /*
  5295. * syntax plugin routines
  5296. * THESE ARE DEPRECATED - the first argument is the syntax plugin
  5297. * we do not support that style of call anymore - use the slapi_attr_
  5298. * versions below instead
  5299. */
  5300. int slapi_call_syntax_values2keys_sv( void *vpi, Slapi_Value **vals,
  5301. Slapi_Value ***ivals, int ftype );
  5302. int slapi_call_syntax_values2keys_sv_pb( void *vpi, Slapi_Value **vals,
  5303. Slapi_Value ***ivals, int ftype, Slapi_PBlock *pb );
  5304. int slapi_call_syntax_assertion2keys_ava_sv( void *vpi, Slapi_Value *val,
  5305. Slapi_Value ***ivals, int ftype );
  5306. int slapi_call_syntax_assertion2keys_sub_sv( void *vpi, char *initial,
  5307. char **any, char *final, Slapi_Value ***ivals );
  5308. int slapi_attr_values2keys_sv( const Slapi_Attr *sattr, Slapi_Value **vals,
  5309. Slapi_Value ***ivals, int ftype );
  5310. int slapi_attr_values2keys_sv_pb( const Slapi_Attr *sattr, Slapi_Value **vals,
  5311. Slapi_Value ***ivals, int ftype, Slapi_PBlock *pb );
  5312. int slapi_attr_assertion2keys_ava_sv( const Slapi_Attr *sattr, Slapi_Value *val,
  5313. Slapi_Value ***ivals, int ftype );
  5314. int slapi_attr_assertion2keys_sub_sv( const Slapi_Attr *sattr, char *initial,
  5315. char **any, char *final, Slapi_Value ***ivals );
  5316. /**
  5317. * Normalize the given value using the syntax associated with the
  5318. * given attribute. It will attempt to normalize the value in place.
  5319. * If it cannot, it will return the normalized value in retval. If
  5320. * trim_spaces is true, whitepace characters will be trimmed from the
  5321. * ends of the string. If sattr is NULL, the type will be used to look
  5322. * up the attribute syntax. If sattr is not NULL, type is ignored. If
  5323. * retval is set, the caller is responsible for freeing it.
  5324. *
  5325. * \param pb Slapi_PBlock to use
  5326. * \param sattr attribute to get the syntax from
  5327. * \param type attribute to get the syntax from if sattr is NULL
  5328. * \param val value to normalize in place - must be NULL terminated
  5329. * \param trim_spaces trim whitespace from ends of string
  5330. * \param retval if value could not be normalized in place, this is the malloc'd memory containg the new value - caller must free
  5331. */
  5332. void slapi_attr_value_normalize(
  5333. Slapi_PBlock *pb,
  5334. const Slapi_Attr *sattr, /* if sattr is NULL, type must be attr type name */
  5335. const char *type,
  5336. char *val,
  5337. int trim_spaces,
  5338. char **retval
  5339. );
  5340. /**
  5341. * Normalize the given value using the matching rule associated with the
  5342. * given attribute and given filter type. It will attempt to normalize
  5343. * the value in place. If it cannot, it will return the normalized value
  5344. * in retval. If trim_spaces is true, whitepace characters will be trimmed
  5345. * from the ends of the string. If sattr is NULL, the type will be used to look
  5346. * up the attribute syntax. If sattr is not NULL, type is ignored. If
  5347. * retval is set, the caller is responsible for freeing it. The filter_type
  5348. * corresponds to the matching rule to use - LDAP_FILTER_GE or LDAP_FILTER_LE
  5349. * will use the ORDERING matching rule normalization function - LDAP_FILTER_EQUALITY
  5350. * will use the EQUALITY matching rule normalization function - LDAP_FILTER_SUBSTRINGS
  5351. * will use the SUBSTRINGS matching rule normalization function. If the given
  5352. * filter_type is 0, or some other value other than specified above, or there is no
  5353. * matching rule corresponding to the given filter type, the default normalization
  5354. * function provided by the attribute syntax will be used.
  5355. *
  5356. * \param pb Slapi_PBlock to use
  5357. * \param sattr attribute to get the syntax from
  5358. * \param type attribute to get the syntax from if sattr is NULL
  5359. * \param val value to normalize in place - must be NULL terminated
  5360. * \param trim_spaces trim whitespace from ends of string
  5361. * \param retval if value could not be normalized in place, this is the malloc'd memory containg the new value - caller must free
  5362. * \param filter_type one of the values specified above, or 0
  5363. */
  5364. void slapi_attr_value_normalize_ext(
  5365. Slapi_PBlock *pb,
  5366. const Slapi_Attr *sattr, /* if sattr is NULL, type must be attr type name */
  5367. const char *type,
  5368. char *val,
  5369. int trim_spaces,
  5370. char **retval,
  5371. unsigned long filter_type
  5372. );
  5373. /*
  5374. * internal operation and plugin callback routines
  5375. */
  5376. typedef void (*plugin_result_callback)(int rc, void *callback_data);
  5377. typedef int (*plugin_referral_entry_callback)(char * referral,
  5378. void *callback_data);
  5379. typedef int (*plugin_search_entry_callback)(Slapi_Entry *e,
  5380. void *callback_data);
  5381. void slapi_free_search_results_internal(Slapi_PBlock *pb);
  5382. /*
  5383. * The following functions can be used for internal operations based on DN
  5384. * as well as on uniqueid. These functions should be used by all new plugins
  5385. * and preferrably old plugins should be changed to use them to take
  5386. * advantage of new plugin configuration capabilities and to use an
  5387. * extensible interface.
  5388. *
  5389. * These functions return -1 if pb is NULL and 0 otherwise.
  5390. * The SLAPI_PLUGIN_INTOP_RESULT pblock parameter should be checked to
  5391. * check if the operation was successful.
  5392. *
  5393. * Helper functions are provided to set up pblock parameters currently used
  5394. * by the functions, e.g., slapi_search_internal_set_pb().
  5395. * Additional parameters may be set directly in the pblock.
  5396. */
  5397. int slapi_search_internal_pb(Slapi_PBlock *pb);
  5398. int slapi_search_internal_callback_pb(Slapi_PBlock *pb, void *callback_data,
  5399. plugin_result_callback prc, plugin_search_entry_callback psec,
  5400. plugin_referral_entry_callback prec);
  5401. int slapi_add_internal_pb(Slapi_PBlock *pb);
  5402. int slapi_modify_internal_pb(Slapi_PBlock *pb);
  5403. int slapi_modrdn_internal_pb(Slapi_PBlock *pb);
  5404. int slapi_delete_internal_pb(Slapi_PBlock *pb);
  5405. int slapi_seq_internal_callback_pb(Slapi_PBlock *pb, void *callback_data,
  5406. plugin_result_callback res_callback,
  5407. plugin_search_entry_callback srch_callback,
  5408. plugin_referral_entry_callback ref_callback);
  5409. void slapi_search_internal_set_pb(Slapi_PBlock *pb, const char *base,
  5410. int scope, const char *filter, char **attrs, int attrsonly,
  5411. LDAPControl **controls, const char *uniqueid,
  5412. Slapi_ComponentId *plugin_identity, int operation_flags);
  5413. void slapi_search_internal_set_pb_ext(Slapi_PBlock *pb, Slapi_DN *sdn,
  5414. int scope, const char *filter, char **attrs, int attrsonly,
  5415. LDAPControl **controls, const char *uniqueid,
  5416. Slapi_ComponentId *plugin_identity, int operation_flags);
  5417. void slapi_add_entry_internal_set_pb(Slapi_PBlock *pb, Slapi_Entry *e,
  5418. LDAPControl **controls, Slapi_ComponentId *plugin_identity,
  5419. int operation_flags);
  5420. int slapi_add_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  5421. LDAPMod **attrs, LDAPControl **controls,
  5422. Slapi_ComponentId *plugin_identity, int operation_flags);
  5423. void slapi_modify_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  5424. LDAPMod **mods, LDAPControl **controls, const char *uniqueid,
  5425. Slapi_ComponentId *plugin_identity, int operation_flags);
  5426. void slapi_modify_internal_set_pb_ext(Slapi_PBlock *pb, const Slapi_DN *sdn,
  5427. LDAPMod **mods, LDAPControl **controls, const char *uniqueid,
  5428. Slapi_ComponentId *plugin_identity, int operation_flags);
  5429. /**
  5430. * Set \c Slapi_PBlock to perform modrdn/rename internally
  5431. *
  5432. * \param pblock - Slapi_PBlock to be set
  5433. * \param olddn - original dn to be renamed; it should have been normalized
  5434. * \param newrdn - new leaf rdn if any; it should have been normalized
  5435. * \param newsuperior - new parent dn if any; it should have been normalized
  5436. * \param deloldrdn \c 0 - keep original rdn \c non-zero - delete original rdn
  5437. * \param controls
  5438. * \param uniqueid
  5439. * \param plugin_identity
  5440. * \param operation_flags
  5441. */
  5442. void slapi_rename_internal_set_pb_ext(Slapi_PBlock *pb,
  5443. const Slapi_DN *olddn, const char *newrdn,
  5444. const Slapi_DN *newsuperior, int deloldrdn,
  5445. LDAPControl **controls, const char *uniqueid,
  5446. Slapi_ComponentId *plugin_identity, int operation_flags);
  5447. void slapi_delete_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  5448. LDAPControl **controls, const char *uniqueid,
  5449. Slapi_ComponentId *plugin_identity, int operation_flags);
  5450. void slapi_seq_internal_set_pb(Slapi_PBlock *pb, char *ibase, int type,
  5451. char *attrname, char *val, char **attrs, int attrsonly,
  5452. LDAPControl **controls, Slapi_ComponentId *plugin_identity,
  5453. int operation_flags);
  5454. /*
  5455. * slapi_search_internal_get_entry() finds an entry given a dn. It returns
  5456. * an LDAP error code (LDAP_SUCCESS if all goes well).
  5457. */
  5458. int slapi_search_internal_get_entry( Slapi_DN *dn, char ** attrlist,
  5459. Slapi_Entry **ret_entry , void *caller_identity);
  5460. /*
  5461. * interface for registering object extensions.
  5462. */
  5463. typedef void *(*slapi_extension_constructor_fnptr)(void *object, void *parent);
  5464. typedef void (*slapi_extension_destructor_fnptr)(void *extension,
  5465. void *object, void *parent);
  5466. int slapi_register_object_extension( const char *pluginname,
  5467. const char *objectname, slapi_extension_constructor_fnptr constructor,
  5468. slapi_extension_destructor_fnptr destructor, int *objecttype,
  5469. int *extensionhandle);
  5470. /* objects that can be extended (possible values for the objectname param.) */
  5471. #define SLAPI_EXT_CONNECTION "Connection"
  5472. #define SLAPI_EXT_OPERATION "Operation"
  5473. #define SLAPI_EXT_ENTRY "Entry"
  5474. #define SLAPI_EXT_MTNODE "Mapping Tree Node"
  5475. /* Module names for SLAPI_EXT_ENTRY */
  5476. #define SLAPI_EXTMOD_PWPOLICY "Password Policy"
  5477. /* Object names in SLAPI_EXT_ENTRY */
  5478. #define SLAPI_EXTOBJ_ENTRY_PW "UnhashedPW"
  5479. void *slapi_get_object_extension(int objecttype, void *object,
  5480. int extensionhandle);
  5481. void slapi_set_object_extension(int objecttype, void *object,
  5482. int extensionhandle, void *extension);
  5483. /*
  5484. * interface to allow a plugin to register additional plugins.
  5485. */
  5486. typedef int (*slapi_plugin_init_fnptr)( Slapi_PBlock *pb );
  5487. int slapi_register_plugin( const char *plugintype, int enabled,
  5488. const char *initsymbol, slapi_plugin_init_fnptr initfunc,
  5489. const char *name, char **argv, void *group_identity);
  5490. int slapi_register_plugin_ext( const char *plugintype, int enabled,
  5491. const char *initsymbol, slapi_plugin_init_fnptr initfunc,
  5492. const char *name, char **argv, void *group_identity, int precedence);
  5493. /*
  5494. * logging
  5495. */
  5496. int slapi_log_error( int severity, char *subsystem, char *fmt, ... )
  5497. #ifdef __GNUC__
  5498. __attribute__ ((format (printf, 3, 4)));
  5499. #else
  5500. ;
  5501. #endif
  5502. int slapi_log_error_ext( int severity, char *subsystem, char *fmt, va_list varg1, va_list varg2);
  5503. /* allowed values for the "severity" parameter */
  5504. #define SLAPI_LOG_FATAL 0
  5505. #define SLAPI_LOG_TRACE 1
  5506. #define SLAPI_LOG_PACKETS 2
  5507. #define SLAPI_LOG_ARGS 3
  5508. #define SLAPI_LOG_CONNS 4
  5509. #define SLAPI_LOG_BER 5
  5510. #define SLAPI_LOG_FILTER 6
  5511. #define SLAPI_LOG_CONFIG 7
  5512. #define SLAPI_LOG_ACL 8
  5513. #define SLAPI_LOG_SHELL 9
  5514. #define SLAPI_LOG_PARSE 10
  5515. #define SLAPI_LOG_HOUSE 11
  5516. #define SLAPI_LOG_REPL 12
  5517. #define SLAPI_LOG_CACHE 13
  5518. #define SLAPI_LOG_PLUGIN 14
  5519. #define SLAPI_LOG_TIMING 15
  5520. #define SLAPI_LOG_BACKLDBM 16
  5521. #define SLAPI_LOG_ACLSUMMARY 17 /* ACLSUMMARY must be the last (log.c) */
  5522. int slapi_is_loglevel_set( const int loglevel );
  5523. /*
  5524. * locks and synchronization
  5525. */
  5526. typedef struct slapi_mutex Slapi_Mutex;
  5527. typedef struct slapi_condvar Slapi_CondVar;
  5528. #ifdef USE_POSIX_RWLOCKS
  5529. typedef pthread_rwlock_t Slapi_RWLock;
  5530. #else
  5531. typedef struct slapi_rwlock Slapi_RWLock;
  5532. #endif
  5533. Slapi_Mutex *slapi_new_mutex( void );
  5534. void slapi_destroy_mutex( Slapi_Mutex *mutex );
  5535. void slapi_lock_mutex( Slapi_Mutex *mutex );
  5536. int slapi_unlock_mutex( Slapi_Mutex *mutex );
  5537. Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex );
  5538. void slapi_destroy_condvar( Slapi_CondVar *cvar );
  5539. int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout );
  5540. int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all );
  5541. /**
  5542. * Creates a new read/write lock.
  5543. *
  5544. * \return A pointer to a \c Slapi_RWLock
  5545. *
  5546. * \note Free the returned lock by calling slapi_destroy_rwlock() when finished
  5547. *
  5548. * \see slapi_destroy_rwlock()
  5549. * \see slapi_rwlock_rdlock()
  5550. * \see slapi_rwlock_wrlock()
  5551. * \see slapi_rwlock_unlock()
  5552. */
  5553. Slapi_RWLock *slapi_new_rwlock( void );
  5554. /**
  5555. * Free a read/write lock
  5556. *
  5557. * \see slapi_new_rwlock()
  5558. */
  5559. void slapi_destroy_rwlock( Slapi_RWLock *rwlock );
  5560. /**
  5561. * Acquires a reader lock
  5562. *
  5563. * \return 0 if successful
  5564. * \return Non-zero if an error occurred
  5565. *
  5566. * \note Release the acquired lock by calling slapi_rwlock_unlock()
  5567. * \note It is safe for a thread to hold multiple reader locks, but
  5568. * you must call slapi_rwlock_unlock() for each aquired lock.
  5569. *
  5570. * \see slapi_rwlock_unlock()
  5571. */
  5572. int slapi_rwlock_rdlock( Slapi_RWLock *rwlock );
  5573. /**
  5574. * Acquires a writer lock
  5575. *
  5576. * \return 0 if successful
  5577. * \return Non-zero if an error occurred
  5578. *
  5579. * \note Release the acquired lock by calling slapi_rwlock_unlock()
  5580. *
  5581. * \see slapi_rwlock_unlock()
  5582. */
  5583. int slapi_rwlock_wrlock( Slapi_RWLock *rwlock );
  5584. /**
  5585. * Releases a reader or writer lock
  5586. *
  5587. * \return 0 if successful
  5588. * \return Non-zero if an error occurred
  5589. *
  5590. * \see slapi_rwlock_rdlock()
  5591. * \see slapi_rwlock_wrlock()
  5592. */
  5593. int slapi_rwlock_unlock( Slapi_RWLock *rwlock );
  5594. /*
  5595. * thread-safe LDAP connections
  5596. */
  5597. /**
  5598. * Initializes an LDAP connection, and returns a handle to the connection.
  5599. *
  5600. * \param ldaphost Hostname or IP address - NOTE: for TLS or GSSAPI, should be the FQDN
  5601. * \param ldapport LDAP server port number (default 389)
  5602. * \param secure \c 0 - LDAP \c 1 - LDAPS \c 2 - startTLS
  5603. * \param shared \c 0 - single thread access \c 1 - LDAP* will be shared among multiple threads
  5604. * \return A pointer to an LDAP* handle
  5605. *
  5606. * \note Use #slapi_ldap_unbind() to close and free the handle
  5607. *
  5608. * \see slapi_ldap_unbind()
  5609. * \see slapi_ldap_init_ext()
  5610. */
  5611. LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared );
  5612. /**
  5613. * Closes an LDAP connection, and frees memory associated with the handle
  5614. *
  5615. * \param ld the LDAP connection handle
  5616. *
  5617. * \see slapi_ldap_init()
  5618. * \see slapi_ldap_init_ext()
  5619. */
  5620. void slapi_ldap_unbind( LDAP *ld );
  5621. /**
  5622. * Initializes an LDAP connection, and returns a handle to the connection.
  5623. *
  5624. * \param ldapurl A full LDAP url in the form ldap[s]://hostname:port or
  5625. * ldapi://path - if \c NULL, #hostname, #port, and #secure must be provided
  5626. * \param hostname Hostname or IP address - NOTE: for TLS or GSSAPI, should be the FQDN
  5627. * \param port LDAP server port number (default 389)
  5628. * \param secure \c 0 - LDAP \c 1 - LDAPS \c 2 - startTLS
  5629. * \param shared \c 0 - single thread access \c 1 - LDAP* will be shared among multiple threads
  5630. * \param filename - currently not supported
  5631. * \return A pointer to an LDAP* handle
  5632. *
  5633. * \note Use #slapi_ldap_unbind() to close and free the handle
  5634. *
  5635. * \see slapi_ldap_unbind()
  5636. * \see slapi_ldap_init()
  5637. */
  5638. LDAP *slapi_ldap_init_ext(
  5639. const char *ldapurl, /* full ldap url */
  5640. const char *hostname, /* can also use this to override
  5641. host in url */
  5642. int port, /* can also use this to override port in url */
  5643. int secure, /* 0 for ldap, 1 for ldaps, 2 for starttls -
  5644. override proto in url */
  5645. int shared, /* if true, LDAP* will be shared among multiple threads */
  5646. const char *filename /* for ldapi */
  5647. );
  5648. /**
  5649. * The LDAP bind request - this function handles all of the different types of mechanisms
  5650. * including simple, sasl, and external (client cert auth)
  5651. *
  5652. * \param ld the LDAP connection handle
  5653. * \param bindid Either a bind DN for simple bind or a SASL identity
  5654. * \param creds usually a password for simple bind or SASL credentials
  5655. * \param mech a valid mech that can be passed to ldap_sasl_bind (or NULL for simple)
  5656. * \param serverctrls optional controls to send (or NULL)
  5657. * \param returnedctrls optional controls returned by the server - use NULL if you just
  5658. * want to ignore them - if you pass in a variable for this, you
  5659. * are responsible for freeing the result (ldap_controls_free)
  5660. * \param timeout timeout or NULL for no timeout (wait forever)
  5661. * \param msgidp LDAP message ID \c NULL - call bind synchronously \c non-NULL -
  5662. * call bind asynchronously - you are responsible for calling ldap_result
  5663. * to read the response
  5664. * \return an LDAP error code
  5665. *
  5666. * \see ldap_sasl_bind()
  5667. * \see ldap_sasl_bind_s()
  5668. * \see ldap_controls_free()
  5669. * \see ldap_result()
  5670. */
  5671. int slapi_ldap_bind(
  5672. LDAP *ld, /* ldap connection */
  5673. const char *bindid, /* usually a bind DN for simple bind */
  5674. const char *creds, /* usually a password for simple bind */
  5675. const char *mech, /* name of mechanism */
  5676. LDAPControl **serverctrls, /* additional controls to send */
  5677. LDAPControl ***returnedctrls, /* returned controls */
  5678. struct timeval *timeout, /* timeout */
  5679. int *msgidp /* pass in non-NULL for async handling */
  5680. );
  5681. /**
  5682. * Create either a v1 Proxy Auth Control or a v2 Proxied Auth Control
  5683. *
  5684. * \param ld the LDAP connection handle
  5685. * \param dn The proxy DN
  5686. * \param creds usually a password for simple bind or SASL credentials
  5687. * \param ctl_iscritical \c 0 - not critical \c 1 - critical
  5688. * \param usev2 \c 0 - use the v1 Proxy Auth \c 1 - use the v2 Proxied Auth
  5689. * \param ctrlp the control to send - caller is responsible for freeing (ldap_control_free)
  5690. * \return an LDAP error code
  5691. *
  5692. * \see ldap_control_free()
  5693. */
  5694. int slapi_ldap_create_proxyauth_control (
  5695. LDAP *ld, /* only used to get current ber options */
  5696. const char *dn, /* proxy dn */
  5697. const char ctl_iscritical,
  5698. int usev2, /* use the v2 (.18) control instead */
  5699. LDAPControl **ctrlp /* value to return */
  5700. );
  5701. /**
  5702. * Parse a line from an LDIF record returned by ldif_getline() and return the LDAP
  5703. * attribute type and value from the line. ldif_getline() will encode the LDIF continuation
  5704. * lines, and slapi_ldif_parse_line() will take those into consideration when returning the
  5705. * value.
  5706. *
  5707. * \param line LDIF record line returned by ldif_getline()
  5708. * \param type The attribute type returned
  5709. * \param value The attribute value returned
  5710. * \param freeval \c NULL - use malloc for the value->bv_val - caller is responsible for freeing
  5711. * \c an int* - slapi_ldif_parse_line will usually return pointers into the line
  5712. * parameter that should not be freed - if slapi_ldif_parse_line needs to allocate
  5713. * memory for the value, *freeval will be set to 1 to indicate the caller must
  5714. * free value->bv_val
  5715. * \return \c 0 - success \c 1 - failure
  5716. *
  5717. * \note line is written to - you must pass in writable memory - line must be NULL terminated
  5718. *
  5719. * \see ldif_getline()
  5720. */
  5721. int slapi_ldif_parse_line(
  5722. char *line, /* line to parse */
  5723. struct berval *type, /* attribute type to return */
  5724. struct berval *value, /* attribute value to return */
  5725. int *freeval /* values will usually be returned in place as pointers into line - if the value is a url, the value will be malloced and must be freed by the caller */
  5726. );
  5727. /**
  5728. * Parse an LDAP DN string. Return an array of RDN strings, terminated by a NULL. This
  5729. * function differs from the standard openldap ldap_explode_dn, which will escape utf-8
  5730. * characters. In the directory server, we do not want to escape them. The caller
  5731. * should use slapi_ldap_value_free to free the returned memory when finished.
  5732. *
  5733. * \param dn The LDAP DN
  5734. * \param notypes set to true (1) to return only the attribute values with no attribute types
  5735. * \return \c An array of RDN strings - use slapi_ch_array_free to free
  5736. *
  5737. * \see slapi_ldap_value_free()
  5738. */
  5739. char **slapi_ldap_explode_dn(
  5740. const char *dn, /* dn to explode */
  5741. int notypes /* set to true to return only the values with no types */
  5742. );
  5743. /**
  5744. * Parse an LDAP RDN string. Return an array of AVA strings, terminated by a NULL. This
  5745. * function differs from the standard openldap ldap_explode_rdn, which will escape utf-8
  5746. * characters. In the directory server, we do not want to escape them. The caller
  5747. * should use slapi_ldap_value_free to free the returned memory when finished.
  5748. *
  5749. * \param dn The LDAP RDN
  5750. * \param notypes set to true (1) to return only the attribute values with no attribute types
  5751. * \return \c An array of AVA strings - use slapi_ch_array_free to free
  5752. *
  5753. * \see slapi_ldap_value_free()
  5754. */
  5755. char **slapi_ldap_explode_rdn(
  5756. const char *rdn, /* rdn to explode */
  5757. int notypes /* set to true to return only the values with no types */
  5758. );
  5759. /*
  5760. * computed attributes
  5761. */
  5762. struct _computed_attr_context;
  5763. typedef struct _computed_attr_context computed_attr_context;
  5764. typedef int (*slapi_compute_output_t)(computed_attr_context *c,Slapi_Attr *a , Slapi_Entry *e);
  5765. typedef int (*slapi_compute_callback_t)(computed_attr_context *c,char* type,Slapi_Entry *e,slapi_compute_output_t outputfn);
  5766. typedef int (*slapi_search_rewrite_callback_t)(Slapi_PBlock *pb);
  5767. int slapi_compute_add_evaluator(slapi_compute_callback_t function);
  5768. int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function);
  5769. int compute_rewrite_search_filter(Slapi_PBlock *pb);
  5770. /*
  5771. * routines for dealing with backends
  5772. */
  5773. Slapi_Backend *slapi_be_new( const char *type, const char *name,
  5774. int isprivate, int logchanges );
  5775. void slapi_be_free(Slapi_Backend **be);
  5776. Slapi_Backend *slapi_be_select( const Slapi_DN *sdn );
  5777. Slapi_Backend *slapi_be_select_by_instance_name( const char *name );
  5778. int slapi_be_exist(const Slapi_DN *sdn);
  5779. void slapi_be_delete_onexit(Slapi_Backend *be);
  5780. void slapi_be_set_readonly(Slapi_Backend *be, int readonly);
  5781. int slapi_be_get_readonly(Slapi_Backend *be);
  5782. int slapi_be_getentrypoint(Slapi_Backend *be, int entrypoint, void **ret_fnptr,
  5783. Slapi_PBlock *pb);
  5784. int slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr,
  5785. Slapi_PBlock *pb);
  5786. int slapi_be_logchanges(Slapi_Backend *be);
  5787. int slapi_be_issuffix(const Slapi_Backend *be, const Slapi_DN *suffix );
  5788. void slapi_be_addsuffix(Slapi_Backend *be,const Slapi_DN *suffix);
  5789. char * slapi_be_get_name(Slapi_Backend * be);
  5790. const Slapi_DN *slapi_be_getsuffix(Slapi_Backend *be, int n);
  5791. Slapi_Backend* slapi_get_first_backend(char **cookie);
  5792. Slapi_Backend* slapi_get_next_backend(char *cookie);
  5793. int slapi_be_private( Slapi_Backend *be );
  5794. void * slapi_be_get_instance_info(Slapi_Backend * be);
  5795. void slapi_be_set_instance_info(Slapi_Backend * be, void * data);
  5796. Slapi_DN * slapi_get_first_suffix(void ** node, int show_private);
  5797. Slapi_DN * slapi_get_next_suffix(void ** node, int show_private);
  5798. Slapi_DN * slapi_get_next_suffix_ext(void ** node, int show_private);
  5799. int slapi_is_root_suffix(Slapi_DN * dn);
  5800. const Slapi_DN *slapi_get_suffix_by_dn(const Slapi_DN *dn);
  5801. const char * slapi_be_gettype(Slapi_Backend *be);
  5802. /**
  5803. * Start database transaction
  5804. *
  5805. * \param pb Pblock which is supposed to set (Slapi_Backend *) to SLAPI_BACKEND
  5806. * \return 0 if successful
  5807. * \return SLAPI_BACK_TRANSACTION_NOT_SUPPORTED if transaction support is not available for this backend
  5808. * \return Non-zero if an error occurred
  5809. *
  5810. * \see slapi_back_transaction_commit
  5811. * \see slapi_back_transaction_abort
  5812. */
  5813. int slapi_back_transaction_begin(Slapi_PBlock *pb);
  5814. /**
  5815. * Commit database transaction
  5816. *
  5817. * \param pb Pblock which is used to start transaction
  5818. * \return 0 if successful
  5819. * \return Non-zero if an error occurred
  5820. *
  5821. * \see slapi_back_transaction_start
  5822. * \see slapi_back_transaction_abort
  5823. */
  5824. int slapi_back_transaction_commit(Slapi_PBlock *pb);
  5825. /**
  5826. * Abort database transaction
  5827. *
  5828. * \param pb Pblock which is used to start transaction
  5829. * \return 0 if successful
  5830. * \return Non-zero if an error occurred
  5831. *
  5832. * \see slapi_back_transaction_commit
  5833. * \see slapi_back_transaction_abort
  5834. */
  5835. int slapi_back_transaction_abort(Slapi_PBlock *pb);
  5836. /**
  5837. * Checks if the connection type is LDAPI
  5838. *
  5839. * \param pb Parameter block.
  5840. *
  5841. * \return \c 1 if connection type is LDAPI
  5842. * \return \c 0 if connection is not LDAPI
  5843. */
  5844. int slapi_is_ldapi_conn(Slapi_PBlock *pb);
  5845. int slapi_be_is_flag_set(Slapi_Backend * be, int flag);
  5846. void slapi_be_set_flag(Slapi_Backend * be, int flag);
  5847. #define SLAPI_BE_FLAG_REMOTE_DATA 0x1 /* entries held by backend are remote */
  5848. #define SLAPI_BE_FLAG_DONT_BYPASS_FILTERTEST 0x10 /* force to call filter_test (search only) */
  5849. /* These functions allow a plugin to register for callback when
  5850. * a backend state change
  5851. */
  5852. typedef void (*slapi_backend_state_change_fnptr)(void *handle, char *be_name,
  5853. int old_be_state, int new_be_state);
  5854. void slapi_register_backend_state_change(void * handle, slapi_backend_state_change_fnptr funct);
  5855. int slapi_unregister_backend_state_change(void * handle);
  5856. #define SLAPI_BE_STATE_ON 1 /* backend is ON */
  5857. #define SLAPI_BE_STATE_OFFLINE 2 /* backend is OFFLINE (import process) */
  5858. #define SLAPI_BE_STATE_DELETE 3 /* backend has been deleted */
  5859. /*
  5860. * Distribution.
  5861. */
  5862. /* SLAPI_BE_ALL_BACKENDS is a special value that is returned by
  5863. * a distribution plugin function to indicate that all backends
  5864. * should be searched (it is only used for search operations).
  5865. *
  5866. * SLAPI_BE_NO_BACKEND indicates no more backend is available or allowed
  5867. * SLAPI_BE_REMOTE_BACKEND indicates that the are not locally available
  5868. */
  5869. #define SLAPI_BE_ALL_BACKENDS -1
  5870. #define SLAPI_BE_NO_BACKEND -2
  5871. #define SLAPI_BE_REMOTE_BACKEND -3
  5872. /*
  5873. * virtual attribute service
  5874. */
  5875. /* General flags (flags parameter) */
  5876. #define SLAPI_REALATTRS_ONLY 1
  5877. #define SLAPI_VIRTUALATTRS_ONLY 2
  5878. #define SLAPI_VIRTUALATTRS_REQUEST_POINTERS 4 /* I want to receive pointers into the entry, if possible */
  5879. #define SLAPI_VIRTUALATTRS_LIST_OPERATIONAL_ATTRS 8 /* Include operational attributes in attribute lists */
  5880. #define SLAPI_VIRTUALATTRS_SUPPRESS_SUBTYPES 16 /* I want only the requested attribute */
  5881. /* Buffer disposition flags (buffer_flags parameter) */
  5882. #define SLAPI_VIRTUALATTRS_RETURNED_POINTERS 1
  5883. #define SLAPI_VIRTUALATTRS_RETURNED_COPIES 2
  5884. #define SLAPI_VIRTUALATTRS_REALATTRS_ONLY 4
  5885. #define SLAPI_VIRTUALATTRS_VALUES_CACHEABLE 8
  5886. /* Attribute type name disposition values (type_name_disposition parameter) */
  5887. #define SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_EXACTLY_OR_ALIAS 1
  5888. #define SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_SUBTYPE 2
  5889. #define SLAPI_VIRTUALATTRS_NOT_FOUND -1
  5890. #define SLAPI_VIRTUALATTRS_LOOP_DETECTED -2
  5891. typedef struct _vattr_type_thang vattr_type_thang;
  5892. typedef struct _vattr_get_thang vattr_get_thang;
  5893. vattr_get_thang *slapi_vattr_getthang_first(vattr_get_thang *t);
  5894. vattr_get_thang *slapi_vattr_getthang_next(vattr_get_thang *t);
  5895. int slapi_vattr_values_type_thang_get(
  5896. /* Entry we're interested in */ Slapi_Entry *e,
  5897. /* attr type */ vattr_type_thang *type_thang,
  5898. /* pointer to result set */ Slapi_ValueSet** results,
  5899. int *type_name_disposition, char **actual_type_name, int flags,
  5900. int *buffer_flags);
  5901. int slapi_vattr_values_get(
  5902. /* Entry we're interested in */ Slapi_Entry *e,
  5903. /* attr type name */ char *type,
  5904. /* pointer to result set */ Slapi_ValueSet** results,
  5905. int *type_name_disposition, char **actual_type_name, int flags,
  5906. int *buffer_flags);
  5907. int slapi_vattr_values_get_ex(
  5908. /* Entry we're interested in */ Slapi_Entry *e,
  5909. /* attr type name */ char *type,
  5910. /* pointer to result set */ Slapi_ValueSet*** results,
  5911. int **type_name_disposition, char ***actual_type_name, int flags,
  5912. int *buffer_flags, int *subtype_count);
  5913. int slapi_vattr_namespace_values_get(
  5914. /* Entry we're interested in */ Slapi_Entry *e,
  5915. /* backend namespace dn */ Slapi_DN *namespace_dn,
  5916. /* attr type name */ char *type,
  5917. /* pointer to result set */ Slapi_ValueSet*** results,
  5918. int **type_name_disposition, char ***actual_type_name, int flags,
  5919. int *buffer_flags, int *subtype_count);
  5920. void slapi_vattr_values_free(Slapi_ValueSet **value, char **actual_type_name,
  5921. int flags);
  5922. int slapi_vattr_value_compare(
  5923. /* Entry we're interested in */ Slapi_Entry *e,
  5924. /* attr type name */ char *type,
  5925. Slapi_Value *test_this,/* pointer to result */ int *result,
  5926. int flags);
  5927. int slapi_vattr_namespace_value_compare(
  5928. /* Entry we're interested in */ Slapi_Entry *e,
  5929. /* backend namespace dn */ Slapi_DN *namespace_dn,
  5930. /* attr type name */ const char *type,
  5931. Slapi_Value *test_this,/* pointer to result */ int *result,
  5932. int flags);
  5933. int slapi_vattr_list_attrs(
  5934. /* Entry we're interested in */ Slapi_Entry *e,
  5935. /* pointer to receive the list */ vattr_type_thang **types,
  5936. int flags, int *buffer_flags);
  5937. void slapi_vattr_attrs_free(vattr_type_thang **types, int flags);
  5938. char *vattr_typethang_get_name(vattr_type_thang *t);
  5939. unsigned long vattr_typethang_get_flags(vattr_type_thang *t);
  5940. vattr_type_thang *vattr_typethang_next(vattr_type_thang *t);
  5941. vattr_type_thang *vattr_typethang_first(vattr_type_thang *t);
  5942. int slapi_vattr_schema_check_type(Slapi_Entry *e, char *type);
  5943. /* roles */
  5944. typedef int (*roles_check_fn_type)(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present);
  5945. int slapi_role_check(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present);
  5946. void slapi_register_role_check(roles_check_fn_type check_fn);
  5947. /* DSE */
  5948. /* Front end configuration */
  5949. typedef int (*dseCallbackFn)(Slapi_PBlock *, Slapi_Entry *, Slapi_Entry *,
  5950. int *, char*, void *);
  5951. /*
  5952. * Note: DSE callback functions MUST return one of these three values:
  5953. *
  5954. * SLAPI_DSE_CALLBACK_OK -- no errors occurred; apply changes.
  5955. * SLAPI_DSE_CALLBACK_ERROR -- an error occurred; don't apply changes.
  5956. * SLAPI_DSE_CALLBACK_DO_NOT_APPLY -- no error, but do not apply changes.
  5957. *
  5958. * SLAPI_DSE_CALLBACK_DO_NOT_APPLY should only be returned by modify
  5959. * callbacks (i.e., those registered with operation==SLAPI_OPERATION_MODIFY).
  5960. * A return value of SLAPI_DSE_CALLBACK_DO_NOT_APPLY is treated the same as
  5961. * SLAPI_DSE_CALLBACK_ERROR for all other operations.
  5962. */
  5963. #define SLAPI_DSE_CALLBACK_OK (1)
  5964. #define SLAPI_DSE_CALLBACK_ERROR (-1)
  5965. #define SLAPI_DSE_CALLBACK_DO_NOT_APPLY (0)
  5966. /*
  5967. * Flags for slapi_config_register_callback() and
  5968. * slapi_config_remove_callback()
  5969. */
  5970. #define DSE_FLAG_PREOP 0x0001
  5971. #define DSE_FLAG_POSTOP 0x0002
  5972. /* This is the size of the returntext parameter passed to the config callback function,
  5973. which is the "char *" argument to dseCallbackFn above */
  5974. #define SLAPI_DSE_RETURNTEXT_SIZE 512 /* for use by callback functions */
  5975. int slapi_config_register_callback(int operation, int flags, const char *base, int scope, const char *filter, dseCallbackFn fn, void *fn_arg);
  5976. int slapi_config_remove_callback(int operation, int flags, const char *base, int scope, const char *filter, dseCallbackFn fn);
  5977. /******************************************************************************
  5978. * Online tasks interface (to support import, export, etc)
  5979. * After some cleanup, we could consider making these public.
  5980. */
  5981. /* task states */
  5982. #define SLAPI_TASK_SETUP 0
  5983. #define SLAPI_TASK_RUNNING 1
  5984. #define SLAPI_TASK_FINISHED 2
  5985. #define SLAPI_TASK_CANCELLED 3
  5986. /* task flag (pb_task_flags)*/
  5987. #define SLAPI_TASK_RUNNING_AS_TASK 0x0
  5988. #define SLAPI_TASK_RUNNING_FROM_COMMANDLINE 0x1
  5989. /* task flags (set by the task-control code) */
  5990. #define SLAPI_TASK_DESTROYING 0x01 /* queued event for destruction */
  5991. int slapi_task_register_handler(const char *name, dseCallbackFn func);
  5992. void slapi_task_begin(Slapi_Task *task, int total_work);
  5993. void slapi_task_inc_progress(Slapi_Task *task);
  5994. void slapi_task_finish(Slapi_Task *task, int rc);
  5995. void slapi_task_cancel(Slapi_Task *task, int rc);
  5996. int slapi_task_get_state(Slapi_Task *task);
  5997. void slapi_task_set_data(Slapi_Task *task, void *data);
  5998. void * slapi_task_get_data(Slapi_Task *task);
  5999. void slapi_task_inc_refcount(Slapi_Task *task);
  6000. void slapi_task_dec_refcount(Slapi_Task *task);
  6001. int slapi_task_get_refcount(Slapi_Task *task);
  6002. void slapi_task_set_destructor_fn(Slapi_Task *task, TaskCallbackFn func);
  6003. void slapi_task_set_cancel_fn(Slapi_Task *task, TaskCallbackFn func);
  6004. void slapi_task_status_changed(Slapi_Task *task);
  6005. void slapi_task_log_status(Slapi_Task *task, char *format, ...)
  6006. #ifdef __GNUC__
  6007. __attribute__ ((format (printf, 2, 3)));
  6008. #else
  6009. ;
  6010. #endif
  6011. void slapi_task_log_notice(Slapi_Task *task, char *format, ...)
  6012. #ifdef __GNUC__
  6013. __attribute__ ((format (printf, 2, 3)));
  6014. #else
  6015. ;
  6016. #endif
  6017. void slapi_task_log_status_ext(Slapi_Task *task, char *format, va_list varg);
  6018. void slapi_task_log_notice_ext(Slapi_Task *task, char *format, va_list varg);
  6019. /*
  6020. * slapi_new_task: create new task, fill in DN, and setup modify callback
  6021. * argument:
  6022. * dn: task dn
  6023. * result:
  6024. * Success: Slapi_Task object
  6025. * Failure: NULL
  6026. */
  6027. Slapi_Task *slapi_new_task(const char *dn);
  6028. /* slapi_destroy_task: destroy a task
  6029. * argument:
  6030. * task: task to destroy
  6031. * result:
  6032. * none
  6033. */
  6034. void slapi_destroy_task(void *arg);
  6035. /* End of interface to support online tasks **********************************/
  6036. /* Slapi_Counter Interface */
  6037. Slapi_Counter *slapi_counter_new(void);
  6038. void slapi_counter_init(Slapi_Counter *counter);
  6039. void slapi_counter_destroy(Slapi_Counter **counter);
  6040. PRUint64 slapi_counter_increment(Slapi_Counter *counter);
  6041. PRUint64 slapi_counter_decrement(Slapi_Counter *counter);
  6042. PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue);
  6043. PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue);
  6044. PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue);
  6045. PRUint64 slapi_counter_get_value(Slapi_Counter *counter);
  6046. /* Binder-based (connection centric) resource limits */
  6047. /*
  6048. * Valid values for `type' parameter to slapi_reslimit_register().
  6049. */
  6050. #define SLAPI_RESLIMIT_TYPE_INT 0
  6051. /*
  6052. * Status codes returned by all functions.
  6053. */
  6054. #define SLAPI_RESLIMIT_STATUS_SUCCESS 0 /* goodness */
  6055. #define SLAPI_RESLIMIT_STATUS_NOVALUE 1 /* no value is available */
  6056. #define SLAPI_RESLIMIT_STATUS_INIT_FAILURE 2 /* initialization failed */
  6057. #define SLAPI_RESLIMIT_STATUS_PARAM_ERROR 3 /* bad parameter */
  6058. #define SLAPI_RESLIMIT_STATUS_UNKNOWN_HANDLE 4 /* unregistered handle */
  6059. #define SLAPI_RESLIMIT_STATUS_INTERNAL_ERROR 5 /* unexpected error */
  6060. /*
  6061. * Functions.
  6062. */
  6063. int slapi_reslimit_register( int type, const char *attrname, int *handlep );
  6064. int slapi_reslimit_get_integer_limit( Slapi_Connection *conn, int handle,
  6065. int *limitp );
  6066. /* END of Binder-based resource limits API */
  6067. /**
  6068. * Returns the current time
  6069. *
  6070. * \return The current time
  6071. */
  6072. time_t slapi_current_time( void );
  6073. /*
  6074. * Plugin and parameter block related macros (remainder of this file).
  6075. */
  6076. /*
  6077. * Plugin version. Note that the Directory Server will load version 01
  6078. * and 02 plugins, but some server features require 03 plugins.
  6079. */
  6080. #define SLAPI_PLUGIN_VERSION_01 "01"
  6081. #define SLAPI_PLUGIN_VERSION_02 "02"
  6082. #define SLAPI_PLUGIN_VERSION_03 "03"
  6083. #define SLAPI_PLUGIN_CURRENT_VERSION SLAPI_PLUGIN_VERSION_03
  6084. #define SLAPI_PLUGIN_IS_COMPAT(x) \
  6085. ((strcmp((x), SLAPI_PLUGIN_VERSION_01) == 0) || \
  6086. (strcmp((x), SLAPI_PLUGIN_VERSION_02) == 0) || \
  6087. (strcmp((x), SLAPI_PLUGIN_VERSION_03) == 0))
  6088. #define SLAPI_PLUGIN_IS_V2(x) \
  6089. ((strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_02) == 0) || \
  6090. (strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_03) == 0))
  6091. #define SLAPI_PLUGIN_IS_V3(x) \
  6092. (strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_03) == 0)
  6093. /* this one just has to be human readable */
  6094. #define SLAPI_PLUGIN_SUPPORTED_VERSIONS "01,02,03"
  6095. /*
  6096. * types of plugin interfaces
  6097. */
  6098. #define SLAPI_PLUGIN_EXTENDEDOP 2
  6099. #define SLAPI_PLUGIN_PREOPERATION 3
  6100. #define SLAPI_PLUGIN_POSTOPERATION 4
  6101. #define SLAPI_PLUGIN_MATCHINGRULE 5
  6102. #define SLAPI_PLUGIN_SYNTAX 6
  6103. #define SLAPI_PLUGIN_ACL 7
  6104. #define SLAPI_PLUGIN_BEPREOPERATION 8
  6105. #define SLAPI_PLUGIN_BEPOSTOPERATION 9
  6106. #define SLAPI_PLUGIN_ENTRY 10
  6107. #define SLAPI_PLUGIN_TYPE_OBJECT 11
  6108. #define SLAPI_PLUGIN_INTERNAL_PREOPERATION 12
  6109. #define SLAPI_PLUGIN_INTERNAL_POSTOPERATION 13
  6110. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME 14
  6111. #define SLAPI_PLUGIN_VATTR_SP 15
  6112. #define SLAPI_PLUGIN_REVER_PWD_STORAGE_SCHEME 16
  6113. #define SLAPI_PLUGIN_LDBM_ENTRY_FETCH_STORE 17
  6114. #define SLAPI_PLUGIN_INDEX 18
  6115. #define SLAPI_PLUGIN_BETXNPREOPERATION 19
  6116. #define SLAPI_PLUGIN_BETXNPOSTOPERATION 20
  6117. /*
  6118. * special return values for extended operation plugins (zero or positive
  6119. * return values should be LDAP error codes as defined in ldap.h)
  6120. */
  6121. #define SLAPI_PLUGIN_EXTENDED_SENT_RESULT -1
  6122. #define SLAPI_PLUGIN_EXTENDED_NOT_HANDLED -2
  6123. /*
  6124. * Return values of plugins:
  6125. */
  6126. #define SLAPI_PLUGIN_SUCCESS 0 /* 0 is treated as success implicitely */
  6127. #define SLAPI_PLUGIN_FAILURE -1 /* common failure */
  6128. #define SLAPI_PLUGIN_NOOP -2 /* Special in be_pre_op/be_txn_pre_op.
  6129. * Treat as SUCCESS, but skip the backend op.
  6130. * Also, return SUCCESS to the client/supplier.
  6131. * Necessary for the replication conflicts. */
  6132. /*
  6133. * the following can be used as the second argument to the
  6134. * slapi_pblock_get() and slapi_pblock_set() calls.
  6135. */
  6136. /* backend, connection, operation */
  6137. #define SLAPI_BACKEND 130
  6138. #define SLAPI_CONNECTION 131
  6139. #define SLAPI_OPERATION 132
  6140. #define SLAPI_REQUESTOR_ISROOT 133
  6141. #define SLAPI_BE_TYPE 135
  6142. #define SLAPI_BE_READONLY 136
  6143. #define SLAPI_BE_LASTMOD 137
  6144. #define SLAPI_CONN_ID 139
  6145. #define SLAPI_BACKEND_COUNT 860
  6146. /* operation */
  6147. #define SLAPI_OPINITIATED_TIME 140
  6148. #define SLAPI_REQUESTOR_DN 141
  6149. #define SLAPI_REQUESTOR_SDN 852
  6150. #define SLAPI_REQUESTOR_NDN 156
  6151. #define SLAPI_OPERATION_PARAMETERS 138
  6152. #define SLAPI_OPERATION_TYPE 590
  6153. #define SLAPI_OPERATION_AUTHTYPE 741
  6154. #define SLAPI_OPERATION_ID 744
  6155. #define SLAPI_OPERATION_SSF 750
  6156. #define SLAPI_IS_REPLICATED_OPERATION 142
  6157. #define SLAPI_IS_MMR_REPLICATED_OPERATION 153
  6158. #define SLAPI_IS_LEGACY_REPLICATED_OPERATION 154
  6159. #define SLAPI_SKIP_MODIFIED_ATTRS 155
  6160. /* connection */
  6161. #define SLAPI_CONN_DN 143
  6162. #define SLAPI_CONN_CLIENTNETADDR 850
  6163. #define SLAPI_CONN_SERVERNETADDR 851
  6164. #define SLAPI_CONN_IS_REPLICATION_SESSION 149
  6165. #define SLAPI_CONN_IS_SSL_SESSION 747
  6166. #define SLAPI_CONN_CERT 743
  6167. #define SLAPI_CONN_AUTHMETHOD 746
  6168. #define SLAPI_CONN_SASL_SSF 748
  6169. #define SLAPI_CONN_SSL_SSF 749
  6170. #define SLAPI_CONN_LOCAL_SSF 751
  6171. /*
  6172. * Types of authentication for SLAPI_CONN_AUTHMETHOD
  6173. * (and deprecated SLAPI_CONN_AUTHTYPE)
  6174. */
  6175. #define SLAPD_AUTH_NONE "none"
  6176. #define SLAPD_AUTH_SIMPLE "simple"
  6177. #define SLAPD_AUTH_SSL "SSL"
  6178. #define SLAPD_AUTH_SASL "SASL " /* followed by the mechanism name */
  6179. #define SLAPD_AUTH_OS "OS"
  6180. /* Command Line Arguments */
  6181. #define SLAPI_ARGC 147
  6182. #define SLAPI_ARGV 148
  6183. /* Slapd config file directory */
  6184. #define SLAPI_CONFIG_DIRECTORY 281
  6185. /* DSE flags */
  6186. #define SLAPI_DSE_DONT_WRITE_WHEN_ADDING 282
  6187. #define SLAPI_DSE_MERGE_WHEN_ADDING 283
  6188. #define SLAPI_DSE_DONT_CHECK_DUPS 284
  6189. #define SLAPI_DSE_REAPPLY_MODS 287
  6190. #define SLAPI_DSE_IS_PRIMARY_FILE 289
  6191. /* internal schema flags */
  6192. #define SLAPI_SCHEMA_FLAGS 285
  6193. /* urp flags */
  6194. #define SLAPI_URP_NAMING_COLLISION_DN 286
  6195. #define SLAPI_URP_TOMBSTONE_UNIQUEID 288
  6196. /* common to all plugins */
  6197. #define SLAPI_PLUGIN 3
  6198. #define SLAPI_PLUGIN_PRIVATE 4
  6199. #define SLAPI_PLUGIN_TYPE 5
  6200. #define SLAPI_PLUGIN_ARGV 6
  6201. #define SLAPI_PLUGIN_ARGC 7
  6202. #define SLAPI_PLUGIN_VERSION 8
  6203. #define SLAPI_PLUGIN_OPRETURN 9
  6204. #define SLAPI_PLUGIN_OBJECT 10
  6205. #define SLAPI_PLUGIN_DESTROY_FN 11
  6206. #define SLAPI_PLUGIN_DESCRIPTION 12
  6207. typedef struct slapi_plugindesc {
  6208. char *spd_id;
  6209. char *spd_vendor;
  6210. char *spd_version;
  6211. char *spd_description;
  6212. } Slapi_PluginDesc;
  6213. #define SLAPI_PLUGIN_IDENTITY 13
  6214. #define SLAPI_PLUGIN_PRECEDENCE 14
  6215. /* common for internal plugin_ops */
  6216. #define SLAPI_PLUGIN_INTOP_RESULT 15
  6217. #define SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES 16
  6218. #define SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS 17
  6219. /* miscellaneous plugin functions */
  6220. #define SLAPI_PLUGIN_CLOSE_FN 210
  6221. #define SLAPI_PLUGIN_START_FN 212
  6222. #define SLAPI_PLUGIN_CLEANUP_FN 232
  6223. #define SLAPI_PLUGIN_POSTSTART_FN 233
  6224. /* extendedop plugin functions */
  6225. #define SLAPI_PLUGIN_EXT_OP_FN 300
  6226. #define SLAPI_PLUGIN_EXT_OP_OIDLIST 301
  6227. #define SLAPI_PLUGIN_EXT_OP_NAMELIST 302
  6228. /* preoperation plugin functions */
  6229. #define SLAPI_PLUGIN_PRE_BIND_FN 401
  6230. #define SLAPI_PLUGIN_PRE_UNBIND_FN 402
  6231. #define SLAPI_PLUGIN_PRE_SEARCH_FN 403
  6232. #define SLAPI_PLUGIN_PRE_COMPARE_FN 404
  6233. #define SLAPI_PLUGIN_PRE_MODIFY_FN 405
  6234. #define SLAPI_PLUGIN_PRE_MODRDN_FN 406
  6235. #define SLAPI_PLUGIN_PRE_ADD_FN 407
  6236. #define SLAPI_PLUGIN_PRE_DELETE_FN 408
  6237. #define SLAPI_PLUGIN_PRE_ABANDON_FN 409
  6238. #define SLAPI_PLUGIN_PRE_ENTRY_FN 410
  6239. #define SLAPI_PLUGIN_PRE_REFERRAL_FN 411
  6240. #define SLAPI_PLUGIN_PRE_RESULT_FN 412
  6241. /* internal preoperation plugin functions */
  6242. #define SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN 420
  6243. #define SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN 421
  6244. #define SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN 422
  6245. #define SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN 423
  6246. #define SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN 424
  6247. /* preoperation plugin to the backend */
  6248. #define SLAPI_PLUGIN_BE_PRE_ADD_FN 450
  6249. #define SLAPI_PLUGIN_BE_PRE_MODIFY_FN 451
  6250. #define SLAPI_PLUGIN_BE_PRE_MODRDN_FN 452
  6251. #define SLAPI_PLUGIN_BE_PRE_DELETE_FN 453
  6252. #define SLAPI_PLUGIN_BE_PRE_CLOSE_FN 454
  6253. #define SLAPI_PLUGIN_BE_PRE_BACKUP_FN 455
  6254. /* preoperation plugin to the backend - just after transaction creation */
  6255. #define SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN 460
  6256. #define SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN 461
  6257. #define SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN 462
  6258. #define SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN 463
  6259. #define SLAPI_PLUGIN_BE_TXN_PRE_DELETE_TOMBSTONE_FN 464
  6260. /* postoperation plugin functions */
  6261. #define SLAPI_PLUGIN_POST_BIND_FN 501
  6262. #define SLAPI_PLUGIN_POST_UNBIND_FN 502
  6263. #define SLAPI_PLUGIN_POST_SEARCH_FN 503
  6264. #define SLAPI_PLUGIN_POST_COMPARE_FN 504
  6265. #define SLAPI_PLUGIN_POST_MODIFY_FN 505
  6266. #define SLAPI_PLUGIN_POST_MODRDN_FN 506
  6267. #define SLAPI_PLUGIN_POST_ADD_FN 507
  6268. #define SLAPI_PLUGIN_POST_DELETE_FN 508
  6269. #define SLAPI_PLUGIN_POST_ABANDON_FN 509
  6270. #define SLAPI_PLUGIN_POST_ENTRY_FN 510
  6271. #define SLAPI_PLUGIN_POST_REFERRAL_FN 511
  6272. #define SLAPI_PLUGIN_POST_RESULT_FN 512
  6273. #define SLAPI_PLUGIN_POST_SEARCH_FAIL_FN 513
  6274. /* internal preoperation plugin functions */
  6275. #define SLAPI_PLUGIN_INTERNAL_POST_ADD_FN 520
  6276. #define SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN 521
  6277. #define SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN 522
  6278. #define SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN 523
  6279. /* postoperation plugin to the backend */
  6280. #define SLAPI_PLUGIN_BE_POST_ADD_FN 550
  6281. #define SLAPI_PLUGIN_BE_POST_MODIFY_FN 551
  6282. #define SLAPI_PLUGIN_BE_POST_MODRDN_FN 552
  6283. #define SLAPI_PLUGIN_BE_POST_DELETE_FN 553
  6284. #define SLAPI_PLUGIN_BE_POST_OPEN_FN 554
  6285. #define SLAPI_PLUGIN_BE_POST_BACKUP_FN 555
  6286. /* postoperation plugin to the backend - just before transaction commit */
  6287. #define SLAPI_PLUGIN_BE_TXN_POST_ADD_FN 560
  6288. #define SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN 561
  6289. #define SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN 562
  6290. #define SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN 563
  6291. /* matching rule plugin functions */
  6292. #define SLAPI_PLUGIN_MR_FILTER_CREATE_FN 600
  6293. #define SLAPI_PLUGIN_MR_INDEXER_CREATE_FN 601
  6294. #define SLAPI_PLUGIN_MR_FILTER_MATCH_FN 602
  6295. #define SLAPI_PLUGIN_MR_FILTER_INDEX_FN 603
  6296. #define SLAPI_PLUGIN_MR_FILTER_RESET_FN 604
  6297. #define SLAPI_PLUGIN_MR_INDEX_FN 605
  6298. #define SLAPI_PLUGIN_MR_INDEX_SV_FN 606
  6299. /* matching rule plugin arguments */
  6300. #define SLAPI_PLUGIN_MR_OID 610
  6301. #define SLAPI_PLUGIN_MR_TYPE 611
  6302. #define SLAPI_PLUGIN_MR_VALUE 612
  6303. #define SLAPI_PLUGIN_MR_VALUES 613
  6304. #define SLAPI_PLUGIN_MR_KEYS 614
  6305. #define SLAPI_PLUGIN_MR_FILTER_REUSABLE 615
  6306. #define SLAPI_PLUGIN_MR_QUERY_OPERATOR 616
  6307. #define SLAPI_PLUGIN_MR_USAGE 617
  6308. /* new style matching rule syntax plugin functions */
  6309. #define SLAPI_PLUGIN_MR_FILTER_AVA 618
  6310. #define SLAPI_PLUGIN_MR_FILTER_SUB 619
  6311. #define SLAPI_PLUGIN_MR_VALUES2KEYS 620
  6312. #define SLAPI_PLUGIN_MR_ASSERTION2KEYS_AVA 621
  6313. #define SLAPI_PLUGIN_MR_ASSERTION2KEYS_SUB 622
  6314. #define SLAPI_PLUGIN_MR_FLAGS 623
  6315. #define SLAPI_PLUGIN_MR_NAMES 624
  6316. #define SLAPI_PLUGIN_MR_COMPARE 625
  6317. #define SLAPI_PLUGIN_MR_NORMALIZE 626
  6318. /* Defined values of SLAPI_PLUGIN_MR_QUERY_OPERATOR: */
  6319. #define SLAPI_OP_LESS 1
  6320. #define SLAPI_OP_LESS_OR_EQUAL 2
  6321. #define SLAPI_OP_EQUAL 3
  6322. #define SLAPI_OP_GREATER_OR_EQUAL 4
  6323. #define SLAPI_OP_GREATER 5
  6324. #define SLAPI_OP_SUBSTRING 6
  6325. /* Defined values of SLAPI_PLUGIN_MR_USAGE: */
  6326. #define SLAPI_PLUGIN_MR_USAGE_INDEX 0
  6327. #define SLAPI_PLUGIN_MR_USAGE_SORT 1
  6328. /* Defined values for matchingRuleEntry accessor functions */
  6329. #define SLAPI_MATCHINGRULE_NAME 1
  6330. #define SLAPI_MATCHINGRULE_OID 2
  6331. #define SLAPI_MATCHINGRULE_DESC 3
  6332. #define SLAPI_MATCHINGRULE_SYNTAX 4
  6333. #define SLAPI_MATCHINGRULE_OBSOLETE 5
  6334. /* syntax plugin functions and arguments */
  6335. #define SLAPI_PLUGIN_SYNTAX_FILTER_AVA 700
  6336. #define SLAPI_PLUGIN_SYNTAX_FILTER_SUB 701
  6337. #define SLAPI_PLUGIN_SYNTAX_VALUES2KEYS 702
  6338. #define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA 703
  6339. #define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB 704
  6340. #define SLAPI_PLUGIN_SYNTAX_NAMES 705
  6341. #define SLAPI_PLUGIN_SYNTAX_OID 706
  6342. #define SLAPI_PLUGIN_SYNTAX_FLAGS 707
  6343. #define SLAPI_PLUGIN_SYNTAX_COMPARE 708
  6344. /* user defined substrlen; not stored in slapdplugin, but pblock itself */
  6345. #define SLAPI_SYNTAX_SUBSTRLENS 709
  6346. #define SLAPI_MR_SUBSTRLENS SLAPI_SYNTAX_SUBSTRLENS /* alias */
  6347. #define SLAPI_PLUGIN_SYNTAX_VALIDATE 710
  6348. #define SLAPI_PLUGIN_SYNTAX_NORMALIZE 711
  6349. #define SLAPI_PLUGIN_SYNTAX_FILTER_NORMALIZED 712
  6350. #define SLAPI_PLUGIN_SYNTAX_FILTER_DATA 713
  6351. /* ACL plugin functions and arguments */
  6352. #define SLAPI_PLUGIN_ACL_INIT 730
  6353. #define SLAPI_PLUGIN_ACL_SYNTAX_CHECK 731
  6354. #define SLAPI_PLUGIN_ACL_ALLOW_ACCESS 732
  6355. #define SLAPI_PLUGIN_ACL_MODS_ALLOWED 733
  6356. #define SLAPI_PLUGIN_ACL_MODS_UPDATE 734
  6357. #define ACLPLUGIN_ACCESS_DEFAULT 0
  6358. #define ACLPLUGIN_ACCESS_READ_ON_ENTRY 1
  6359. #define ACLPLUGIN_ACCESS_READ_ON_ATTR 2
  6360. #define ACLPLUGIN_ACCESS_READ_ON_VLV 3
  6361. #define ACLPLUGIN_ACCESS_MODRDN 4
  6362. #define ACLPLUGIN_ACCESS_GET_EFFECTIVE_RIGHTS 5
  6363. /* Authorization types */
  6364. #define SLAPI_BE_MAXNESTLEVEL 742
  6365. #define SLAPI_CLIENT_DNS 745
  6366. /* Password storage scheme functions and arguments */
  6367. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN 800
  6368. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DEC_FN 801 /* only meaningfull for reversible encryption */
  6369. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN 802
  6370. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME 810 /* name of the method: SHA, SSHA... */
  6371. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_USER_PWD 811 /* value sent over LDAP */
  6372. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DB_PWD 812 /* value from the DB */
  6373. /* entry fetch and entry store values */
  6374. #define SLAPI_PLUGIN_ENTRY_FETCH_FUNC 813
  6375. #define SLAPI_PLUGIN_ENTRY_STORE_FUNC 814
  6376. #define SLAPI_PLUGIN_ENABLED 815
  6377. #define SLAPI_PLUGIN_CONFIG_AREA 816
  6378. /*
  6379. * Defined values of SLAPI_PLUGIN_SYNTAX_FLAGS:
  6380. */
  6381. #define SLAPI_PLUGIN_SYNTAX_FLAG_ORKEYS 1
  6382. #define SLAPI_PLUGIN_SYNTAX_FLAG_ORDERING 2
  6383. /* controls we know about */
  6384. #define SLAPI_MANAGEDSAIT 1000
  6385. #define SLAPI_PWPOLICY 1001
  6386. /* arguments that are common to all operation */
  6387. #define SLAPI_TARGET_ADDRESS 48 /* target address (dn + uniqueid) should be normalized */
  6388. #define SLAPI_TARGET_UNIQUEID 49 /* target uniqueid of the operation */
  6389. #define SLAPI_TARGET_DN 50 /* DEPRECATED. target dn of the operation.
  6390. It actually points DN in SLAPI_TARGET_SDN. */
  6391. #define SLAPI_TARGET_SDN 47 /* target sdn of the operation */
  6392. #define SLAPI_REQCONTROLS 51 /* request controls */
  6393. /* Copies of entry before and after add, mod, mod[r]dn operations */
  6394. #define SLAPI_ENTRY_PRE_OP 52
  6395. #define SLAPI_ENTRY_POST_OP 53
  6396. /* a PRE_ENTRY_FN may alter the entry to be returned to the client -
  6397. SLAPI_SEARCH_ORIG_ENTRY holds the original entry from
  6398. the database - this must not be changed
  6399. SLAPI_SEARCH_ENTRY_COPY holds a copy of the original entry that
  6400. has been modified by the plugin - this will be NULL by default -
  6401. if a plugin needs to modify the entry, it should first check to
  6402. see if there is already a SLAPI_SEARCH_ENTRY_COPY - if not, the
  6403. plugin must use slapi_entry_dup() or similar to make a copy, edit
  6404. the copy, then store it in SLAPI_SEARCH_ENTRY_COPY - the internal
  6405. server code will free SLAPI_SEARCH_ENTRY_COPY
  6406. */
  6407. #define SLAPI_SEARCH_ENTRY_ORIG SLAPI_ENTRY_PRE_OP
  6408. #define SLAPI_SEARCH_ENTRY_COPY SLAPI_ENTRY_POST_OP
  6409. /* for plugin init functions, this is the plugin config entry */
  6410. #define SLAPI_PLUGIN_CONFIG_ENTRY SLAPI_ENTRY_PRE_OP
  6411. /* LDAPv3 controls to be sent with the operation result */
  6412. #define SLAPI_RESCONTROLS 55
  6413. #define SLAPI_ADD_RESCONTROL 56 /* add result control */
  6414. /* Extra notes to be logged within access log RESULT lines */
  6415. #define SLAPI_OPERATION_NOTES 57
  6416. #define SLAPI_OP_NOTE_UNINDEXED 0x01
  6417. #define SLAPI_OP_NOTE_SIMPLEPAGED 0x02
  6418. #define SLAPI_OP_NOTE_FULL_UNINDEXED 0x04
  6419. /* Allows controls to be passed before operation object is created */
  6420. #define SLAPI_CONTROLS_ARG 58
  6421. /* specify whether pblock content should be destroyed when the pblock is destroyed */
  6422. #define SLAPI_DESTROY_CONTENT 59
  6423. /* add arguments */
  6424. #define SLAPI_ADD_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6425. #define SLAPI_ADD_TARGET_SDN SLAPI_TARGET_SDN
  6426. #define SLAPI_ADD_ENTRY 60
  6427. #define SLAPI_ADD_EXISTING_DN_ENTRY 61
  6428. #define SLAPI_ADD_PARENT_ENTRY 62
  6429. #define SLAPI_ADD_PARENT_UNIQUEID 63
  6430. #define SLAPI_ADD_EXISTING_UNIQUEID_ENTRY 64
  6431. /* bind arguments */
  6432. #define SLAPI_BIND_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6433. #define SLAPI_BIND_TARGET_SDN SLAPI_TARGET_SDN
  6434. #define SLAPI_BIND_METHOD 70
  6435. #define SLAPI_BIND_CREDENTIALS 71 /* v3 only */
  6436. #define SLAPI_BIND_SASLMECHANISM 72 /* v3 only */
  6437. /* bind return values */
  6438. #define SLAPI_BIND_RET_SASLCREDS 73 /* v3 only */
  6439. /* compare arguments */
  6440. #define SLAPI_COMPARE_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6441. #define SLAPI_COMPARE_TARGET_SDN SLAPI_TARGET_SDN
  6442. #define SLAPI_COMPARE_TYPE 80
  6443. #define SLAPI_COMPARE_VALUE 81
  6444. /* delete arguments */
  6445. #define SLAPI_DELETE_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6446. #define SLAPI_DELETE_TARGET_SDN SLAPI_TARGET_SDN
  6447. #define SLAPI_DELETE_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  6448. #define SLAPI_DELETE_GLUE_PARENT_ENTRY SLAPI_ADD_PARENT_ENTRY
  6449. #define SLAPI_DELETE_BEPREOP_ENTRY SLAPI_ENTRY_PRE_OP
  6450. #define SLAPI_DELETE_BEPOSTOP_ENTRY SLAPI_ENTRY_POST_OP
  6451. /* modify arguments */
  6452. #define SLAPI_MODIFY_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6453. #define SLAPI_MODIFY_TARGET_SDN SLAPI_TARGET_SDN
  6454. #define SLAPI_MODIFY_MODS 90
  6455. #define SLAPI_MODIFY_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  6456. /* modrdn arguments */
  6457. #define SLAPI_MODRDN_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6458. #define SLAPI_MODRDN_TARGET_SDN SLAPI_TARGET_SDN
  6459. #define SLAPI_MODRDN_NEWRDN 100
  6460. #define SLAPI_MODRDN_DELOLDRDN 101
  6461. #define SLAPI_MODRDN_NEWSUPERIOR 102 /* v3 only */
  6462. #define SLAPI_MODRDN_NEWSUPERIOR_SDN 103 /* v3 only */
  6463. #define SLAPI_MODRDN_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  6464. #define SLAPI_MODRDN_PARENT_ENTRY 104
  6465. #define SLAPI_MODRDN_NEWPARENT_ENTRY 105
  6466. #define SLAPI_MODRDN_TARGET_ENTRY 106
  6467. #define SLAPI_MODRDN_NEWSUPERIOR_ADDRESS 107
  6468. /*
  6469. * unnormalized dn argument (useful for MOD, MODRDN and DEL operations to carry
  6470. * the original non-escaped dn as introduced by the client application)
  6471. */
  6472. #define SLAPI_ORIGINAL_TARGET_DN 109
  6473. #define SLAPI_ORIGINAL_TARGET SLAPI_ORIGINAL_TARGET_DN
  6474. /* search arguments */
  6475. #define SLAPI_SEARCH_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6476. #define SLAPI_SEARCH_TARGET_SDN SLAPI_TARGET_SDN
  6477. #define SLAPI_SEARCH_SCOPE 110
  6478. #define SLAPI_SEARCH_DEREF 111
  6479. #define SLAPI_SEARCH_SIZELIMIT 112
  6480. #define SLAPI_SEARCH_TIMELIMIT 113
  6481. #define SLAPI_SEARCH_FILTER 114
  6482. #define SLAPI_SEARCH_STRFILTER 115
  6483. #define SLAPI_SEARCH_ATTRS 116
  6484. #define SLAPI_SEARCH_GERATTRS 1160
  6485. #define SLAPI_SEARCH_ATTRSONLY 117
  6486. #define SLAPI_SEARCH_IS_AND 118
  6487. /* abandon arguments */
  6488. #define SLAPI_ABANDON_MSGID 120
  6489. /* seq access arguments */
  6490. #define SLAPI_SEQ_TYPE 150
  6491. #define SLAPI_SEQ_ATTRNAME 151
  6492. #define SLAPI_SEQ_VAL 152
  6493. /* extended operation arguments */
  6494. #define SLAPI_EXT_OP_REQ_OID 160 /* v3 only */
  6495. #define SLAPI_EXT_OP_REQ_VALUE 161 /* v3 only */
  6496. /* extended operation return values */
  6497. #define SLAPI_EXT_OP_RET_OID 162 /* v3 only */
  6498. #define SLAPI_EXT_OP_RET_VALUE 163 /* v3 only */
  6499. /* extended filter arguments */
  6500. #define SLAPI_MR_FILTER_ENTRY 170 /* v3 only */
  6501. #define SLAPI_MR_FILTER_TYPE 171 /* v3 only */
  6502. #define SLAPI_MR_FILTER_VALUE 172 /* v3 only */
  6503. #define SLAPI_MR_FILTER_OID 173 /* v3 only */
  6504. #define SLAPI_MR_FILTER_DNATTRS 174 /* v3 only */
  6505. /* ldif2db arguments */
  6506. /* ldif file to convert to db */
  6507. #define SLAPI_LDIF2DB_FILE 180
  6508. /* check for duplicate values or not */
  6509. #define SLAPI_LDIF2DB_REMOVEDUPVALS 185
  6510. /* index only this attribute from existing database */
  6511. #define SLAPI_DB2INDEX_ATTRS 186
  6512. /* do not generate attribute indexes */
  6513. #define SLAPI_LDIF2DB_NOATTRINDEXES 187
  6514. /* list if DNs to include */
  6515. #define SLAPI_LDIF2DB_INCLUDE 188
  6516. /* list of DNs to exclude */
  6517. #define SLAPI_LDIF2DB_EXCLUDE 189
  6518. /* generate uniqueid */
  6519. #define SLAPI_LDIF2DB_GENERATE_UNIQUEID 175
  6520. #define SLAPI_LDIF2DB_NAMESPACEID 177
  6521. #define SLAPI_LDIF2DB_ENCRYPT 303
  6522. #define SLAPI_DB2LDIF_DECRYPT 304
  6523. /* uniqueid generation options */
  6524. #define SLAPI_UNIQUEID_GENERATE_NONE 0 /* do not generate */
  6525. #define SLAPI_UNIQUEID_GENERATE_TIME_BASED 1 /* generate time based id */
  6526. #define SLAPI_UNIQUEID_GENERATE_NAME_BASED 2 /* generate name based id */
  6527. /* db2ldif arguments */
  6528. /* print keys or not in ldif */
  6529. #define SLAPI_DB2LDIF_PRINTKEY 183
  6530. /* filename to export */
  6531. #define SLAPI_DB2LDIF_FILE 184
  6532. /* dump uniqueid */
  6533. #define SLAPI_DB2LDIF_DUMP_UNIQUEID 176
  6534. #define SLAPI_DB2LDIF_SERVER_RUNNING 197
  6535. /* db2ldif/ldif2db/bak2db/db2bak arguments */
  6536. #define SLAPI_BACKEND_INSTANCE_NAME 178
  6537. #define SLAPI_BACKEND_TASK 179
  6538. #define SLAPI_TASK_FLAGS 181
  6539. /* bulk import (online wire import) */
  6540. #define SLAPI_BULK_IMPORT_ENTRY 182
  6541. #define SLAPI_BULK_IMPORT_STATE 192
  6542. /* the actual states (these are not pblock args) */
  6543. #define SLAPI_BI_STATE_START 1
  6544. #define SLAPI_BI_STATE_DONE 2
  6545. #define SLAPI_BI_STATE_ADD 3
  6546. /* possible error codes from a bulk import */
  6547. #define SLAPI_BI_ERR_BUSY -23 /* backend is busy; try later */
  6548. /* transaction arguments */
  6549. #define SLAPI_PARENT_TXN 190
  6550. #define SLAPI_TXN 191
  6551. #define SLAPI_TXN_RUV_MODS_FN 1901
  6552. #define SLAPI_BACK_TRANSACTION_NOT_SUPPORTED 1902
  6553. /*
  6554. * The following are used to pass information back and forth
  6555. * between the front end and the back end. The backend
  6556. * creates a search result set as an opaque structure and
  6557. * passes a reference to this back to the front end. The
  6558. * front end uses the backend's iterator entry point to
  6559. * step through the results. The entry, nentries, and
  6560. * referrals options, below, are set/read by both the
  6561. * front end and back end while stepping through the
  6562. * search results.
  6563. */
  6564. /* Search result set */
  6565. #define SLAPI_SEARCH_RESULT_SET 193
  6566. /* Estimated search result set size (for paged results) */
  6567. #define SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE 1930
  6568. /* Search result - next entry returned from search result set */
  6569. #define SLAPI_SEARCH_RESULT_ENTRY 194
  6570. #define SLAPI_SEARCH_RESULT_ENTRY_EXT 1944
  6571. /* Number of entries returned from search */
  6572. #define SLAPI_NENTRIES 195
  6573. /* Any referrals encountered during the search */
  6574. #define SLAPI_SEARCH_REFERRALS 196
  6575. /* for search operations, allows plugins to provide
  6576. controls to pass for each entry or referral returned
  6577. corresponds to pb_search_ctrls */
  6578. #define SLAPI_SEARCH_CTRLS 198
  6579. #define SLAPI_RESULT_CODE 881
  6580. #define SLAPI_RESULT_TEXT 882
  6581. #define SLAPI_RESULT_MATCHED 883
  6582. #define SLAPI_PB_RESULT_TEXT 885
  6583. /* Size of the database, in kilobytes */
  6584. #define SLAPI_DBSIZE 199
  6585. /* Simple paged results index */
  6586. #define SLAPI_PAGED_RESULTS_INDEX 1945
  6587. /* ACI Target Check */
  6588. #define SLAPI_ACI_TARGET_CHECK 1946
  6589. /* convenience macros for checking modify operation types */
  6590. #define SLAPI_IS_MOD_ADD(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_ADD)
  6591. #define SLAPI_IS_MOD_DELETE(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_DELETE)
  6592. #define SLAPI_IS_MOD_REPLACE(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_REPLACE)
  6593. /* regex.c */
  6594. typedef struct slapi_regex_handle Slapi_Regex;
  6595. /**
  6596. * Compiles a regular expression pattern. A thin wrapper of pcre_compile.
  6597. *
  6598. * \param pat Pattern to be compiled.
  6599. * \param error The error string is set if the compile fails.
  6600. * \return This function returns a pointer to the regex handler which stores
  6601. * the compiled pattern. NULL if the compile fails.
  6602. * \warning The regex handler should be released by slapi_re_free().
  6603. */
  6604. Slapi_Regex *slapi_re_comp( const char *pat, const char **error );
  6605. /**
  6606. * Matches a compiled regular expression pattern against a given string.
  6607. * A thin wrapper of pcre_exec.
  6608. *
  6609. * \param re_handle The regex handler returned from slapi_re_comp.
  6610. * \param subject A string to be checked against the compiled pattern.
  6611. * \param time_up If the current time is larger than the value, this function
  6612. * returns immediately. (-1) means no time limit.
  6613. * \return This function returns 0 if the string did not match.
  6614. * \return This function returns 1 if the string matched.
  6615. * \return This function returns other values if any error occurred.
  6616. * \warning The regex handler should be released by slapi_re_free().
  6617. */
  6618. int slapi_re_exec( Slapi_Regex *re_handle, const char *subject, time_t time_up );
  6619. /**
  6620. * Substitutes '&' or '\#' in the param src with the matched string.
  6621. *
  6622. * \param re_handle The regex handler returned from slapi_re_comp.
  6623. * \param subject A string checked against the compiled pattern.
  6624. * \param src A given string which could contain the substitution symbols.
  6625. * \param dst A pointer pointing to the memory which stores the output string.
  6626. * \param dstlen Size of the memory dst.
  6627. * \return This function returns 1 if the substitution was successful.
  6628. * \return This function returns 0 if the substitution failed.
  6629. * \warning The regex handler should be released by slapi_re_free().
  6630. */
  6631. int slapi_re_subs( Slapi_Regex *re_handle, const char *subject, const char *src, char **dst, unsigned long dstlen );
  6632. /**
  6633. * Substitutes '&' or '\#' in the param src with the matched string. If the 'src' is a search filter
  6634. * do not remove & if it is part of a compound filter.
  6635. *
  6636. * \param re_handle The regex handler returned from slapi_re_comp.
  6637. * \param subject A string checked against the compiled pattern.
  6638. * \param src A given string which could contain the substitution symbols.
  6639. * \param dst A pointer pointing to the memory which stores the output string.
  6640. * \param dstlen Size of the memory dst.
  6641. * \param filter Set to 1 if the src is a ldap search filter
  6642. * \return This function returns 1 if the substitution was successful.
  6643. * \return This function returns 0 if the substitution failed.
  6644. * \warning The regex handler should be released by slapi_re_free().
  6645. */
  6646. int slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject, const char *src, char **dst, unsigned long dstlen, int filter );
  6647. /**
  6648. * Releases the regex handler which was returned from slapi_re_comp.
  6649. *
  6650. * \param re_handle The regex handler to be released.
  6651. * \return nothing
  6652. */
  6653. void slapi_re_free(Slapi_Regex *re_handle);
  6654. /* wrap non-portable LDAP API functions */
  6655. void slapi_ldap_value_free(char **vals);
  6656. int slapi_ldap_count_values(char **vals);
  6657. int slapi_ldap_url_parse(const char *url, LDAPURLDesc **ludpp, int require_dn, int *secure);
  6658. const char *slapi_urlparse_err2string(int err);
  6659. int slapi_ldap_get_lderrno(LDAP *ld, char **m, char **s);
  6660. #ifndef LDIF_OPT_NOWRAP
  6661. #define LDIF_OPT_NOWRAP 0x01UL
  6662. #endif
  6663. #ifndef LDIF_OPT_VALUE_IS_URL
  6664. #define LDIF_OPT_VALUE_IS_URL 0x02UL
  6665. #endif
  6666. #ifndef LDIF_OPT_MINIMAL_ENCODING
  6667. #define LDIF_OPT_MINIMAL_ENCODING 0x04UL
  6668. #endif
  6669. void slapi_ldif_put_type_and_value_with_options( char **out, const char *t, const char *val, int vlen, unsigned long options );
  6670. /* ldif_read_record lineno argument type depends on openldap version */
  6671. #if defined(USE_OPENLDAP)
  6672. #if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
  6673. typedef unsigned long int ldif_record_lineno_t;
  6674. #else
  6675. typedef int ldif_record_lineno_t;
  6676. #endif
  6677. #endif
  6678. #if defined(USE_OPENLDAP)
  6679. /*
  6680. * UTF-8 routines (should these move into libnls?)
  6681. */
  6682. /* number of bytes in character */
  6683. int ldap_utf8len( const char* );
  6684. /* find next character */
  6685. char *ldap_utf8next( char* );
  6686. /* find previous character */
  6687. char *ldap_utf8prev( char* );
  6688. /* copy one character */
  6689. int ldap_utf8copy( char* dst, const char* src );
  6690. /* total number of characters */
  6691. size_t ldap_utf8characters( const char* );
  6692. /* get one UCS-4 character, and move *src to the next character */
  6693. unsigned long ldap_utf8getcc( const char** src );
  6694. /* UTF-8 aware strtok_r() */
  6695. char *ldap_utf8strtok_r( char* src, const char* brk, char** next);
  6696. /* like isalnum(*s) in the C locale */
  6697. int ldap_utf8isalnum( char* s );
  6698. /* like isalpha(*s) in the C locale */
  6699. int ldap_utf8isalpha( char* s );
  6700. /* like isdigit(*s) in the C locale */
  6701. int ldap_utf8isdigit( char* s );
  6702. /* like isxdigit(*s) in the C locale */
  6703. int ldap_utf8isxdigit(char* s );
  6704. /* like isspace(*s) in the C locale */
  6705. int ldap_utf8isspace( char* s );
  6706. #define LDAP_UTF8LEN(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8len (s) : 1)
  6707. #define LDAP_UTF8NEXT(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8next(s) : ( s)+1)
  6708. #define LDAP_UTF8INC(s) ((0x80 & *(unsigned char*)(s)) ? s=ldap_utf8next(s) : ++s)
  6709. #define LDAP_UTF8PREV(s) ldap_utf8prev(s)
  6710. #define LDAP_UTF8DEC(s) (s=ldap_utf8prev(s))
  6711. #define LDAP_UTF8COPY(d,s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8copy(d,s) : ((*(d) = *(s)), 1))
  6712. #define LDAP_UTF8GETCC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc (&s) : *s++)
  6713. #define LDAP_UTF8GETC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc ((const char**)&s) : *s++)
  6714. #endif /* USE_OPENLDAP */
  6715. /* by default will allow dups */
  6716. char **slapi_str2charray( char *str, char *brkstr );
  6717. /*
  6718. * extended version of str2charray lets you disallow
  6719. * duplicate values into the array.
  6720. */
  6721. char **slapi_str2charray_ext( char *str, char *brkstr, int allow_dups );
  6722. #ifndef LDAP_PORT_MAX
  6723. #define LDAP_PORT_MAX 65535 /* API extension */
  6724. #endif
  6725. #ifndef LDAP_ALL_USER_ATTRS
  6726. #ifdef LDAP_ALL_USER_ATTRIBUTES
  6727. #define LDAP_ALL_USER_ATTRS LDAP_ALL_USER_ATTRIBUTES
  6728. #else
  6729. #define LDAP_ALL_USER_ATTRS "*"
  6730. #endif
  6731. #endif
  6732. #ifndef LDAP_SASL_EXTERNAL
  6733. #define LDAP_SASL_EXTERNAL "EXTERNAL" /* TLS/SSL extension */
  6734. #endif
  6735. #ifndef LBER_SOCKET
  6736. #ifdef LBER_SOCKET_T
  6737. #define LBER_SOCKET LBER_SOCKET_T
  6738. #else
  6739. #define LBER_SOCKET int
  6740. #endif
  6741. #endif
  6742. /* Used to make unhashed passwords available to plugins. */
  6743. #define PSEUDO_ATTR_UNHASHEDUSERPASSWORD "unhashed#user#password"
  6744. /* Unhashed password */
  6745. #define SLAPD_UNHASHED_PW_OFF 0
  6746. #define SLAPD_UNHASHED_PW_ON 1
  6747. #define SLAPD_UNHASHED_PW_NOLOG 2
  6748. /**
  6749. * Set given "type: value" to the plugin default config entry
  6750. * (cn=plugin default config,cn=config) unless the same "type: value" pair
  6751. * already exists in the entry.
  6752. *
  6753. * \param type Attribute type to add to the default config entry
  6754. * \param value Attribute value to add to the default config entry
  6755. * \return \c 0 if the operation was successful
  6756. * \return non-0 if the operation was not successful
  6757. */
  6758. int slapi_set_plugin_default_config(const char *type, Slapi_Value *value);
  6759. /**
  6760. * Get attribute values of given type from the plugin default config entry
  6761. * (cn=plugin default config,cn=config).
  6762. *
  6763. * \param type Attribute type to get from the default config entry
  6764. * \param valueset Valueset holding the attribute values
  6765. * \return \c 0 if the operation was successful
  6766. * \return non-0 if the operation was not successful
  6767. * \warning Caller is responsible to free attrs by slapi_ch_array_free
  6768. */
  6769. int slapi_get_plugin_default_config(char *type, Slapi_ValueSet **valueset);
  6770. int slapi_check_account_lock( Slapi_PBlock *pb, Slapi_Entry *bind_target_entry, int pwresponse_req, int check_password_policy, int send_result);
  6771. /* backend get/set info */
  6772. /**
  6773. * Get backend info based upon cmd
  6774. *
  6775. * \param be Backend from which the infomation will be retrieved
  6776. * \param cmd macro to specify the information type
  6777. * \param info pointer to store the information
  6778. * \return \c 0 if the operation was successful
  6779. * \return non-0 if the operation was not successful
  6780. *
  6781. * \note Implemented cmd:
  6782. * BACK_INFO_DBENV - Get the dbenv
  6783. * BACK_INFO_DBENV_OPENFLAGS - Get the dbenv openflags
  6784. * BACK_INFO_INDEXPAGESIZE - Get the index page size
  6785. */
  6786. int slapi_back_get_info(Slapi_Backend *be, int cmd, void **info);
  6787. /**
  6788. * Set info to backend based upon cmd
  6789. *
  6790. * \param be Backend to which the infomation will be set
  6791. * \param cmd macro to specify the information type
  6792. * \param info pointer to the information
  6793. * \return \c 0 if the operation was successful
  6794. * \return non-0 if the operation was not successful
  6795. * \warning No cmd is defined yet.
  6796. */
  6797. int slapi_back_set_info(Slapi_Backend *be, int cmd, void *info);
  6798. /**
  6799. * Execute cmd in backend
  6800. *
  6801. * \param be Backend where the command is executed
  6802. * \param cmd macro to specify the execution type
  6803. * \param info pointer to the information
  6804. * \return \c 0 if the operation was successful
  6805. * \return non-0 if the operation was not successful
  6806. *
  6807. * \note Implemented cmd:
  6808. * BACK_INFO_CRYPT_INIT - Initialize cipher (info: back_info_crypt_init)
  6809. * BACK_INFO_CRYPT_ENCRYPT_VALUE - Encrypt the given value (info: back_info_crypt_value)
  6810. * BACK_INFO_CRYPT_DECRYPT_VALUE - Decrypt the given value (info: back_info_crypt_value)
  6811. */
  6812. int slapi_back_ctrl_info(Slapi_Backend *be, int cmd, void *info);
  6813. /* cmd */
  6814. enum
  6815. {
  6816. BACK_INFO_DBENV, /* Get the dbenv */
  6817. BACK_INFO_INDEXPAGESIZE, /* Get the index page size */
  6818. BACK_INFO_DBENV_OPENFLAGS, /* Get the dbenv openflags */
  6819. BACK_INFO_CRYPT_INIT, /* Ctrl: clcrypt_init */
  6820. BACK_INFO_CRYPT_ENCRYPT_VALUE, /* Ctrl: clcrypt_encrypt_value */
  6821. BACK_INFO_CRYPT_DECRYPT_VALUE, /* Ctrl: clcrypt_decrypt_value */
  6822. BACK_INFO_DIRECTORY, /* Get the directory path */
  6823. BACK_INFO_LOG_DIRECTORY /* Get the txn log directory */
  6824. };
  6825. struct _back_info_crypt_init {
  6826. char *dn; /* input -- entry to store nsSymmetricKey */
  6827. char *encryptionAlgorithm; /* input -- encryption althorithm */
  6828. Slapi_Backend *be; /* input -- backend to use */
  6829. void *state_priv; /* outout */
  6830. };
  6831. typedef struct _back_info_crypt_init back_info_crypt_init;
  6832. struct _back_info_crypt_value {
  6833. void *state_priv; /* input */
  6834. struct berval *in; /* input */
  6835. struct berval *out; /* output */
  6836. };
  6837. typedef struct _back_info_crypt_value back_info_crypt_value;
  6838. #define BACK_CRYPT_OUTBUFF_EXTLEN 16
  6839. /**
  6840. * Convert unsigned char (8 bit) value to a hex string. Writes to the string.
  6841. * The caller must ensure enough space to write 2 bytes. If the upper parameter
  6842. * is TRUE, will use upper case A-F instead of lower case a-f for hex numbers.
  6843. * Returns the address after the last byte written to encourage usage like this:
  6844. * \code
  6845. * char *ptr = slapi_u_to_hex(val, buf, 0);
  6846. * ptr = slapi_u_to_hex(val2, ptr, 0);
  6847. * ...
  6848. * ptr = slapi_u_to_hex(valN, ptr, 0);
  6849. * *ptr = 0;
  6850. * \endcode
  6851. *
  6852. * \param val unsigned value to convert to string
  6853. * \param s string to write hex value into
  6854. * \param upper if TRUE use A-F otherwise use a-f
  6855. * \return address of next char after writing value to s
  6856. *
  6857. * \note Does not null terminate s - caller is responsible for that
  6858. */
  6859. char *slapi_u8_to_hex(uint8_t val, char *s, uint8_t upper);
  6860. /**
  6861. * Convert unsigned short (16 bit) value to a hex string. Writes to the string.
  6862. * The caller must ensure enough space to write 4 bytes. If the upper parameter
  6863. * is TRUE, will use upper case A-F instead of lower case a-f for hex numbers.
  6864. * Returns the address after the last byte written to encourage usage like this:
  6865. * \code
  6866. * char *ptr = slapi_u_to_hex(val, buf, 0);
  6867. * ptr = slapi_u_to_hex(val2, ptr, 0);
  6868. * ...
  6869. * ptr = slapi_u_to_hex(valN, ptr, 0);
  6870. * *ptr = 0;
  6871. * \endcode
  6872. *
  6873. * \param val unsigned value to convert to string
  6874. * \param s string to write hex value into
  6875. * \param upper if TRUE use A-F otherwise use a-f
  6876. * \return address of next char after writing value to s
  6877. *
  6878. * \note Does not null terminate s - caller is responsible for that
  6879. */
  6880. char *slapi_u16_to_hex(uint16_t val, char *s, uint8_t upper);
  6881. /**
  6882. * Convert unsigned int (32 bit) value to a hex string. Writes to the string.
  6883. * The caller must ensure enough space to write 4 bytes. If the upper parameter
  6884. * is TRUE, will use upper case A-F instead of lower case a-f for hex numbers.
  6885. * Returns the address after the last byte written to encourage usage like this:
  6886. * \code
  6887. * char *ptr = slapi_u_to_hex(val, buf, 0);
  6888. * ptr = slapi_u_to_hex(val2, ptr, 0);
  6889. * ...
  6890. * ptr = slapi_u_to_hex(valN, ptr, 0);
  6891. * *ptr = 0;
  6892. * \endcode
  6893. *
  6894. * \param val unsigned value to convert to string
  6895. * \param s string to write hex value into
  6896. * \param upper if TRUE use A-F otherwise use a-f
  6897. * \return address of next char after writing value to s
  6898. *
  6899. * \note Does not null terminate s - caller is responsible for that
  6900. */
  6901. char *slapi_u32_to_hex(uint32_t val, char *s, uint8_t upper);
  6902. /**
  6903. * Convert unsigned long long (64 bit) value to a hex string. Writes to the string.
  6904. * The caller must ensure enough space to write 4 bytes. If the upper parameter
  6905. * is TRUE, will use upper case A-F instead of lower case a-f for hex numbers.
  6906. * Returns the address after the last byte written to encourage usage like this:
  6907. * \code
  6908. * char *ptr = slapi_u_to_hex(val, buf, 0);
  6909. * ptr = slapi_u_to_hex(val2, ptr, 0);
  6910. * ...
  6911. * ptr = slapi_u_to_hex(valN, ptr, 0);
  6912. * *ptr = 0;
  6913. * \endcode
  6914. *
  6915. * \param val unsigned value to convert to string
  6916. * \param s string to write hex value into
  6917. * \param upper if TRUE use A-F otherwise use a-f
  6918. * \return address of next char after writing value to s
  6919. *
  6920. * \note Does not null terminate s - caller is responsible for that
  6921. */
  6922. char *slapi_u64_to_hex(uint64_t val, char *s, uint8_t upper);
  6923. /**
  6924. * Convert a char to its integral hex value e.g. '0' -> 0 or 'a' -> 10.
  6925. * This only works on one caller at a time. If you want to convert a string
  6926. * of decimal/hex numbers to its integral value, see slapi_str_to_u8 et. al.
  6927. * This uses a lookup table so it should be extremely fast.
  6928. *
  6929. * \param c character value to convert
  6930. * \return integral value of the given char or -1 if not a valid decimal/hex digit
  6931. */
  6932. int slapi_hexchar2int(char c);
  6933. /**
  6934. * Convert a string of 2 decimal/hex characters to a 1 byte (8-bit) unsigned value.
  6935. * This function does no checking - it assumes s is non-NULL and well-formed.
  6936. *
  6937. * \param s convert the first 2 chars of this decimal/hex char string to its integral value
  6938. * \return the integral value
  6939. */
  6940. uint8_t slapi_str_to_u8(const char *s);
  6941. /**
  6942. * Convert a string of 4 decimal/hex characters to a 2 byte (16-bit) unsigned value.
  6943. * This function does no checking - it assumes s is non-NULL and well-formed.
  6944. *
  6945. * \param s convert the first 4 chars of this decimal/hex char string to its integral value
  6946. * \return the integral value
  6947. */
  6948. uint16_t slapi_str_to_u16(const char *s);
  6949. /**
  6950. * Convert a string of 8 decimal/hex characters to a 4 byte (32-bit) unsigned value.
  6951. * This function does no checking - it assumes s is non-NULL and well-formed.
  6952. *
  6953. * \param s convert the first 8 chars of this decimal/hex char string to its integral value
  6954. * \return the integral value
  6955. */
  6956. uint32_t slapi_str_to_u32(const char *s);
  6957. /**
  6958. * Convert a string of 16 decimal/hex characters to a 8 byte (64-bit) unsigned value.
  6959. * This function does no checking - it assumes s is non-NULL and well-formed.
  6960. *
  6961. * \param s convert the first 16 chars of this decimal/hex char string to its integral value
  6962. * \return the integral value
  6963. */
  6964. uint64_t slapi_str_to_u64(const char *s);
  6965. void slapi_set_plugin_open_rootdn_bind(Slapi_PBlock *pb);
  6966. PRBool slapi_disordely_shutdown(PRBool set);
  6967. /*
  6968. * Public entry extension getter/setter functions
  6969. *
  6970. * Currently, only slapi_pw_get/set_entry_ext is implemented.
  6971. * The functions are in pw.c. Detailed usage of the factory
  6972. * is found in the comments at the top of factory.c.
  6973. *
  6974. * When you plan to add other entry extension code AND
  6975. * the type-value pair is managed via ordinary mod,
  6976. * setter, getter and copy function having the same API
  6977. * are supposed to be implemented, then add the set to
  6978. * attrs_in_extension list in entry.c. The set is called
  6979. * in slapi_entry_apply_mod_extension.
  6980. *
  6981. * Note: setter and getter are public, but copy function
  6982. * is not. (for the copy function, see pw_copy_entry_ext in pw.c)
  6983. */
  6984. /* operation used in the entry extension setter */
  6985. #define SLAPI_EXT_SET_ADD 0
  6986. #define SLAPI_EXT_SET_REPLACE 1
  6987. /**
  6988. * Get entry extension
  6989. *
  6990. * \param entry is the entry to retrieve the extension from
  6991. * \param vals is the array of (Slapi_Value *), which directly refers the extension. Caller must duplicate it to use it for other than referring.
  6992. *
  6993. * \return LDAP_SUCCESS if successful.
  6994. * \return non-zero otherwise.
  6995. */
  6996. int slapi_pw_get_entry_ext(Slapi_Entry *entry, Slapi_Value ***vals);
  6997. /**
  6998. * Set entry extension
  6999. *
  7000. * \param entry is the entry to set the extension to
  7001. * \param vals is the array of (Slapi_Value *), which is consumed in slapi_pw_set_ext if the call is successful.
  7002. * \param flags: SLAPI_EXT_SET_ADD -- add vals to the existing extension if any.
  7003. * SLAPI_EXT_SET_REPLACE -- replace vals with the existing extension if any.
  7004. * No difference if there is no extension in the entry.
  7005. *
  7006. * \return LDAP_SUCCESS if successful.
  7007. * \return non-zero otherwise.
  7008. */
  7009. int slapi_pw_set_entry_ext(Slapi_Entry *entry, Slapi_Value **vals, int flags);
  7010. /**
  7011. * Get stashed clear password.
  7012. * If multiple of them are in the extension, the first one is returned.
  7013. *
  7014. * \param entry is the entry to retrieve the extension from
  7015. *
  7016. * \return a pointer to the clear password string. Caller is responsible to free the string.
  7017. */
  7018. char *slapi_get_first_clear_text_pw(Slapi_Entry *entry);
  7019. /**
  7020. * Return the string equivalent of an NSPR error
  7021. * *
  7022. * \param a NSPR error code
  7023. *
  7024. * \return a pointer to the error code string.
  7025. */
  7026. char *slapi_pr_strerror( const PRErrorCode prerrno );
  7027. /**
  7028. * Return the string equivalent of an OS error
  7029. *
  7030. * \param a OS error code
  7031. *
  7032. * \return a pointer to the system error code string.
  7033. */
  7034. const char *slapi_system_strerror( const int syserrno );
  7035. /* event queue routines and data types */
  7036. /**
  7037. * Represents a scheduled event object.
  7038. */
  7039. typedef void* Slapi_Eq_Context;
  7040. /**
  7041. * Represents the function that will be performed when an event is triggered.
  7042. */
  7043. typedef void (*slapi_eq_fn_t)(time_t when, void *arg);
  7044. /**
  7045. * Cause an event to happen exactly once.
  7046. *
  7047. * \param fn The function to call when the event is triggered.
  7048. * \param arg An argument to pass to the called function.
  7049. * \param when The time that the function should be called.
  7050. *
  7051. * \return slapi_eq_context
  7052. */
  7053. Slapi_Eq_Context slapi_eq_once(slapi_eq_fn_t fn, void *arg, time_t when);
  7054. /**
  7055. * Cause an event to happen repeatedly.
  7056. *
  7057. * \param fn The function to call when the vent is triggered.
  7058. * \param arg An argument to pass to the called function.
  7059. * \param when The time that the function should be called.
  7060. * \param interval The amount of time (in milliseconds) between
  7061. * successive calls to the function.
  7062. *
  7063. * \return slapi_eq_context
  7064. */
  7065. Slapi_Eq_Context slapi_eq_repeat(slapi_eq_fn_t fn, void *arg, time_t when, unsigned long interval);
  7066. /**
  7067. * Cause a scheduled event to be canceled.
  7068. *
  7069. * \param ctx The event object to cancel
  7070. *
  7071. * \return 1 If event was found and canceled.
  7072. * \return 0 If event was not found in the queue.
  7073. */
  7074. int slapi_eq_cancel(Slapi_Eq_Context ctx);
  7075. /**
  7076. * Return the event's argument.
  7077. *
  7078. * \param ctx The event object
  7079. *
  7080. * \return A pointer to the event argument.
  7081. */
  7082. void *slapi_eq_get_arg (Slapi_Eq_Context ctx);
  7083. /**
  7084. * Construct a full path and name of a plugin.
  7085. *
  7086. * \param dir The Directory where the plugin is located.
  7087. * \param name The name of the plugin.
  7088. *
  7089. * \return absolute path of the plugin. Caller is responsible to free it.
  7090. */
  7091. char *slapi_get_plugin_name(const char *dir, const char *name);
  7092. /**
  7093. * Takes a encoded password and return the storage scheme.
  7094. * Return the password scheme for value "passwd_val".
  7095. *
  7096. * If "valpwdp" is not NULL, it is set to point to the value with any
  7097. * prefix removed.
  7098. *
  7099. * If no matching scheme is found and first_is_default is non-zero, the
  7100. * first scheme is returned. If no matching scheme is found and
  7101. * first_is_default is zero, NULL is returned.
  7102. *
  7103. * \param passwd_val The password value.
  7104. * \param valpwdp If the char pointer passed is is not NULL, this gets set to the password value
  7105. * without the password storage scheme prefix.
  7106. * \param first_is_default Return the first scheme, if there are no other matches.
  7107. *
  7108. * \return password storage scheme
  7109. */
  7110. PWScheme *slapi_pw_val2scheme( char *passwd_val, char **valpwdp, int first_is_default );
  7111. /**
  7112. * Compare a clear text password to an encoded password value.
  7113. *
  7114. * \param pass_scheme The password scheme.
  7115. * \param clear_pw The clear text password.
  7116. * \param encoded_pw The encoded password value, minus the storage scheme prefix.
  7117. *
  7118. * \return 0 If the passwords match.
  7119. * \return 1 if passwords do not match.
  7120. */
  7121. int slapi_pw_cmp(PWScheme *pass_scheme, char *clear_pw, char *encoded_pw);
  7122. /**
  7123. * Get the password storage scheme name
  7124. *
  7125. * \param pass_scheme The password storage scheme object.
  7126. *
  7127. * \return The storage scheme name.
  7128. */
  7129. char *slapi_pw_get_scheme_name(PWScheme *pass_scheme);
  7130. /**
  7131. * Free a PWScheme object.
  7132. *
  7133. * \param pass_scheme PWScheme object.
  7134. *
  7135. * \return Nothing.
  7136. */
  7137. void slapi_free_pw_scheme(PWScheme *pass_scheme);
  7138. #ifdef __cplusplus
  7139. }
  7140. #endif
  7141. #endif /* _SLAPIPLUGIN */