slapi-plugin.h 299 KB

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