slapi-plugin.h 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. /* slapi-plugin.h - public Directory Server plugin interface */
  42. #ifndef _SLAPIPLUGIN
  43. #define _SLAPIPLUGIN
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. #include "prtypes.h"
  48. #include "ldap.h"
  49. #include "prprf.h"
  50. NSPR_API(PRUint32) PR_snprintf(char *out, PRUint32 outlen, const char *fmt, ...)
  51. #ifdef __GNUC__
  52. __attribute__ ((format (printf, 3, 4)));
  53. #else
  54. ;
  55. #endif
  56. NSPR_API(char*) PR_smprintf(const char *fmt, ...)
  57. #ifdef __GNUC__
  58. __attribute__ ((format (printf, 1, 2)));
  59. #else
  60. ;
  61. #endif
  62. NSPR_API(char*) PR_sprintf_append(char *last, const char *fmt, ...)
  63. #ifdef __GNUC__
  64. __attribute__ ((format (printf, 2, 3)));
  65. #else
  66. ;
  67. #endif
  68. NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...)
  69. #ifdef __GNUC__
  70. __attribute__ ((format (printf, 2, 3)));
  71. #else
  72. ;
  73. #endif
  74. /* NSPR uses the print macros a bit differently than ANSI C. We
  75. * need to use ll for a 64-bit integer, even when a long is 64-bit.
  76. */
  77. #define NSPRIu64 "llu"
  78. #define NSPRI64 "ll"
  79. /*
  80. * The slapi_attr_get_flags() routine returns a bitmap that contains one or
  81. * more of these values.
  82. *
  83. * Note that the flag values 0x0010, 0x0020, 0x4000, and 0x8000 are reserved.
  84. */
  85. #define SLAPI_ATTR_FLAG_SINGLE 0x0001 /* single-valued attribute */
  86. #define SLAPI_ATTR_FLAG_OPATTR 0x0002 /* operational attribute */
  87. #define SLAPI_ATTR_FLAG_READONLY 0x0004 /* read from shipped config file */
  88. #define SLAPI_ATTR_FLAG_STD_ATTR SLAPI_ATTR_FLAG_READONLY /* alias for read only */
  89. #define SLAPI_ATTR_FLAG_OBSOLETE 0x0040 /* an outdated definition */
  90. #define SLAPI_ATTR_FLAG_COLLECTIVE 0x0080 /* collective (not supported) */
  91. #define SLAPI_ATTR_FLAG_NOUSERMOD 0x0100 /* can't be modified over LDAP */
  92. #define SLAPI_ATTR_FLAG_NORMALIZED 0x0200 /* the attr value is normalized */
  93. /* operation flags */
  94. #define SLAPI_OP_FLAG_INTERNAL 0x00020 /* An operation generated by the core server or a plugin. */
  95. #define SLAPI_OP_FLAG_NEVER_CHAIN 0x00800 /* Do not chain the operation */
  96. #define SLAPI_OP_FLAG_NO_ACCESS_CHECK 0x10000 /* Do not check for access control - bypass them */
  97. #define SLAPI_OC_FLAG_REQUIRED 0x0001
  98. #define SLAPI_OC_FLAG_ALLOWED 0x0002
  99. /*
  100. * access control levels
  101. */
  102. #define SLAPI_ACL_COMPARE 0x01
  103. #define SLAPI_ACL_SEARCH 0x02
  104. #define SLAPI_ACL_READ 0x04
  105. #define SLAPI_ACL_WRITE 0x08
  106. #define SLAPI_ACL_DELETE 0x10
  107. #define SLAPI_ACL_ADD 0x20
  108. #define SLAPI_ACL_SELF 0x40
  109. #define SLAPI_ACL_PROXY 0x80
  110. #define SLAPI_ACL_ALL 0x7f
  111. /*
  112. * filter types
  113. */
  114. #define LDAP_FILTER_AND 0xa0L
  115. #define LDAP_FILTER_OR 0xa1L
  116. #define LDAP_FILTER_NOT 0xa2L
  117. #define LDAP_FILTER_EQUALITY 0xa3L
  118. #define LDAP_FILTER_SUBSTRINGS 0xa4L
  119. #define LDAP_FILTER_GE 0xa5L
  120. #define LDAP_FILTER_LE 0xa6L
  121. #define LDAP_FILTER_PRESENT 0x87L
  122. #define LDAP_FILTER_APPROX 0xa8L
  123. #define LDAP_FILTER_EXTENDED 0xa9L
  124. /*
  125. * Sequential access types
  126. */
  127. #define SLAPI_SEQ_FIRST 1
  128. #define SLAPI_SEQ_LAST 2
  129. #define SLAPI_SEQ_PREV 3
  130. #define SLAPI_SEQ_NEXT 4
  131. /*
  132. * return codes from a backend API call
  133. */
  134. #define SLAPI_FAIL_GENERAL -1
  135. #define SLAPI_FAIL_DISKFULL -2
  136. /*
  137. * return codes used by BIND functions
  138. */
  139. #define SLAPI_BIND_SUCCESS 0 /* front end will send result */
  140. #define SLAPI_BIND_FAIL 2 /* back end should send result */
  141. #define SLAPI_BIND_ANONYMOUS 3 /* front end will send result */
  142. /* commonly used attributes names */
  143. #define SLAPI_ATTR_UNIQUEID "nsuniqueid"
  144. #define SLAPI_ATTR_OBJECTCLASS "objectclass"
  145. #define SLAPI_ATTR_VALUE_TOMBSTONE "nsTombstone"
  146. #define SLAPI_ATTR_VALUE_PARENT_UNIQUEID "nsParentUniqueID"
  147. #define SLAPI_ATTR_NSCP_ENTRYDN "nscpEntryDN"
  148. /* opaque structures */
  149. typedef struct slapi_pblock Slapi_PBlock;
  150. typedef struct slapi_entry Slapi_Entry;
  151. typedef struct slapi_attr Slapi_Attr;
  152. typedef struct slapi_value Slapi_Value;
  153. typedef struct slapi_value_set Slapi_ValueSet;
  154. typedef struct slapi_filter Slapi_Filter;
  155. typedef struct backend Slapi_Backend;
  156. typedef struct _guid_t Slapi_UniqueID;
  157. typedef struct op Slapi_Operation;
  158. typedef struct conn Slapi_Connection;
  159. typedef struct slapi_dn Slapi_DN;
  160. typedef struct slapi_rdn Slapi_RDN;
  161. typedef struct slapi_mod Slapi_Mod;
  162. typedef struct slapi_mods Slapi_Mods;
  163. typedef struct slapi_componentid Slapi_ComponentId;
  164. typedef struct slapi_counter Slapi_Counter;
  165. /* Online tasks interface (to support import, export, etc) */
  166. #define SLAPI_TASK_PUBLIC 1 /* tell old plugins that the task api is now public */
  167. typedef struct slapi_task Slapi_Task;
  168. typedef void (*TaskCallbackFn)(Slapi_Task *task);
  169. /*
  170. * The default thread stacksize for nspr21 is 64k (except on IRIX! It's 32k!).
  171. * For OSF, we require a larger stacksize as actual storage allocation is
  172. * higher i.e pointers are allocated 8 bytes but lower 4 bytes are used.
  173. * The value 0 means use the default stacksize.
  174. *
  175. * larger stacksize (256KB) is needed on IRIX due to its 4KB BUFSIZ.
  176. * (@ pthread IRIX porting -- 01/11/99)
  177. *
  178. * Don't know why HP was defined as follows up until DS6.1x. HP BUFSIZ is 1KB
  179. #elif ( defined( hpux ))
  180. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  181. */
  182. #if ( defined( irix ))
  183. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  184. #elif ( defined ( OSF1 ))
  185. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  186. #elif ( defined ( AIX ))
  187. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  188. /* All other platforms use the default stack size */
  189. #else
  190. #define SLAPD_DEFAULT_THREAD_STACKSIZE 0
  191. #endif
  192. /*
  193. * parameter block routines
  194. */
  195. Slapi_PBlock *slapi_pblock_new( void ); /* allocate and initialize */
  196. void slapi_pblock_init( Slapi_PBlock *pb ); /* clear out for re-use */
  197. int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value );
  198. int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value );
  199. void slapi_pblock_destroy( Slapi_PBlock *pb );
  200. /*
  201. * entry routines
  202. */
  203. Slapi_Entry *slapi_str2entry( char *s, int flags );
  204. /* Flags for slapi_str2entry() */
  205. /* Remove duplicate values */
  206. #define SLAPI_STR2ENTRY_REMOVEDUPVALS 1
  207. /* Add any missing values from RDN */
  208. #define SLAPI_STR2ENTRY_ADDRDNVALS 2
  209. /* Provide a hint that the entry is large; this enables some optimizations
  210. related to large entries. */
  211. #define SLAPI_STR2ENTRY_BIGENTRY 4
  212. /* Check to see if the entry is a tombstone; if so, set the tombstone flag
  213. (SLAPI_ENTRY_FLAG_TOMBSTONE) */
  214. #define SLAPI_STR2ENTRY_TOMBSTONE_CHECK 8
  215. /* Ignore entry state information if present */
  216. #define SLAPI_STR2ENTRY_IGNORE_STATE 16
  217. /* Return entries that have a "version: 1" line as part of the LDIF
  218. representation */
  219. #define SLAPI_STR2ENTRY_INCLUDE_VERSION_STR 32
  220. /* Add any missing ancestor values based on the object class hierarchy */
  221. #define SLAPI_STR2ENTRY_EXPAND_OBJECTCLASSES 64
  222. /* Inform slapi_str2entry() that the LDIF input is not well formed.
  223. Well formed LDIF has no duplicate attribute values, already
  224. has the RDN as an attribute of the entry, and has all values for a
  225. given attribute type listed contiguously. */
  226. #define SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF 128
  227. #define SLAPI_STR2ENTRY_NO_SCHEMA_LOCK 256
  228. char *slapi_entry2str_with_options( Slapi_Entry *e, int *len, int options );
  229. /* Options for slapi_entry2str_with_options() */
  230. #define SLAPI_DUMP_STATEINFO 1 /* replication state */
  231. #define SLAPI_DUMP_UNIQUEID 2 /* unique ID */
  232. #define SLAPI_DUMP_NOOPATTRS 4 /* suppress operational attrs */
  233. #define SLAPI_DUMP_NOWRAP 8 /* no line breaks */
  234. #define SLAPI_DUMP_MINIMAL_ENCODING 16 /* use less base64 encoding */
  235. char *slapi_entry2str( Slapi_Entry *e, int *len );
  236. Slapi_Entry *slapi_entry_alloc(void);
  237. void slapi_entry_init(Slapi_Entry *e, char *dn, Slapi_Attr *a);
  238. void slapi_entry_free( Slapi_Entry *e );
  239. Slapi_Entry *slapi_entry_dup( const Slapi_Entry *e );
  240. char *slapi_entry_get_dn( Slapi_Entry *e );
  241. char *slapi_entry_get_ndn( Slapi_Entry *e );
  242. const Slapi_DN *slapi_entry_get_sdn_const( const Slapi_Entry *e );
  243. Slapi_DN *slapi_entry_get_sdn( Slapi_Entry *e );
  244. const char *slapi_entry_get_dn_const( const Slapi_Entry *e );
  245. void slapi_entry_set_dn( Slapi_Entry *e, char *dn );
  246. void slapi_entry_set_sdn( Slapi_Entry *e, const Slapi_DN *sdn );
  247. int slapi_entry_attr_find( const Slapi_Entry *e, const char *type, Slapi_Attr **attr );
  248. int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr );
  249. int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr );
  250. const char *slapi_entry_get_uniqueid( const Slapi_Entry *e );
  251. void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid );
  252. int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e );
  253. int slapi_entry_rdn_values_present( const Slapi_Entry *e );
  254. int slapi_entry_add_rdn_values( Slapi_Entry *e );
  255. int slapi_entry_attr_delete( Slapi_Entry *e, const char *type );
  256. char **slapi_entry_attr_get_charray(const Slapi_Entry* e, const char *type);
  257. char *slapi_entry_attr_get_charptr(const Slapi_Entry* e, const char *type);
  258. int slapi_entry_attr_get_int(const Slapi_Entry* e, const char *type);
  259. unsigned int slapi_entry_attr_get_uint(const Slapi_Entry* e, const char *type);
  260. long slapi_entry_attr_get_long( const Slapi_Entry* e, const char *type);
  261. unsigned long slapi_entry_attr_get_ulong( const Slapi_Entry* e, const char *type);
  262. long long slapi_entry_attr_get_longlong( const Slapi_Entry* e, const char *type);
  263. unsigned long long slapi_entry_attr_get_ulonglong( const Slapi_Entry* e, const char *type);
  264. PRBool slapi_entry_attr_get_bool( const Slapi_Entry* e, const char *type);
  265. void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value);
  266. void slapi_entry_attr_set_int( Slapi_Entry* e, const char *type, int l);
  267. void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l);
  268. void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
  269. void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l);
  270. int slapi_entry_attr_has_syntax_value(const Slapi_Entry *e, const char *type, const Slapi_Value *value);
  271. int slapi_entry_has_children(const Slapi_Entry *e);
  272. int slapi_is_rootdse( const char *dn );
  273. size_t slapi_entry_size(Slapi_Entry *e);
  274. int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  275. int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  276. int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs);
  277. int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  278. int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  279. int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  280. int slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value);
  281. int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value);
  282. int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value);
  283. void slapi_entry_diff(Slapi_Mods *smods, Slapi_Entry *e1, Slapi_Entry *e2, int diff_ctrl);
  284. int slapi_entry_apply_mods(Slapi_Entry *e, LDAPMod **mods);
  285. /*
  286. * Entry flags.
  287. */
  288. #define SLAPI_ENTRY_FLAG_TOMBSTONE 1
  289. int slapi_entry_flag_is_set( const Slapi_Entry *e, unsigned char flag );
  290. void slapi_entry_set_flag( Slapi_Entry *e, unsigned char flag);
  291. void slapi_entry_clear_flag( Slapi_Entry *e, unsigned char flag);
  292. /* exported vattrcache routines */
  293. int slapi_entry_vattrcache_watermark_isvalid(const Slapi_Entry *e);
  294. void slapi_entry_vattrcache_watermark_set(Slapi_Entry *e);
  295. void slapi_entry_vattrcache_watermark_invalidate(Slapi_Entry *e);
  296. void slapi_entrycache_vattrcache_watermark_invalidate();
  297. /*
  298. * Slapi_DN routines
  299. */
  300. Slapi_DN *slapi_sdn_new( void );
  301. Slapi_DN *slapi_sdn_new_dn_byval(const char *dn);
  302. Slapi_DN *slapi_sdn_new_ndn_byval(const char *ndn);
  303. Slapi_DN *slapi_sdn_new_dn_byref(const char *dn);
  304. Slapi_DN *slapi_sdn_new_ndn_byref(const char *ndn);
  305. Slapi_DN *slapi_sdn_new_dn_passin(const char *dn);
  306. Slapi_DN *slapi_sdn_set_dn_byval(Slapi_DN *sdn, const char *dn);
  307. Slapi_DN *slapi_sdn_set_dn_byref(Slapi_DN *sdn, const char *dn);
  308. Slapi_DN *slapi_sdn_set_dn_passin(Slapi_DN *sdn, const char *dn);
  309. Slapi_DN *slapi_sdn_set_ndn_byval(Slapi_DN *sdn, const char *ndn);
  310. Slapi_DN *slapi_sdn_set_ndn_byref(Slapi_DN *sdn, const char *ndn);
  311. void slapi_sdn_done(Slapi_DN *sdn);
  312. void slapi_sdn_free(Slapi_DN **sdn);
  313. const char * slapi_sdn_get_dn(const Slapi_DN *sdn);
  314. const char * slapi_sdn_get_ndn(const Slapi_DN *sdn);
  315. void slapi_sdn_get_parent(const Slapi_DN *sdn,Slapi_DN *sdn_parent);
  316. void slapi_sdn_get_backend_parent(const Slapi_DN *sdn,Slapi_DN *sdn_parent,const Slapi_Backend *backend);
  317. Slapi_DN * slapi_sdn_dup(const Slapi_DN *sdn);
  318. void slapi_sdn_copy(const Slapi_DN *from, Slapi_DN *to);
  319. int slapi_sdn_compare( const Slapi_DN *sdn1, const Slapi_DN *sdn2 );
  320. int slapi_sdn_isempty( const Slapi_DN *sdn);
  321. int slapi_sdn_issuffix(const Slapi_DN *sdn, const Slapi_DN *suffixsdn);
  322. int slapi_sdn_isparent( const Slapi_DN *parent, const Slapi_DN *child );
  323. int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child );
  324. int slapi_sdn_get_ndn_len(const Slapi_DN *sdn);
  325. int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope );
  326. void slapi_sdn_get_rdn(const Slapi_DN *sdn,Slapi_RDN *rdn);
  327. Slapi_DN *slapi_sdn_set_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
  328. Slapi_DN *slapi_sdn_set_parent(Slapi_DN *sdn, const Slapi_DN *parentdn);
  329. int slapi_sdn_is_rdn_component(const Slapi_DN *rdn, const Slapi_Attr *a, const Slapi_Value *v);
  330. char * slapi_moddn_get_newdn(Slapi_DN *dn_olddn, char *newrdn, char *newsuperiordn);
  331. /*
  332. * Slapi_RDN functions
  333. */
  334. Slapi_RDN *slapi_rdn_new( void );
  335. Slapi_RDN *slapi_rdn_new_dn(const char *dn);
  336. Slapi_RDN *slapi_rdn_new_sdn(const Slapi_DN *sdn);
  337. Slapi_RDN *slapi_rdn_new_rdn(const Slapi_RDN *fromrdn);
  338. void slapi_rdn_init(Slapi_RDN *rdn);
  339. void slapi_rdn_init_dn(Slapi_RDN *rdn,const char *dn);
  340. void slapi_rdn_init_sdn(Slapi_RDN *rdn,const Slapi_DN *sdn);
  341. void slapi_rdn_init_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn);
  342. void slapi_rdn_set_dn(Slapi_RDN *rdn,const char *dn);
  343. void slapi_rdn_set_sdn(Slapi_RDN *rdn,const Slapi_DN *sdn);
  344. void slapi_rdn_set_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn);
  345. void slapi_rdn_free(Slapi_RDN **rdn);
  346. void slapi_rdn_done(Slapi_RDN *rdn);
  347. int slapi_rdn_get_first(Slapi_RDN *rdn, char **type, char **value);
  348. int slapi_rdn_get_next(Slapi_RDN *rdn, int index, char **type, char **value);
  349. int slapi_rdn_get_index(Slapi_RDN *rdn, const char *type, const char *value,size_t length);
  350. int slapi_rdn_get_index_attr(Slapi_RDN *rdn, const char *type, char **value);
  351. int slapi_rdn_contains(Slapi_RDN *rdn, const char *type, const char *value,size_t length);
  352. int slapi_rdn_contains_attr(Slapi_RDN *rdn, const char *type, char **value);
  353. int slapi_rdn_add(Slapi_RDN *rdn, const char *type, const char *value);
  354. int slapi_rdn_remove_index(Slapi_RDN *rdn, int atindex);
  355. int slapi_rdn_remove(Slapi_RDN *rdn, const char *type, const char *value, size_t length);
  356. int slapi_rdn_remove_attr(Slapi_RDN *rdn, const char *type);
  357. int slapi_rdn_isempty(const Slapi_RDN *rdn);
  358. int slapi_rdn_get_num_components(Slapi_RDN *rdn);
  359. int slapi_rdn_compare(Slapi_RDN *rdn1, Slapi_RDN *rdn2);
  360. const char *slapi_rdn_get_rdn(const Slapi_RDN *rdn);
  361. const char *slapi_rdn_get_nrdn(const Slapi_RDN *rdn);
  362. Slapi_DN *slapi_sdn_add_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
  363. /*
  364. * utility routines for dealing with DNs
  365. */
  366. char *slapi_dn_normalize( char *dn );
  367. char *slapi_dn_normalize_to_end( char *dn, char *end );
  368. char *slapi_dn_ignore_case( char *dn );
  369. char *slapi_dn_normalize_case( char *dn );
  370. char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn );
  371. const char *slapi_dn_find_parent( const char *dn );
  372. char *slapi_dn_parent( const char *dn );
  373. int slapi_dn_issuffix( const char *dn, const char *suffix );
  374. int slapi_dn_isparent( const char *parentdn, const char *childdn );
  375. int slapi_dn_isroot( const char *dn );
  376. int slapi_dn_isbesuffix( Slapi_PBlock *pb, const char *dn );
  377. int slapi_rdn2typeval( char *rdn, char **type, struct berval *bv );
  378. char *slapi_dn_plus_rdn(const char *dn, const char *rdn);
  379. /*
  380. * thread safe random functions
  381. */
  382. int slapi_rand_r(unsigned int * seed);
  383. void slapi_rand_array(void *randx, size_t len);
  384. int slapi_rand();
  385. /*
  386. * attribute routines
  387. */
  388. Slapi_Attr *slapi_attr_new( void );
  389. Slapi_Attr *slapi_attr_init(Slapi_Attr *a, const char *type);
  390. void slapi_attr_free( Slapi_Attr **a );
  391. Slapi_Attr *slapi_attr_dup(const Slapi_Attr *attr);
  392. int slapi_attr_add_value(Slapi_Attr *a, const Slapi_Value *v);
  393. int slapi_attr_type2plugin( const char *type, void **pi );
  394. int slapi_attr_get_type( Slapi_Attr *attr, char **type );
  395. int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp );
  396. int slapi_attr_get_syntax_oid_copy( const Slapi_Attr *a, char **oidp );
  397. int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags );
  398. int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag );
  399. int slapi_attr_value_cmp( const Slapi_Attr *attr, const struct berval *v1, const struct berval *v2 );
  400. int slapi_attr_value_find( const Slapi_Attr *a, const struct berval *v );
  401. int slapi_attr_type_cmp( const char *t1, const char *t2, int opt );
  402. /* Mode of operation (opt) values for slapi_attr_type_cmp() */
  403. #define SLAPI_TYPE_CMP_EXACT 0
  404. #define SLAPI_TYPE_CMP_BASE 1
  405. #define SLAPI_TYPE_CMP_SUBTYPE 2
  406. int slapi_attr_types_equivalent(const char *t1, const char *t2);
  407. char *slapi_attr_basetype( const char *type, char *buf, size_t bufsiz );
  408. int slapi_attr_first_value( Slapi_Attr *a, Slapi_Value **v );
  409. int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v );
  410. int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues);
  411. int slapi_attr_get_valueset(const Slapi_Attr *a, Slapi_ValueSet **vs);
  412. /* Make the valuset in Slapi_Attr be *vs--not a copy */
  413. int slapi_attr_set_valueset(Slapi_Attr *a, const Slapi_ValueSet *vs);
  414. int slapi_attr_set_type(Slapi_Attr *a, const char *type);
  415. int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals );
  416. char * slapi_attr_syntax_normalize( const char *s );
  417. void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
  418. void slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod);
  419. /*
  420. * value routines
  421. */
  422. Slapi_Value *slapi_value_new( void );
  423. Slapi_Value *slapi_value_new_berval(const struct berval *bval);
  424. Slapi_Value *slapi_value_new_value(const Slapi_Value *v);
  425. Slapi_Value *slapi_value_new_string(const char *s);
  426. Slapi_Value *slapi_value_new_string_passin(char *s);
  427. Slapi_Value *slapi_value_init(Slapi_Value *v);
  428. Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval);
  429. Slapi_Value *slapi_value_init_string(Slapi_Value *v,const char *s);
  430. Slapi_Value *slapi_value_init_string_passin(Slapi_Value *v, char *s);
  431. Slapi_Value *slapi_value_dup(const Slapi_Value *v);
  432. void slapi_value_set_flags(Slapi_Value *v, unsigned long flags);
  433. void slapi_values_set_flags(Slapi_Value **vs, unsigned long flags);
  434. unsigned long slapi_value_get_flags(Slapi_Value *v);
  435. void slapi_value_free(Slapi_Value **value);
  436. const struct berval *slapi_value_get_berval( const Slapi_Value *value );
  437. Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bval );
  438. Slapi_Value *slapi_value_set_value( Slapi_Value *value, const Slapi_Value *vfrom);
  439. Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len);
  440. int slapi_value_set_string(Slapi_Value *value, const char *strVal);
  441. int slapi_value_set_string_passin(Slapi_Value *value, char *strVal);
  442. int slapi_value_set_int(Slapi_Value *value, int intVal);
  443. const char*slapi_value_get_string(const Slapi_Value *value);
  444. int slapi_value_get_int(const Slapi_Value *value);
  445. unsigned int slapi_value_get_uint(const Slapi_Value *value);
  446. long slapi_value_get_long(const Slapi_Value *value);
  447. unsigned long slapi_value_get_ulong(const Slapi_Value *value);
  448. long long slapi_value_get_longlong(const Slapi_Value *value);
  449. unsigned long long slapi_value_get_ulonglong(const Slapi_Value *value);
  450. size_t slapi_value_get_length(const Slapi_Value *value);
  451. int slapi_value_compare(const Slapi_Attr *a,const Slapi_Value *v1,const Slapi_Value *v2);
  452. /*
  453. * Valueset functions.
  454. */
  455. #define SLAPI_VALUE_FLAG_PASSIN 0x1
  456. #define SLAPI_VALUE_FLAG_IGNOREERROR 0x2
  457. #define SLAPI_VALUE_FLAG_PRESERVECSNSET 0x4
  458. #define SLAPI_VALUE_FLAG_USENEWVALUE 0x8 /* see valueset_remove_valuearray */
  459. Slapi_ValueSet *slapi_valueset_new( void );
  460. void slapi_valueset_free(Slapi_ValueSet *vs);
  461. void slapi_valueset_init(Slapi_ValueSet *vs);
  462. void slapi_valueset_done(Slapi_ValueSet *vs);
  463. void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval);
  464. void slapi_valueset_add_value_ext(Slapi_ValueSet *vs, Slapi_Value *addval, unsigned long flags);
  465. int slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v );
  466. int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v);
  467. int slapi_valueset_count( const Slapi_ValueSet *vs);
  468. void slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod);
  469. void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
  470. Slapi_Value *slapi_valueset_find(const Slapi_Attr *a, const Slapi_ValueSet *vs, const Slapi_Value *v);
  471. /*
  472. * operation routines
  473. */
  474. int slapi_op_abandoned( Slapi_PBlock *pb );
  475. unsigned long slapi_op_get_type(Slapi_Operation * op);
  476. void slapi_operation_set_flag(Slapi_Operation *op, unsigned long flag);
  477. void slapi_operation_clear_flag(Slapi_Operation *op, unsigned long flag);
  478. int slapi_operation_is_flag_set(Slapi_Operation *op, unsigned long flag);
  479. int slapi_op_reserved(Slapi_PBlock *pb);
  480. void slapi_operation_set_csngen_handler ( Slapi_Operation *op, void *callback );
  481. void slapi_operation_set_replica_attr_handler ( Slapi_Operation *op, void *callback );
  482. int slapi_operation_get_replica_attr ( Slapi_PBlock *pb, Slapi_Operation *op, const char *type, void *value );
  483. char *slapi_op_type_to_string(unsigned long type);
  484. /*
  485. * LDAPMod manipulation routines
  486. */
  487. Slapi_Mods* slapi_mods_new( void );
  488. void slapi_mods_init(Slapi_Mods *smods, int initCount);
  489. void slapi_mods_init_byref(Slapi_Mods *smods, LDAPMod **mods);
  490. void slapi_mods_init_passin(Slapi_Mods *smods, LDAPMod **mods);
  491. void slapi_mods_free(Slapi_Mods **smods);
  492. void slapi_mods_done(Slapi_Mods *smods);
  493. void slapi_mods_insert_at(Slapi_Mods *smods, LDAPMod *mod, int pos);
  494. void slapi_mods_insert_smod_at(Slapi_Mods *smods, Slapi_Mod *smod, int pos);
  495. void slapi_mods_insert_before(Slapi_Mods *smods, LDAPMod *mod);
  496. void slapi_mods_insert_smod_before(Slapi_Mods *smods, Slapi_Mod *smod);
  497. void slapi_mods_insert_after(Slapi_Mods *smods, LDAPMod *mod);
  498. void slapi_mods_insert_after(Slapi_Mods *smods, LDAPMod *mod);
  499. void slapi_mods_add( Slapi_Mods *smods, int modtype, const char *type, unsigned long len, const char *val);
  500. void slapi_mods_add_ldapmod(Slapi_Mods *smods, LDAPMod *mod);
  501. void slapi_mods_add_modbvps( Slapi_Mods *smods, int modtype, const char *type, struct berval **bvps );
  502. void slapi_mods_add_mod_values( Slapi_Mods *smods, int modtype, const char *type, Slapi_Value **va );
  503. void slapi_mods_add_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  504. void slapi_mods_add_string( Slapi_Mods *smods, int modtype, const char *type, const char *val);
  505. void slapi_mods_remove(Slapi_Mods *smods);
  506. LDAPMod *slapi_mods_get_first_mod(Slapi_Mods *smods);
  507. LDAPMod *slapi_mods_get_next_mod(Slapi_Mods *smods);
  508. Slapi_Mod *slapi_mods_get_first_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  509. Slapi_Mod *slapi_mods_get_next_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  510. void slapi_mods_iterator_backone(Slapi_Mods *smods);
  511. LDAPMod **slapi_mods_get_ldapmods_byref(Slapi_Mods *smods);
  512. LDAPMod **slapi_mods_get_ldapmods_passout(Slapi_Mods *smods);
  513. int slapi_mods_get_num_mods(const Slapi_Mods *smods);
  514. void slapi_mods_dump(const Slapi_Mods *smods, const char *text);
  515. Slapi_Mod* slapi_mod_new( void );
  516. void slapi_mod_init(Slapi_Mod *smod, int initCount);
  517. void slapi_mod_init_byval(Slapi_Mod *smod, const LDAPMod *mod);
  518. void slapi_mod_init_byref(Slapi_Mod *smod, LDAPMod *mod);
  519. void slapi_mod_init_passin(Slapi_Mod *smod, LDAPMod *mod);
  520. /* init a mod and set the mod values to be a copy of the given valueset */
  521. void slapi_mod_init_valueset_byval(Slapi_Mod *smod, int op, const char *type, const Slapi_ValueSet *svs);
  522. void slapi_mod_add_value(Slapi_Mod *smod, const struct berval *val);
  523. void slapi_mod_remove_value(Slapi_Mod *smod);
  524. struct berval *slapi_mod_get_first_value(Slapi_Mod *smod);
  525. struct berval *slapi_mod_get_next_value(Slapi_Mod *smod);
  526. const char *slapi_mod_get_type(const Slapi_Mod *smod);
  527. int slapi_mod_get_operation(const Slapi_Mod *smod);
  528. void slapi_mod_set_type(Slapi_Mod *smod, const char *type);
  529. void slapi_mod_set_operation(Slapi_Mod *smod, int op);
  530. int slapi_mod_get_num_values(const Slapi_Mod *smod);
  531. const LDAPMod *slapi_mod_get_ldapmod_byref(const Slapi_Mod *smod);
  532. LDAPMod *slapi_mod_get_ldapmod_passout(Slapi_Mod *smod);
  533. void slapi_mod_free(Slapi_Mod **smod);
  534. void slapi_mod_done(Slapi_Mod *mod);
  535. int slapi_mod_isvalid(const Slapi_Mod *mod);
  536. void slapi_mod_dump(LDAPMod *mod, int n);
  537. /* helper functions to translate between entry and a set of mods */
  538. int slapi_mods2entry(Slapi_Entry **e, const char *dn, LDAPMod **attrs);
  539. int slapi_entry2mods(const Slapi_Entry *e, char **dn, LDAPMod ***attrs);
  540. /*
  541. * routines for dealing with filters
  542. */
  543. int slapi_filter_get_choice( Slapi_Filter *f );
  544. int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
  545. int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type );
  546. int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
  547. char ***any, char **final );
  548. Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
  549. Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
  550. Slapi_Filter *slapi_str2filter( char *str );
  551. Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1,
  552. Slapi_Filter *f2 );
  553. Slapi_Filter *slapi_filter_join_ex( int ftype, Slapi_Filter *f1,
  554. Slapi_Filter *f2, int recurse_always );
  555. void slapi_filter_free( Slapi_Filter *f, int recurse );
  556. int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  557. int verify_access );
  558. int slapi_vattr_filter_test( Slapi_PBlock *pb, Slapi_Entry *e,
  559. struct slapi_filter *f, int verify_access);
  560. int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f);
  561. char *slapi_find_matching_paren( const char *str );
  562. int slapi_filter_test_ext( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  563. int verify_access , int only_test_access);
  564. int slapi_vattr_filter_test_ext( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  565. int verify_access , int only_test_access);
  566. int slapi_filter_compare(struct slapi_filter *f1, struct slapi_filter *f2);
  567. Slapi_Filter *slapi_filter_dup(Slapi_Filter *f);
  568. int slapi_filter_changetype(Slapi_Filter *f, const char *newtype);
  569. /*
  570. * slapi_filter_apply() is used to apply a function to each simple filter
  571. * component within a complex filter. A 'simple filter' is anything other
  572. * than AND, OR or NOT.
  573. */
  574. typedef int (*FILTER_APPLY_FN)( Slapi_Filter *f, void *arg);
  575. int slapi_filter_apply( struct slapi_filter *f, FILTER_APPLY_FN fn, void *arg,
  576. int *error_code );
  577. /*
  578. * Possible return values for slapi_filter_apply() and FILTER_APPLY_FNs.
  579. * Note that a FILTER_APPLY_FN should return _STOP or _CONTINUE only.
  580. */
  581. #define SLAPI_FILTER_SCAN_STOP -1 /* premature abort */
  582. #define SLAPI_FILTER_SCAN_ERROR -2 /* an error occurred */
  583. #define SLAPI_FILTER_SCAN_NOMORE 0 /* success */
  584. #define SLAPI_FILTER_SCAN_CONTINUE 1 /* continue scanning */
  585. /* Error codes that slapi_filter_apply() may set in *error_code */
  586. #define SLAPI_FILTER_UNKNOWN_FILTER_TYPE 2
  587. /*
  588. * Bit-Twiddlers
  589. */
  590. unsigned char slapi_setbit_uchar(unsigned char f,unsigned char bitnum);
  591. unsigned char slapi_unsetbit_uchar(unsigned char f,unsigned char bitnum);
  592. int slapi_isbitset_uchar(unsigned char f,unsigned char bitnum);
  593. unsigned int slapi_setbit_int(unsigned int f,unsigned int bitnum);
  594. unsigned int slapi_unsetbit_int(unsigned int f,unsigned int bitnum);
  595. int slapi_isbitset_int(unsigned int f,unsigned int bitnum);
  596. /*
  597. * routines for sending entries and results to the client
  598. */
  599. int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e,
  600. LDAPControl **ectrls, char **attrs, int attrsonly );
  601. void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched,
  602. char *text, int nentries, struct berval **urls );
  603. int slapi_send_ldap_referral( Slapi_PBlock *pb, Slapi_Entry *e,
  604. struct berval **refs, struct berval ***urls );
  605. typedef int (*send_ldap_search_entry_fn_ptr_t)( Slapi_PBlock *pb,
  606. Slapi_Entry *e, LDAPControl **ectrls, char **attrs, int attrsonly );
  607. typedef void (*send_ldap_result_fn_ptr_t)( Slapi_PBlock *pb, int err,
  608. char *matched, char *text, int nentries, struct berval **urls );
  609. typedef int (*send_ldap_referral_fn_ptr_t)( Slapi_PBlock *pb,
  610. Slapi_Entry *e, struct berval **refs, struct berval ***urls );
  611. /*
  612. * matching rule
  613. */
  614. typedef int (*mrFilterMatchFn) (void* filter, Slapi_Entry*, Slapi_Attr* vals);
  615. /* returns: 0 filter matched
  616. * -1 filter did not match
  617. * >0 an LDAP error code
  618. */
  619. int slapi_mr_indexer_create(Slapi_PBlock* opb);
  620. int slapi_mr_filter_index(Slapi_Filter* f, Slapi_PBlock* pb);
  621. int slapi_berval_cmp(const struct berval* L, const struct berval* R);
  622. #define SLAPI_BERVAL_EQ(L,R) ((L)->bv_len == (R)->bv_len && \
  623. ! memcmp ((L)->bv_val, (R)->bv_val, (L)->bv_len))
  624. typedef struct slapi_matchingRuleEntry {
  625. char *mr_oid;
  626. char *mr_oidalias;
  627. char *mr_name;
  628. char *mr_desc;
  629. char *mr_syntax;
  630. int mr_obsolete;
  631. } slapi_matchingRuleEntry;
  632. typedef struct slapi_matchingRuleEntry Slapi_MatchingRuleEntry;
  633. Slapi_MatchingRuleEntry *slapi_matchingrule_new(void);
  634. void slapi_matchingrule_free(Slapi_MatchingRuleEntry **mrEntry,
  635. int freeMembers);
  636. int slapi_matchingrule_get(Slapi_MatchingRuleEntry *mr, int arg, void *value);
  637. int slapi_matchingrule_set(Slapi_MatchingRuleEntry *mr, int arg, void *value);
  638. int slapi_matchingrule_register(Slapi_MatchingRuleEntry *mrEntry);
  639. int slapi_matchingrule_unregister(char *oid);
  640. int slapi_matchingrule_is_ordering(const char *oid_or_name, const char *syntax_oid);
  641. /*
  642. * access control
  643. */
  644. int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr,
  645. struct berval *val, int access );
  646. int slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e,
  647. LDAPMod **mods, char **errbuf );
  648. int slapi_acl_verify_aci_syntax(Slapi_PBlock *pb, Slapi_Entry *e, char **errbuf);
  649. /*
  650. * attribute stuff
  651. */
  652. int slapi_value_find( void *plugin, struct berval **vals, struct berval *v );
  653. /*
  654. * password handling
  655. */
  656. #define SLAPI_USERPWD_ATTR "userpassword"
  657. int slapi_pw_find_sv( Slapi_Value **vals, const Slapi_Value *v );
  658. /* value encoding encoding */
  659. /* checks if the value is encoded with any known algorithm*/
  660. int slapi_is_encoded(char *value);
  661. /* encode value with the specified algorithm */
  662. char* slapi_encode(char *value, char *alg);
  663. /* UTF8 related */
  664. int slapi_has8thBit(unsigned char *s);
  665. unsigned char *slapi_utf8StrToLower(unsigned char *s);
  666. void slapi_utf8ToLower(unsigned char *s, unsigned char *d, int *ssz, int *dsz);
  667. int slapi_utf8isUpper(unsigned char *s);
  668. unsigned char *slapi_utf8StrToUpper(unsigned char *s);
  669. void slapi_utf8ToUpper(unsigned char *s, unsigned char *d, int *ssz, int *dsz);
  670. int slapi_utf8isLower(unsigned char *s);
  671. int slapi_utf8casecmp(unsigned char *s0, unsigned char *s1);
  672. int slapi_utf8ncasecmp(unsigned char *s0, unsigned char *s1, int n);
  673. unsigned char *slapi_UTF8STRTOLOWER(char *s);
  674. void slapi_UTF8TOLOWER(char *s, char *d, int *ssz, int *dsz);
  675. int slapi_UTF8ISUPPER(char *s);
  676. unsigned char *slapi_UTF8STRTOUPPER(char *s);
  677. void slapi_UTF8TOUPPER(char *s, char *d, int *ssz, int *dsz);
  678. int slapi_UTF8ISLOWER(char *s);
  679. int slapi_UTF8CASECMP(char *s0, char *s1);
  680. int slapi_UTF8NCASECMP(char *s0, char *s1, int n);
  681. /*
  682. * Interface to the API broker service
  683. *
  684. * The API broker allows plugins to publish an API that may be discovered
  685. * and used dynamically at run time by other subsystems e.g. other plugins.
  686. */
  687. /* Function: slapi_apib_register
  688. Description: this function allows publication of an interface
  689. Parameters: guid - a string constant that uniquely identifies the
  690. interface (must exist for the life of the server)
  691. api - a vtable for the published api (must exist for the
  692. life of the server or until the reference count,
  693. if it exists, reaches zero)
  694. Return: 0 if function succeeds
  695. non-zero otherwise
  696. */
  697. int slapi_apib_register(char *guid, void **api); /* publish an interface */
  698. /* Function: slapi_apib_unregister
  699. Description: this function allows removal of a published interface
  700. Parameters: guid - a string constant that uniquely identifies the interface
  701. Return: 0 if function succeeds
  702. non-zero otherwise
  703. */
  704. int slapi_apib_unregister(char *guid); /* remove interface from published list */
  705. /* Function: slapi_apib_get_interface
  706. Description: this function allows retrieval of a published interface,
  707. if the api reference counted, then the reference
  708. count is incremented
  709. Parameters: guid - a string constant that uniquely identifies the
  710. interface requested
  711. api - the retrieved vtable for the published api (must NOT
  712. be freed)
  713. Return: 0 if function succeeds
  714. non-zero otherwise
  715. */
  716. int slapi_apib_get_interface(char *guid, void ***api); /* retrieve an interface for use */
  717. /* Function: slapi_apib_make_reference_counted
  718. Description: this function makes an interface a reference counted interface
  719. it must be called prior to registering the interface
  720. Parameters: api - the api to make a reference counted api
  721. callback - if non-zero, this must be a pointer to a function
  722. which the api broker will call when the ref count for
  723. the api reaches zero. This function must return 0 if
  724. it deregisters the api, non-zero otherwise
  725. api - the retrieved vtable for the published api (must NOT
  726. be freed)
  727. Return: 0 if function succeeds
  728. non-zero otherwise
  729. */
  730. typedef int (*slapi_apib_callback_on_zero)(void **api);
  731. int slapi_apib_make_reference_counted(void **api,
  732. slapi_apib_callback_on_zero callback);
  733. /* Function: slapi_apib_addref
  734. Description: this function adds to the reference count of an api - a
  735. call to this function should be paired with a call
  736. to slapi_apib_release
  737. - ONLY FOR REFERENCE COUNTED APIS
  738. Parameters: api - the api to add a reference to
  739. Return: the new reference count
  740. */
  741. int slapi_apib_addref(void **api);
  742. /* Function: slapi_apib_release
  743. Description: this function adds to the reference count of an api - a
  744. call to this function should be paired with a prior call
  745. to slapi_apib_addref or slapi_apib_get_interface
  746. - ONLY FOR REFERENCE COUNTED APIS
  747. Parameters: api - the api to add a reference to
  748. Return: the new reference count
  749. */
  750. int slapi_apib_release(void **api);
  751. /**** End of API broker interface. *******************************************/
  752. /*
  753. * routines for dealing with controls
  754. */
  755. int slapi_control_present( LDAPControl **controls, char *oid,
  756. struct berval **val, int *iscritical );
  757. void slapi_register_supported_control( char *controloid,
  758. unsigned long controlops );
  759. LDAPControl * slapi_dup_control( LDAPControl *ctrl );
  760. #define SLAPI_OPERATION_BIND 0x00000001UL
  761. #define SLAPI_OPERATION_UNBIND 0x00000002UL
  762. #define SLAPI_OPERATION_SEARCH 0x00000004UL
  763. #define SLAPI_OPERATION_MODIFY 0x00000008UL
  764. #define SLAPI_OPERATION_ADD 0x00000010UL
  765. #define SLAPI_OPERATION_DELETE 0x00000020UL
  766. #define SLAPI_OPERATION_MODDN 0x00000040UL
  767. #define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN
  768. #define SLAPI_OPERATION_COMPARE 0x00000080UL
  769. #define SLAPI_OPERATION_ABANDON 0x00000100UL
  770. #define SLAPI_OPERATION_EXTENDED 0x00000200UL
  771. #define SLAPI_OPERATION_ANY 0xFFFFFFFFUL
  772. #define SLAPI_OPERATION_NONE 0x00000000UL
  773. int slapi_get_supported_controls_copy( char ***ctrloidsp,
  774. unsigned long **ctrlopsp );
  775. int slapi_build_control( char *oid, BerElement *ber,
  776. char iscritical, LDAPControl **ctrlp );
  777. int slapi_build_control_from_berval( char *oid, struct berval *bvp,
  778. char iscritical, LDAPControl **ctrlp );
  779. /* Given an array of controls e.g. LDAPControl **ctrls, add the given
  780. control to the end of the array, growing the array with realloc
  781. e.g. slapi_add_control_ext(&ctrls, newctrl, 1);
  782. if ctrls is NULL, the array will be created with malloc
  783. if copy is true, the given control will be copied
  784. if copy is false, the given control will be used and owned by the array
  785. if copy is false, make sure the control can be freed by ldap_controls_free
  786. */
  787. void slapi_add_control_ext( LDAPControl ***ctrlsp, LDAPControl *newctrl, int copy );
  788. /* Given an array of controls e.g. LDAPControl **ctrls, add all of the given
  789. controls in the newctrls array to the end of ctrls, growing the array with realloc
  790. if ctrls is NULL, the array will be created with malloc
  791. if copy is true, each given control will be copied
  792. if copy is false, each given control will be used and owned by the array
  793. if copy is false, make sure each control can be freed by ldap_controls_free
  794. */
  795. void slapi_add_controls( LDAPControl ***ctrlsp, LDAPControl **newctrls, int copy );
  796. /*
  797. * routines for dealing with extended operations
  798. */
  799. char **slapi_get_supported_extended_ops_copy( void );
  800. /*
  801. * bind, including SASL
  802. */
  803. void slapi_register_supported_saslmechanism( char *mechanism );
  804. char ** slapi_get_supported_saslmechanisms_copy( void );
  805. void slapi_add_auth_response_control( Slapi_PBlock *pb, const char *binddn );
  806. int slapi_add_pwd_control( Slapi_PBlock *pb, char *arg, long time );
  807. int slapi_pwpolicy_make_response_control (Slapi_PBlock *pb, int seconds, int logins, int error);
  808. /* Password Policy Response Control stuff - the error argument above */
  809. #define LDAP_PWPOLICY_PWDEXPIRED 0
  810. #define LDAP_PWPOLICY_ACCTLOCKED 1
  811. #define LDAP_PWPOLICY_CHGAFTERRESET 2
  812. #define LDAP_PWPOLICY_PWDMODNOTALLOWED 3
  813. #define LDAP_PWPOLICY_MUSTSUPPLYOLDPWD 4
  814. #define LDAP_PWPOLICY_INVALIDPWDSYNTAX 5
  815. #define LDAP_PWPOLICY_PWDTOOSHORT 6
  816. #define LDAP_PWPOLICY_PWDTOOYOUNG 7
  817. #define LDAP_PWPOLICY_PWDINHISTORY 8
  818. /*
  819. * routine for freeing the ch_arrays returned by the slapi_get*_copy functions above
  820. */
  821. void slapi_ch_array_free( char **array );
  822. /*
  823. * Add the given string to the given null terminated array.
  824. * s is not copied, so if you want to add a copy of s to the
  825. * array, use slapi_ch_strdup(s)
  826. * if *a is NULL, a new array will be created
  827. */
  828. void slapi_ch_array_add( char ***array, char *string );
  829. /*
  830. * checking routines for allocating and freeing memory
  831. */
  832. char * slapi_ch_malloc( unsigned long size );
  833. char * slapi_ch_realloc( char *block, unsigned long size );
  834. char * slapi_ch_calloc( unsigned long nelem, unsigned long size );
  835. char * slapi_ch_strdup( const char *s );
  836. void slapi_ch_free( void **ptr );
  837. void slapi_ch_free_string( char **s );
  838. struct berval* slapi_ch_bvdup(const struct berval*);
  839. struct berval** slapi_ch_bvecdup(struct berval**);
  840. void slapi_ch_bvfree(struct berval** v);
  841. char * slapi_ch_smprintf(const char *fmt, ...)
  842. #ifdef __GNUC__
  843. __attribute__ ((format (printf, 1, 2)));
  844. #else
  845. ;
  846. #endif
  847. /*
  848. * syntax plugin routines
  849. */
  850. int slapi_call_syntax_values2keys_sv( void *vpi, Slapi_Value **vals,
  851. Slapi_Value ***ivals, int ftype );
  852. int slapi_call_syntax_values2keys_sv_pb( void *vpi, Slapi_Value **vals,
  853. Slapi_Value ***ivals, int ftype, Slapi_PBlock *pb );
  854. int slapi_call_syntax_assertion2keys_ava_sv( void *vpi, Slapi_Value *val,
  855. Slapi_Value ***ivals, int ftype );
  856. int slapi_call_syntax_assertion2keys_sub_sv( void *vpi, char *initial,
  857. char **any, char *final, Slapi_Value ***ivals );
  858. /*
  859. * internal operation and plugin callback routines
  860. */
  861. typedef void (*plugin_result_callback)(int rc, void *callback_data);
  862. typedef int (*plugin_referral_entry_callback)(char * referral,
  863. void *callback_data);
  864. typedef int (*plugin_search_entry_callback)(Slapi_Entry *e,
  865. void *callback_data);
  866. void slapi_free_search_results_internal(Slapi_PBlock *pb);
  867. /*
  868. * The following functions can be used for internal operations based on DN
  869. * as well as on uniqueid. These functions should be used by all new plugins
  870. * and preferrably old plugins should be changed to use them to take
  871. * advantage of new plugin configuration capabilities and to use an
  872. * extensible interface.
  873. *
  874. * These functions return -1 if pb is NULL and 0 otherwise.
  875. * The SLAPI_PLUGIN_INTOP_RESULT pblock parameter should be checked to
  876. * check if the operation was successful.
  877. *
  878. * Helper functions are provided to set up pblock parameters currently used
  879. * by the functions, e.g., slapi_search_internal_set_pb().
  880. * Additional parameters may be set directly in the pblock.
  881. */
  882. int slapi_search_internal_pb(Slapi_PBlock *pb);
  883. int slapi_search_internal_callback_pb(Slapi_PBlock *pb, void *callback_data,
  884. plugin_result_callback prc, plugin_search_entry_callback psec,
  885. plugin_referral_entry_callback prec);
  886. int slapi_add_internal_pb(Slapi_PBlock *pb);
  887. int slapi_modify_internal_pb(Slapi_PBlock *pb);
  888. int slapi_modrdn_internal_pb(Slapi_PBlock *pb);
  889. int slapi_delete_internal_pb(Slapi_PBlock *pb);
  890. int slapi_seq_internal_callback_pb(Slapi_PBlock *pb, void *callback_data,
  891. plugin_result_callback res_callback,
  892. plugin_search_entry_callback srch_callback,
  893. plugin_referral_entry_callback ref_callback);
  894. void slapi_search_internal_set_pb(Slapi_PBlock *pb, const char *base,
  895. int scope, const char *filter, char **attrs, int attrsonly,
  896. LDAPControl **controls, const char *uniqueid,
  897. Slapi_ComponentId *plugin_identity, int operation_flags);
  898. void slapi_add_entry_internal_set_pb(Slapi_PBlock *pb, Slapi_Entry *e,
  899. LDAPControl **controls, Slapi_ComponentId *plugin_identity,
  900. int operation_flags);
  901. int slapi_add_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  902. LDAPMod **attrs, LDAPControl **controls,
  903. Slapi_ComponentId *plugin_identity, int operation_flags);
  904. void slapi_modify_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  905. LDAPMod **mods, LDAPControl **controls, const char *uniqueid,
  906. Slapi_ComponentId *plugin_identity, int operation_flags);
  907. void slapi_rename_internal_set_pb(Slapi_PBlock *pb, const char *olddn,
  908. const char *newrdn, const char *newsuperior, int deloldrdn,
  909. LDAPControl **controls, const char *uniqueid,
  910. Slapi_ComponentId *plugin_identity, int operation_flags);
  911. void slapi_delete_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  912. LDAPControl **controls, const char *uniqueid,
  913. Slapi_ComponentId *plugin_identity, int operation_flags);
  914. void slapi_seq_internal_set_pb(Slapi_PBlock *pb, char *ibase, int type,
  915. char *attrname, char *val, char **attrs, int attrsonly,
  916. LDAPControl **controls, Slapi_ComponentId *plugin_identity,
  917. int operation_flags);
  918. /*
  919. * slapi_search_internal_get_entry() finds an entry given a dn. It returns
  920. * an LDAP error code (LDAP_SUCCESS if all goes well).
  921. */
  922. int slapi_search_internal_get_entry( Slapi_DN *dn, char ** attrlist,
  923. Slapi_Entry **ret_entry , void *caller_identity);
  924. /*
  925. * interface for registering object extensions.
  926. */
  927. typedef void *(*slapi_extension_constructor_fnptr)(void *object, void *parent);
  928. typedef void (*slapi_extension_destructor_fnptr)(void *extension,
  929. void *object, void *parent);
  930. int slapi_register_object_extension( const char *pluginname,
  931. const char *objectname, slapi_extension_constructor_fnptr constructor,
  932. slapi_extension_destructor_fnptr destructor, int *objecttype,
  933. int *extensionhandle);
  934. /* objects that can be extended (possible values for the objectname param.) */
  935. #define SLAPI_EXT_CONNECTION "Connection"
  936. #define SLAPI_EXT_OPERATION "Operation"
  937. #define SLAPI_EXT_ENTRY "Entry"
  938. #define SLAPI_EXT_MTNODE "Mapping Tree Node"
  939. void *slapi_get_object_extension(int objecttype, void *object,
  940. int extensionhandle);
  941. void slapi_set_object_extension(int objecttype, void *object,
  942. int extensionhandle, void *extension);
  943. /*
  944. * interface to allow a plugin to register additional plugins.
  945. */
  946. typedef int (*slapi_plugin_init_fnptr)( Slapi_PBlock *pb );
  947. int slapi_register_plugin( const char *plugintype, int enabled,
  948. const char *initsymbol, slapi_plugin_init_fnptr initfunc,
  949. const char *name, char **argv, void *group_identity);
  950. /*
  951. * logging
  952. */
  953. int slapi_log_error( int severity, char *subsystem, char *fmt, ... )
  954. #ifdef __GNUC__
  955. __attribute__ ((format (printf, 3, 4)));
  956. #else
  957. ;
  958. #endif
  959. /* allowed values for the "severity" parameter */
  960. #define SLAPI_LOG_FATAL 0
  961. #define SLAPI_LOG_TRACE 1
  962. #define SLAPI_LOG_PACKETS 2
  963. #define SLAPI_LOG_ARGS 3
  964. #define SLAPI_LOG_CONNS 4
  965. #define SLAPI_LOG_BER 5
  966. #define SLAPI_LOG_FILTER 6
  967. #define SLAPI_LOG_CONFIG 7
  968. #define SLAPI_LOG_ACL 8
  969. #define SLAPI_LOG_SHELL 9
  970. #define SLAPI_LOG_PARSE 10
  971. #define SLAPI_LOG_HOUSE 11
  972. #define SLAPI_LOG_REPL 12
  973. #define SLAPI_LOG_CACHE 13
  974. #define SLAPI_LOG_PLUGIN 14
  975. #define SLAPI_LOG_TIMING 15
  976. #define SLAPI_LOG_ACLSUMMARY 16
  977. int slapi_is_loglevel_set( const int loglevel );
  978. /*
  979. * locks and synchronization
  980. */
  981. typedef struct slapi_mutex Slapi_Mutex;
  982. typedef struct slapi_condvar Slapi_CondVar;
  983. Slapi_Mutex *slapi_new_mutex( void );
  984. void slapi_destroy_mutex( Slapi_Mutex *mutex );
  985. void slapi_lock_mutex( Slapi_Mutex *mutex );
  986. int slapi_unlock_mutex( Slapi_Mutex *mutex );
  987. Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex );
  988. void slapi_destroy_condvar( Slapi_CondVar *cvar );
  989. int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout );
  990. int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all );
  991. /*
  992. * thread-safe LDAP connections
  993. */
  994. LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared );
  995. void slapi_ldap_unbind( LDAP *ld );
  996. LDAP *
  997. slapi_ldap_init_ext(
  998. const char *ldapurl, /* full ldap url */
  999. const char *hostname, /* can also use this to override
  1000. host in url */
  1001. int port, /* can also use this to override port in url */
  1002. int secure, /* 0 for ldap, 1 for ldaps, 2 for starttls -
  1003. override proto in url */
  1004. int shared, /* if true, LDAP* will be shared among multiple threads */
  1005. const char *filename /* for ldapi */
  1006. );
  1007. int
  1008. slapi_ldap_bind(
  1009. LDAP *ld, /* ldap connection */
  1010. const char *bindid, /* usually a bind DN for simple bind */
  1011. const char *creds, /* usually a password for simple bind */
  1012. const char *mech, /* name of mechanism */
  1013. LDAPControl **serverctrls, /* additional controls to send */
  1014. LDAPControl ***returnedctrls, /* returned controls */
  1015. struct timeval *timeout, /* timeout */
  1016. int *msgidp /* pass in non-NULL for async handling */
  1017. );
  1018. /*
  1019. * computed attributes
  1020. */
  1021. struct _computed_attr_context;
  1022. typedef struct _computed_attr_context computed_attr_context;
  1023. typedef int (*slapi_compute_output_t)(computed_attr_context *c,Slapi_Attr *a , Slapi_Entry *e);
  1024. typedef int (*slapi_compute_callback_t)(computed_attr_context *c,char* type,Slapi_Entry *e,slapi_compute_output_t outputfn);
  1025. typedef int (*slapi_search_rewrite_callback_t)(Slapi_PBlock *pb);
  1026. int slapi_compute_add_evaluator(slapi_compute_callback_t function);
  1027. int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function);
  1028. int compute_rewrite_search_filter(Slapi_PBlock *pb);
  1029. /*
  1030. * routines for dealing with backends
  1031. */
  1032. Slapi_Backend *slapi_be_new( const char *type, const char *name,
  1033. int isprivate, int logchanges );
  1034. void slapi_be_free(Slapi_Backend **be);
  1035. Slapi_Backend *slapi_be_select( const Slapi_DN *sdn );
  1036. Slapi_Backend *slapi_be_select_by_instance_name( const char *name );
  1037. int slapi_be_exist(const Slapi_DN *sdn);
  1038. void slapi_be_delete_onexit(Slapi_Backend *be);
  1039. void slapi_be_set_readonly(Slapi_Backend *be, int readonly);
  1040. int slapi_be_get_readonly(Slapi_Backend *be);
  1041. int slapi_be_getentrypoint(Slapi_Backend *be, int entrypoint, void **ret_fnptr,
  1042. Slapi_PBlock *pb);
  1043. int slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr,
  1044. Slapi_PBlock *pb);
  1045. int slapi_be_logchanges(Slapi_Backend *be);
  1046. int slapi_be_issuffix(const Slapi_Backend *be, const Slapi_DN *suffix );
  1047. void slapi_be_addsuffix(Slapi_Backend *be,const Slapi_DN *suffix);
  1048. char * slapi_be_get_name(Slapi_Backend * be);
  1049. const Slapi_DN *slapi_be_getsuffix(Slapi_Backend *be, int n);
  1050. Slapi_Backend* slapi_get_first_backend(char **cookie);
  1051. Slapi_Backend* slapi_get_next_backend(char *cookie);
  1052. int slapi_be_private( Slapi_Backend *be );
  1053. void * slapi_be_get_instance_info(Slapi_Backend * be);
  1054. void slapi_be_set_instance_info(Slapi_Backend * be, void * data);
  1055. Slapi_DN * slapi_get_first_suffix(void ** node, int show_private);
  1056. Slapi_DN * slapi_get_next_suffix(void ** node, int show_private);
  1057. int slapi_is_root_suffix(Slapi_DN * dn);
  1058. const char * slapi_be_gettype(Slapi_Backend *be);
  1059. int slapi_be_is_flag_set(Slapi_Backend * be, int flag);
  1060. void slapi_be_set_flag(Slapi_Backend * be, int flag);
  1061. #define SLAPI_BE_FLAG_REMOTE_DATA 0x1 /* entries held by backend are remote */
  1062. #define SLAPI_BE_FLAG_DONT_BYPASS_FILTERTEST 0x10 /* force to call filter_test (search only) */
  1063. /* These functions allow a plugin to register for callback when
  1064. * a backend state change
  1065. */
  1066. typedef void (*slapi_backend_state_change_fnptr)(void *handle, char *be_name,
  1067. int old_be_state, int new_be_state);
  1068. void slapi_register_backend_state_change(void * handle, slapi_backend_state_change_fnptr funct);
  1069. int slapi_unregister_backend_state_change(void * handle);
  1070. #define SLAPI_BE_STATE_ON 1 /* backend is ON */
  1071. #define SLAPI_BE_STATE_OFFLINE 2 /* backend is OFFLINE (import process) */
  1072. #define SLAPI_BE_STATE_DELETE 3 /* backend has been deleted */
  1073. /*
  1074. * Distribution.
  1075. */
  1076. /* SLAPI_BE_ALL_BACKENDS is a special value that is returned by
  1077. * a distribution plugin function to indicate that all backends
  1078. * should be searched (it is only used for search operations).
  1079. */
  1080. #define SLAPI_BE_ALL_BACKENDS -1
  1081. /*
  1082. * virtual attribute service
  1083. */
  1084. /* General flags (flags parameter) */
  1085. #define SLAPI_REALATTRS_ONLY 1
  1086. #define SLAPI_VIRTUALATTRS_ONLY 2
  1087. #define SLAPI_VIRTUALATTRS_REQUEST_POINTERS 4 /* I want to receive pointers into the entry, if possible */
  1088. #define SLAPI_VIRTUALATTRS_LIST_OPERATIONAL_ATTRS 8 /* Include operational attributes in attribute lists */
  1089. #define SLAPI_VIRTUALATTRS_SUPPRESS_SUBTYPES 16 /* I want only the requested attribute */
  1090. /* Buffer disposition flags (buffer_flags parameter) */
  1091. #define SLAPI_VIRTUALATTRS_RETURNED_POINTERS 1
  1092. #define SLAPI_VIRTUALATTRS_RETURNED_COPIES 2
  1093. #define SLAPI_VIRTUALATTRS_REALATTRS_ONLY 4
  1094. /* Attribute type name disposition values (type_name_disposition parameter) */
  1095. #define SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_EXACTLY_OR_ALIAS 1
  1096. #define SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_SUBTYPE 2
  1097. #define SLAPI_VIRTUALATTRS_NOT_FOUND -1
  1098. #define SLAPI_VIRTUALATTRS_LOOP_DETECTED -2
  1099. typedef struct _vattr_type_thang vattr_type_thang;
  1100. typedef struct _vattr_get_thang vattr_get_thang;
  1101. vattr_get_thang *slapi_vattr_getthang_first(vattr_get_thang *t);
  1102. vattr_get_thang *slapi_vattr_getthang_next(vattr_get_thang *t);
  1103. int slapi_vattr_values_type_thang_get(
  1104. /* Entry we're interested in */ Slapi_Entry *e,
  1105. /* attr type */ vattr_type_thang *type_thang,
  1106. /* pointer to result set */ Slapi_ValueSet** results,
  1107. int *type_name_disposition, char **actual_type_name, int flags,
  1108. int *buffer_flags);
  1109. int slapi_vattr_values_get(
  1110. /* Entry we're interested in */ Slapi_Entry *e,
  1111. /* attr type name */ char *type,
  1112. /* pointer to result set */ Slapi_ValueSet** results,
  1113. int *type_name_disposition, char **actual_type_name, int flags,
  1114. int *buffer_flags);
  1115. int slapi_vattr_values_get_ex(
  1116. /* Entry we're interested in */ Slapi_Entry *e,
  1117. /* attr type name */ char *type,
  1118. /* pointer to result set */ Slapi_ValueSet*** results,
  1119. int **type_name_disposition, char ***actual_type_name, int flags,
  1120. int *buffer_flags, int *subtype_count);
  1121. int slapi_vattr_namespace_values_get(
  1122. /* Entry we're interested in */ Slapi_Entry *e,
  1123. /* backend namespace dn */ Slapi_DN *namespace_dn,
  1124. /* attr type name */ char *type,
  1125. /* pointer to result set */ Slapi_ValueSet*** results,
  1126. int **type_name_disposition, char ***actual_type_name, int flags,
  1127. int *buffer_flags, int *subtype_count);
  1128. void slapi_vattr_values_free(Slapi_ValueSet **value, char **actual_type_name,
  1129. int flags);
  1130. int slapi_vattr_value_compare(
  1131. /* Entry we're interested in */ Slapi_Entry *e,
  1132. /* attr type name */ char *type,
  1133. Slapi_Value *test_this,/* pointer to result */ int *result,
  1134. int flags);
  1135. int slapi_vattr_namespace_value_compare(
  1136. /* Entry we're interested in */ Slapi_Entry *e,
  1137. /* backend namespace dn */ Slapi_DN *namespace_dn,
  1138. /* attr type name */ const char *type,
  1139. Slapi_Value *test_this,/* pointer to result */ int *result,
  1140. int flags);
  1141. int slapi_vattr_list_attrs(
  1142. /* Entry we're interested in */ Slapi_Entry *e,
  1143. /* pointer to receive the list */ vattr_type_thang **types,
  1144. int flags, int *buffer_flags);
  1145. void slapi_vattr_attrs_free(vattr_type_thang **types, int flags);
  1146. char *vattr_typethang_get_name(vattr_type_thang *t);
  1147. unsigned long vattr_typethang_get_flags(vattr_type_thang *t);
  1148. vattr_type_thang *vattr_typethang_next(vattr_type_thang *t);
  1149. vattr_type_thang *vattr_typethang_first(vattr_type_thang *t);
  1150. int slapi_vattr_schema_check_type(Slapi_Entry *e, char *type);
  1151. /* roles */
  1152. typedef int (*roles_check_fn_type)(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present);
  1153. int slapi_role_check(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present);
  1154. void slapi_register_role_check(roles_check_fn_type check_fn);
  1155. /* DSE */
  1156. /* Front end configuration */
  1157. typedef int (*dseCallbackFn)(Slapi_PBlock *, Slapi_Entry *, Slapi_Entry *,
  1158. int *, char*, void *);
  1159. /*
  1160. * Note: DSE callback functions MUST return one of these three values:
  1161. *
  1162. * SLAPI_DSE_CALLBACK_OK -- no errors occurred; apply changes.
  1163. * SLAPI_DSE_CALLBACK_ERROR -- an error occurred; don't apply changes.
  1164. * SLAPI_DSE_CALLBACK_DO_NOT_APPLY -- no error, but do not apply changes.
  1165. *
  1166. * SLAPI_DSE_CALLBACK_DO_NOT_APPLY should only be returned by modify
  1167. * callbacks (i.e., those registered with operation==SLAPI_OPERATION_MODIFY).
  1168. * A return value of SLAPI_DSE_CALLBACK_DO_NOT_APPLY is treated the same as
  1169. * SLAPI_DSE_CALLBACK_ERROR for all other operations.
  1170. */
  1171. #define SLAPI_DSE_CALLBACK_OK (1)
  1172. #define SLAPI_DSE_CALLBACK_ERROR (-1)
  1173. #define SLAPI_DSE_CALLBACK_DO_NOT_APPLY (0)
  1174. /*
  1175. * Flags for slapi_config_register_callback() and
  1176. * slapi_config_remove_callback()
  1177. */
  1178. #define DSE_FLAG_PREOP 0x0001
  1179. #define DSE_FLAG_POSTOP 0x0002
  1180. /* This is the size of the returntext parameter passed to the config callback function,
  1181. which is the "char *" argument to dseCallbackFn above */
  1182. #define SLAPI_DSE_RETURNTEXT_SIZE 512 /* for use by callback functions */
  1183. int slapi_config_register_callback(int operation, int flags, const char *base, int scope, const char *filter, dseCallbackFn fn, void *fn_arg);
  1184. int slapi_config_remove_callback(int operation, int flags, const char *base, int scope, const char *filter, dseCallbackFn fn);
  1185. /******************************************************************************
  1186. * Online tasks interface (to support import, export, etc)
  1187. * After some cleanup, we could consider making these public.
  1188. */
  1189. /* task states */
  1190. #define SLAPI_TASK_SETUP 0
  1191. #define SLAPI_TASK_RUNNING 1
  1192. #define SLAPI_TASK_FINISHED 2
  1193. #define SLAPI_TASK_CANCELLED 3
  1194. /* task flag (pb_task_flags)*/
  1195. #define SLAPI_TASK_RUNNING_AS_TASK 0x0
  1196. #define SLAPI_TASK_RUNNING_FROM_COMMANDLINE 0x1
  1197. /* task flags (set by the task-control code) */
  1198. #define SLAPI_TASK_DESTROYING 0x01 /* queued event for destruction */
  1199. int slapi_task_register_handler(const char *name, dseCallbackFn func);
  1200. void slapi_task_begin(Slapi_Task *task, int total_work);
  1201. void slapi_task_inc_progress(Slapi_Task *task);
  1202. void slapi_task_finish(Slapi_Task *task, int rc);
  1203. void slapi_task_cancel(Slapi_Task *task, int rc);
  1204. int slapi_task_get_state(Slapi_Task *task);
  1205. void slapi_task_set_data(Slapi_Task *task, void *data);
  1206. void * slapi_task_get_data(Slapi_Task *task);
  1207. void slapi_task_inc_refcount(Slapi_Task *task);
  1208. void slapi_task_dec_refcount(Slapi_Task *task);
  1209. int slapi_task_get_refcount(Slapi_Task *task);
  1210. void slapi_task_set_destructor_fn(Slapi_Task *task, TaskCallbackFn func);
  1211. void slapi_task_set_cancel_fn(Slapi_Task *task, TaskCallbackFn func);
  1212. void slapi_task_status_changed(Slapi_Task *task);
  1213. void slapi_task_log_status(Slapi_Task *task, char *format, ...)
  1214. #ifdef __GNUC__
  1215. __attribute__ ((format (printf, 2, 3)));
  1216. #else
  1217. ;
  1218. #endif
  1219. void slapi_task_log_notice(Slapi_Task *task, char *format, ...)
  1220. #ifdef __GNUC__
  1221. __attribute__ ((format (printf, 2, 3)));
  1222. #else
  1223. ;
  1224. #endif
  1225. /*
  1226. * slapi_new_task: create new task, fill in DN, and setup modify callback
  1227. * argument:
  1228. * dn: task dn
  1229. * result:
  1230. * Success: Slapi_Task object
  1231. * Failure: NULL
  1232. */
  1233. Slapi_Task *slapi_new_task(const char *dn);
  1234. /* slapi_destroy_task: destroy a task
  1235. * argument:
  1236. * task: task to destroy
  1237. * result:
  1238. * none
  1239. */
  1240. void slapi_destroy_task(void *arg);
  1241. /* End of interface to support online tasks **********************************/
  1242. /* Slapi_Counter Interface */
  1243. Slapi_Counter *slapi_counter_new();
  1244. void slapi_counter_init(Slapi_Counter *counter);
  1245. void slapi_counter_destroy(Slapi_Counter **counter);
  1246. PRUint64 slapi_counter_increment(Slapi_Counter *counter);
  1247. PRUint64 slapi_counter_decrement(Slapi_Counter *counter);
  1248. PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue);
  1249. PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue);
  1250. PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue);
  1251. PRUint64 slapi_counter_get_value(Slapi_Counter *counter);
  1252. /* Binder-based (connection centric) resource limits */
  1253. /*
  1254. * Valid values for `type' parameter to slapi_reslimit_register().
  1255. */
  1256. #define SLAPI_RESLIMIT_TYPE_INT 0
  1257. /*
  1258. * Status codes returned by all functions.
  1259. */
  1260. #define SLAPI_RESLIMIT_STATUS_SUCCESS 0 /* goodness */
  1261. #define SLAPI_RESLIMIT_STATUS_NOVALUE 1 /* no value is available */
  1262. #define SLAPI_RESLIMIT_STATUS_INIT_FAILURE 2 /* initialization failed */
  1263. #define SLAPI_RESLIMIT_STATUS_PARAM_ERROR 3 /* bad parameter */
  1264. #define SLAPI_RESLIMIT_STATUS_UNKNOWN_HANDLE 4 /* unregistered handle */
  1265. #define SLAPI_RESLIMIT_STATUS_INTERNAL_ERROR 5 /* unexpected error */
  1266. /*
  1267. * Functions.
  1268. */
  1269. int slapi_reslimit_register( int type, const char *attrname, int *handlep );
  1270. int slapi_reslimit_get_integer_limit( Slapi_Connection *conn, int handle,
  1271. int *limitp );
  1272. /* END of Binder-based resource limits API */
  1273. /*
  1274. * Plugin and parameter block related macros (remainder of this file).
  1275. */
  1276. /*
  1277. * Plugin version. Note that the Directory Server will load version 01
  1278. * and 02 plugins, but some server features require 03 plugins.
  1279. */
  1280. #define SLAPI_PLUGIN_VERSION_01 "01"
  1281. #define SLAPI_PLUGIN_VERSION_02 "02"
  1282. #define SLAPI_PLUGIN_VERSION_03 "03"
  1283. #define SLAPI_PLUGIN_CURRENT_VERSION SLAPI_PLUGIN_VERSION_03
  1284. #define SLAPI_PLUGIN_IS_COMPAT(x) \
  1285. ((strcmp((x), SLAPI_PLUGIN_VERSION_01) == 0) || \
  1286. (strcmp((x), SLAPI_PLUGIN_VERSION_02) == 0) || \
  1287. (strcmp((x), SLAPI_PLUGIN_VERSION_03) == 0))
  1288. #define SLAPI_PLUGIN_IS_V2(x) \
  1289. ((strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_02) == 0) || \
  1290. (strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_03) == 0))
  1291. #define SLAPI_PLUGIN_IS_V3(x) \
  1292. (strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_03) == 0)
  1293. /* this one just has to be human readable */
  1294. #define SLAPI_PLUGIN_SUPPORTED_VERSIONS "01,02,03"
  1295. /*
  1296. * types of plugin interfaces
  1297. */
  1298. #define SLAPI_PLUGIN_EXTENDEDOP 2
  1299. #define SLAPI_PLUGIN_PREOPERATION 3
  1300. #define SLAPI_PLUGIN_POSTOPERATION 4
  1301. #define SLAPI_PLUGIN_MATCHINGRULE 5
  1302. #define SLAPI_PLUGIN_SYNTAX 6
  1303. #define SLAPI_PLUGIN_ACL 7
  1304. #define SLAPI_PLUGIN_BEPREOPERATION 8
  1305. #define SLAPI_PLUGIN_BEPOSTOPERATION 9
  1306. #define SLAPI_PLUGIN_ENTRY 10
  1307. #define SLAPI_PLUGIN_TYPE_OBJECT 11
  1308. #define SLAPI_PLUGIN_INTERNAL_PREOPERATION 12
  1309. #define SLAPI_PLUGIN_INTERNAL_POSTOPERATION 13
  1310. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME 14
  1311. #define SLAPI_PLUGIN_VATTR_SP 15
  1312. #define SLAPI_PLUGIN_REVER_PWD_STORAGE_SCHEME 16
  1313. #define SLAPI_PLUGIN_LDBM_ENTRY_FETCH_STORE 17
  1314. #define SLAPI_PLUGIN_INDEX 18
  1315. /*
  1316. * special return values for extended operation plugins (zero or positive
  1317. * return values should be LDAP error codes as defined in ldap.h)
  1318. */
  1319. #define SLAPI_PLUGIN_EXTENDED_SENT_RESULT -1
  1320. #define SLAPI_PLUGIN_EXTENDED_NOT_HANDLED -2
  1321. /*
  1322. * the following can be used as the second argument to the
  1323. * slapi_pblock_get() and slapi_pblock_set() calls.
  1324. */
  1325. /* backend, connection, operation */
  1326. #define SLAPI_BACKEND 130
  1327. #define SLAPI_CONNECTION 131
  1328. #define SLAPI_OPERATION 132
  1329. #define SLAPI_REQUESTOR_ISROOT 133
  1330. #define SLAPI_BE_TYPE 135
  1331. #define SLAPI_BE_READONLY 136
  1332. #define SLAPI_BE_LASTMOD 137
  1333. #define SLAPI_CONN_ID 139
  1334. #define SLAPI_BACKEND_COUNT 860
  1335. /* operation */
  1336. #define SLAPI_OPINITIATED_TIME 140
  1337. #define SLAPI_REQUESTOR_DN 141
  1338. #define SLAPI_OPERATION_PARAMETERS 138
  1339. #define SLAPI_OPERATION_TYPE 590
  1340. #define SLAPI_OPERATION_AUTHTYPE 741
  1341. #define SLAPI_OPERATION_ID 744
  1342. #define SLAPI_IS_REPLICATED_OPERATION 142
  1343. #define SLAPI_IS_MMR_REPLICATED_OPERATION 153
  1344. #define SLAPI_IS_LEGACY_REPLICATED_OPERATION 154
  1345. #define SLAPI_SKIP_MODIFIED_ATTRS 155
  1346. /* connection */
  1347. #define SLAPI_CONN_DN 143
  1348. #define SLAPI_CONN_CLIENTNETADDR 850
  1349. #define SLAPI_CONN_SERVERNETADDR 851
  1350. #define SLAPI_CONN_IS_REPLICATION_SESSION 149
  1351. #define SLAPI_CONN_IS_SSL_SESSION 747
  1352. #define SLAPI_CONN_CERT 743
  1353. #define SLAPI_CONN_AUTHMETHOD 746
  1354. #define SLAPI_CONN_SASL_SSF 748
  1355. /*
  1356. * Types of authentication for SLAPI_CONN_AUTHMETHOD
  1357. * (and deprecated SLAPI_CONN_AUTHTYPE)
  1358. */
  1359. #define SLAPD_AUTH_NONE "none"
  1360. #define SLAPD_AUTH_SIMPLE "simple"
  1361. #define SLAPD_AUTH_SSL "SSL"
  1362. #define SLAPD_AUTH_SASL "SASL " /* followed by the mechanism name */
  1363. #define SLAPD_AUTH_OS "OS"
  1364. /* Command Line Arguments */
  1365. #define SLAPI_ARGC 147
  1366. #define SLAPI_ARGV 148
  1367. /* Slapd config file directory */
  1368. #define SLAPI_CONFIG_DIRECTORY 281
  1369. /* DSE flags */
  1370. #define SLAPI_DSE_DONT_WRITE_WHEN_ADDING 282
  1371. #define SLAPI_DSE_MERGE_WHEN_ADDING 283
  1372. #define SLAPI_DSE_DONT_CHECK_DUPS 284
  1373. #define SLAPI_DSE_REAPPLY_MODS 287
  1374. #define SLAPI_DSE_IS_PRIMARY_FILE 289
  1375. /* internal schema flags */
  1376. #define SLAPI_SCHEMA_FLAGS 285
  1377. /* urp flags */
  1378. #define SLAPI_URP_NAMING_COLLISION_DN 286
  1379. #define SLAPI_URP_TOMBSTONE_UNIQUEID 288
  1380. /* common to all plugins */
  1381. #define SLAPI_PLUGIN 3
  1382. #define SLAPI_PLUGIN_PRIVATE 4
  1383. #define SLAPI_PLUGIN_TYPE 5
  1384. #define SLAPI_PLUGIN_ARGV 6
  1385. #define SLAPI_PLUGIN_ARGC 7
  1386. #define SLAPI_PLUGIN_VERSION 8
  1387. #define SLAPI_PLUGIN_OPRETURN 9
  1388. #define SLAPI_PLUGIN_OBJECT 10
  1389. #define SLAPI_PLUGIN_DESTROY_FN 11
  1390. #define SLAPI_PLUGIN_DESCRIPTION 12
  1391. typedef struct slapi_plugindesc {
  1392. char *spd_id;
  1393. char *spd_vendor;
  1394. char *spd_version;
  1395. char *spd_description;
  1396. } Slapi_PluginDesc;
  1397. #define SLAPI_PLUGIN_IDENTITY 13
  1398. /* common for internal plugin_ops */
  1399. #define SLAPI_PLUGIN_INTOP_RESULT 15
  1400. #define SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES 16
  1401. #define SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS 17
  1402. /* miscellaneous plugin functions */
  1403. #define SLAPI_PLUGIN_CLOSE_FN 210
  1404. #define SLAPI_PLUGIN_START_FN 212
  1405. #define SLAPI_PLUGIN_CLEANUP_FN 232
  1406. #define SLAPI_PLUGIN_POSTSTART_FN 233
  1407. /* extendedop plugin functions */
  1408. #define SLAPI_PLUGIN_EXT_OP_FN 300
  1409. #define SLAPI_PLUGIN_EXT_OP_OIDLIST 301
  1410. #define SLAPI_PLUGIN_EXT_OP_NAMELIST 302
  1411. /* preoperation plugin functions */
  1412. #define SLAPI_PLUGIN_PRE_BIND_FN 401
  1413. #define SLAPI_PLUGIN_PRE_UNBIND_FN 402
  1414. #define SLAPI_PLUGIN_PRE_SEARCH_FN 403
  1415. #define SLAPI_PLUGIN_PRE_COMPARE_FN 404
  1416. #define SLAPI_PLUGIN_PRE_MODIFY_FN 405
  1417. #define SLAPI_PLUGIN_PRE_MODRDN_FN 406
  1418. #define SLAPI_PLUGIN_PRE_ADD_FN 407
  1419. #define SLAPI_PLUGIN_PRE_DELETE_FN 408
  1420. #define SLAPI_PLUGIN_PRE_ABANDON_FN 409
  1421. #define SLAPI_PLUGIN_PRE_ENTRY_FN 410
  1422. #define SLAPI_PLUGIN_PRE_REFERRAL_FN 411
  1423. #define SLAPI_PLUGIN_PRE_RESULT_FN 412
  1424. /* internal preoperation plugin functions */
  1425. #define SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN 420
  1426. #define SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN 421
  1427. #define SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN 422
  1428. #define SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN 423
  1429. /* preoperation plugin to the backend */
  1430. #define SLAPI_PLUGIN_BE_PRE_ADD_FN 450
  1431. #define SLAPI_PLUGIN_BE_PRE_MODIFY_FN 451
  1432. #define SLAPI_PLUGIN_BE_PRE_MODRDN_FN 452
  1433. #define SLAPI_PLUGIN_BE_PRE_DELETE_FN 453
  1434. /* postoperation plugin functions */
  1435. #define SLAPI_PLUGIN_POST_BIND_FN 501
  1436. #define SLAPI_PLUGIN_POST_UNBIND_FN 502
  1437. #define SLAPI_PLUGIN_POST_SEARCH_FN 503
  1438. #define SLAPI_PLUGIN_POST_COMPARE_FN 504
  1439. #define SLAPI_PLUGIN_POST_MODIFY_FN 505
  1440. #define SLAPI_PLUGIN_POST_MODRDN_FN 506
  1441. #define SLAPI_PLUGIN_POST_ADD_FN 507
  1442. #define SLAPI_PLUGIN_POST_DELETE_FN 508
  1443. #define SLAPI_PLUGIN_POST_ABANDON_FN 509
  1444. #define SLAPI_PLUGIN_POST_ENTRY_FN 510
  1445. #define SLAPI_PLUGIN_POST_REFERRAL_FN 511
  1446. #define SLAPI_PLUGIN_POST_RESULT_FN 512
  1447. #define SLAPI_PLUGIN_POST_SEARCH_FAIL_FN 513
  1448. /* internal preoperation plugin functions */
  1449. #define SLAPI_PLUGIN_INTERNAL_POST_ADD_FN 520
  1450. #define SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN 521
  1451. #define SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN 522
  1452. #define SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN 523
  1453. /* postoperation plugin to the backend */
  1454. #define SLAPI_PLUGIN_BE_POST_ADD_FN 550
  1455. #define SLAPI_PLUGIN_BE_POST_MODIFY_FN 551
  1456. #define SLAPI_PLUGIN_BE_POST_MODRDN_FN 552
  1457. #define SLAPI_PLUGIN_BE_POST_DELETE_FN 553
  1458. /* matching rule plugin functions */
  1459. #define SLAPI_PLUGIN_MR_FILTER_CREATE_FN 600
  1460. #define SLAPI_PLUGIN_MR_INDEXER_CREATE_FN 601
  1461. #define SLAPI_PLUGIN_MR_FILTER_MATCH_FN 602
  1462. #define SLAPI_PLUGIN_MR_FILTER_INDEX_FN 603
  1463. #define SLAPI_PLUGIN_MR_FILTER_RESET_FN 604
  1464. #define SLAPI_PLUGIN_MR_INDEX_FN 605
  1465. /* matching rule plugin arguments */
  1466. #define SLAPI_PLUGIN_MR_OID 610
  1467. #define SLAPI_PLUGIN_MR_TYPE 611
  1468. #define SLAPI_PLUGIN_MR_VALUE 612
  1469. #define SLAPI_PLUGIN_MR_VALUES 613
  1470. #define SLAPI_PLUGIN_MR_KEYS 614
  1471. #define SLAPI_PLUGIN_MR_FILTER_REUSABLE 615
  1472. #define SLAPI_PLUGIN_MR_QUERY_OPERATOR 616
  1473. #define SLAPI_PLUGIN_MR_USAGE 617
  1474. /* Defined values of SLAPI_PLUGIN_MR_QUERY_OPERATOR: */
  1475. #define SLAPI_OP_LESS 1
  1476. #define SLAPI_OP_LESS_OR_EQUAL 2
  1477. #define SLAPI_OP_EQUAL 3
  1478. #define SLAPI_OP_GREATER_OR_EQUAL 4
  1479. #define SLAPI_OP_GREATER 5
  1480. #define SLAPI_OP_SUBSTRING 6
  1481. /* Defined values of SLAPI_PLUGIN_MR_USAGE: */
  1482. #define SLAPI_PLUGIN_MR_USAGE_INDEX 0
  1483. #define SLAPI_PLUGIN_MR_USAGE_SORT 1
  1484. /* Defined values for matchingRuleEntry accessor functions */
  1485. #define SLAPI_MATCHINGRULE_NAME 1
  1486. #define SLAPI_MATCHINGRULE_OID 2
  1487. #define SLAPI_MATCHINGRULE_DESC 3
  1488. #define SLAPI_MATCHINGRULE_SYNTAX 4
  1489. #define SLAPI_MATCHINGRULE_OBSOLETE 5
  1490. /* syntax plugin functions and arguments */
  1491. #define SLAPI_PLUGIN_SYNTAX_FILTER_AVA 700
  1492. #define SLAPI_PLUGIN_SYNTAX_FILTER_SUB 701
  1493. #define SLAPI_PLUGIN_SYNTAX_VALUES2KEYS 702
  1494. #define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA 703
  1495. #define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB 704
  1496. #define SLAPI_PLUGIN_SYNTAX_NAMES 705
  1497. #define SLAPI_PLUGIN_SYNTAX_OID 706
  1498. #define SLAPI_PLUGIN_SYNTAX_FLAGS 707
  1499. #define SLAPI_PLUGIN_SYNTAX_COMPARE 708
  1500. /* user defined substrlen; not stored in slapdplugin, but pblock itself */
  1501. #define SLAPI_SYNTAX_SUBSTRLENS 709
  1502. /* ACL plugin functions and arguments */
  1503. #define SLAPI_PLUGIN_ACL_INIT 730
  1504. #define SLAPI_PLUGIN_ACL_SYNTAX_CHECK 731
  1505. #define SLAPI_PLUGIN_ACL_ALLOW_ACCESS 732
  1506. #define SLAPI_PLUGIN_ACL_MODS_ALLOWED 733
  1507. #define SLAPI_PLUGIN_ACL_MODS_UPDATE 734
  1508. #define ACLPLUGIN_ACCESS_DEFAULT 0
  1509. #define ACLPLUGIN_ACCESS_READ_ON_ENTRY 1
  1510. #define ACLPLUGIN_ACCESS_READ_ON_ATTR 2
  1511. #define ACLPLUGIN_ACCESS_READ_ON_VLV 3
  1512. #define ACLPLUGIN_ACCESS_MODRDN 4
  1513. #define ACLPLUGIN_ACCESS_GET_EFFECTIVE_RIGHTS 5
  1514. /* Authorization types */
  1515. #define SLAPI_BE_MAXNESTLEVEL 742
  1516. #define SLAPI_CLIENT_DNS 745
  1517. /* Password storage scheme functions and arguments */
  1518. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN 800
  1519. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DEC_FN 801 /* only meaningfull for reversible encryption */
  1520. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN 802
  1521. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME 810 /* name of the method: SHA, SSHA... */
  1522. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_USER_PWD 811 /* value sent over LDAP */
  1523. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DB_PWD 812 /* value from the DB */
  1524. /* entry fetch and entry store values */
  1525. #define SLAPI_PLUGIN_ENTRY_FETCH_FUNC 813
  1526. #define SLAPI_PLUGIN_ENTRY_STORE_FUNC 814
  1527. /*
  1528. * Defined values of SLAPI_PLUGIN_SYNTAX_FLAGS:
  1529. */
  1530. #define SLAPI_PLUGIN_SYNTAX_FLAG_ORKEYS 1
  1531. #define SLAPI_PLUGIN_SYNTAX_FLAG_ORDERING 2
  1532. /* controls we know about */
  1533. #define SLAPI_MANAGEDSAIT 1000
  1534. #define SLAPI_PWPOLICY 1001
  1535. /* arguments that are common to all operation */
  1536. #define SLAPI_TARGET_ADDRESS 48 /* target address (dn + uniqueid) should be normalized */
  1537. #define SLAPI_TARGET_UNIQUEID 49 /* target uniqueid of the operation */
  1538. #define SLAPI_TARGET_DN 50 /* target dn of the operation should be normalized */
  1539. #define SLAPI_REQCONTROLS 51 /* request controls */
  1540. /* Copies of entry before and after add, mod, mod[r]dn operations */
  1541. #define SLAPI_ENTRY_PRE_OP 52
  1542. #define SLAPI_ENTRY_POST_OP 53
  1543. /* LDAPv3 controls to be sent with the operation result */
  1544. #define SLAPI_RESCONTROLS 55
  1545. #define SLAPI_ADD_RESCONTROL 56 /* add result control */
  1546. /* Extra notes to be logged within access log RESULT lines */
  1547. #define SLAPI_OPERATION_NOTES 57
  1548. #define SLAPI_OP_NOTE_UNINDEXED 0x01
  1549. /* Allows controls to be passed before operation object is created */
  1550. #define SLAPI_CONTROLS_ARG 58
  1551. /* specify whether pblock content should be destroyed when the pblock is destroyed */
  1552. #define SLAPI_DESTROY_CONTENT 59
  1553. /* add arguments */
  1554. #define SLAPI_ADD_TARGET SLAPI_TARGET_DN
  1555. #define SLAPI_ADD_ENTRY 60
  1556. #define SLAPI_ADD_EXISTING_DN_ENTRY 61
  1557. #define SLAPI_ADD_PARENT_ENTRY 62
  1558. #define SLAPI_ADD_PARENT_UNIQUEID 63
  1559. #define SLAPI_ADD_EXISTING_UNIQUEID_ENTRY 64
  1560. /* bind arguments */
  1561. #define SLAPI_BIND_TARGET SLAPI_TARGET_DN
  1562. #define SLAPI_BIND_METHOD 70
  1563. #define SLAPI_BIND_CREDENTIALS 71 /* v3 only */
  1564. #define SLAPI_BIND_SASLMECHANISM 72 /* v3 only */
  1565. /* bind return values */
  1566. #define SLAPI_BIND_RET_SASLCREDS 73 /* v3 only */
  1567. /* compare arguments */
  1568. #define SLAPI_COMPARE_TARGET SLAPI_TARGET_DN
  1569. #define SLAPI_COMPARE_TYPE 80
  1570. #define SLAPI_COMPARE_VALUE 81
  1571. /* delete arguments */
  1572. #define SLAPI_DELETE_TARGET SLAPI_TARGET_DN
  1573. #define SLAPI_DELETE_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  1574. #define SLAPI_DELETE_GLUE_PARENT_ENTRY SLAPI_ADD_PARENT_ENTRY
  1575. /* modify arguments */
  1576. #define SLAPI_MODIFY_TARGET SLAPI_TARGET_DN
  1577. #define SLAPI_MODIFY_MODS 90
  1578. #define SLAPI_MODIFY_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  1579. /* modrdn arguments */
  1580. #define SLAPI_MODRDN_TARGET SLAPI_TARGET_DN
  1581. #define SLAPI_MODRDN_NEWRDN 100
  1582. #define SLAPI_MODRDN_DELOLDRDN 101
  1583. #define SLAPI_MODRDN_NEWSUPERIOR 102 /* v3 only */
  1584. #define SLAPI_MODRDN_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  1585. #define SLAPI_MODRDN_PARENT_ENTRY 104
  1586. #define SLAPI_MODRDN_NEWPARENT_ENTRY 105
  1587. #define SLAPI_MODRDN_TARGET_ENTRY 106
  1588. #define SLAPI_MODRDN_NEWSUPERIOR_ADDRESS 107
  1589. /*
  1590. * unnormalized dn argument (useful for MOD, MODRDN and DEL operations to carry
  1591. * the original non-escaped dn as introduced by the client application)
  1592. */
  1593. #define SLAPI_ORIGINAL_TARGET_DN 109
  1594. #define SLAPI_ORIGINAL_TARGET SLAPI_ORIGINAL_TARGET_DN
  1595. /* search arguments */
  1596. #define SLAPI_SEARCH_TARGET SLAPI_TARGET_DN
  1597. #define SLAPI_SEARCH_SCOPE 110
  1598. #define SLAPI_SEARCH_DEREF 111
  1599. #define SLAPI_SEARCH_SIZELIMIT 112
  1600. #define SLAPI_SEARCH_TIMELIMIT 113
  1601. #define SLAPI_SEARCH_FILTER 114
  1602. #define SLAPI_SEARCH_STRFILTER 115
  1603. #define SLAPI_SEARCH_ATTRS 116
  1604. #define SLAPI_SEARCH_GERATTRS 1160
  1605. #define SLAPI_SEARCH_ATTRSONLY 117
  1606. #define SLAPI_SEARCH_IS_AND 118
  1607. /* abandon arguments */
  1608. #define SLAPI_ABANDON_MSGID 120
  1609. /* seq access arguments */
  1610. #define SLAPI_SEQ_TYPE 150
  1611. #define SLAPI_SEQ_ATTRNAME 151
  1612. #define SLAPI_SEQ_VAL 152
  1613. /* extended operation arguments */
  1614. #define SLAPI_EXT_OP_REQ_OID 160 /* v3 only */
  1615. #define SLAPI_EXT_OP_REQ_VALUE 161 /* v3 only */
  1616. /* extended operation return values */
  1617. #define SLAPI_EXT_OP_RET_OID 162 /* v3 only */
  1618. #define SLAPI_EXT_OP_RET_VALUE 163 /* v3 only */
  1619. /* extended filter arguments */
  1620. #define SLAPI_MR_FILTER_ENTRY 170 /* v3 only */
  1621. #define SLAPI_MR_FILTER_TYPE 171 /* v3 only */
  1622. #define SLAPI_MR_FILTER_VALUE 172 /* v3 only */
  1623. #define SLAPI_MR_FILTER_OID 173 /* v3 only */
  1624. #define SLAPI_MR_FILTER_DNATTRS 174 /* v3 only */
  1625. /* ldif2db arguments */
  1626. /* ldif file to convert to db */
  1627. #define SLAPI_LDIF2DB_FILE 180
  1628. /* check for duplicate values or not */
  1629. #define SLAPI_LDIF2DB_REMOVEDUPVALS 185
  1630. /* index only this attribute from existing database */
  1631. #define SLAPI_DB2INDEX_ATTRS 186
  1632. /* do not generate attribute indexes */
  1633. #define SLAPI_LDIF2DB_NOATTRINDEXES 187
  1634. /* list if DNs to include */
  1635. #define SLAPI_LDIF2DB_INCLUDE 188
  1636. /* list of DNs to exclude */
  1637. #define SLAPI_LDIF2DB_EXCLUDE 189
  1638. /* generate uniqueid */
  1639. #define SLAPI_LDIF2DB_GENERATE_UNIQUEID 175
  1640. #define SLAPI_LDIF2DB_NAMESPACEID 177
  1641. #define SLAPI_LDIF2DB_ENCRYPT 303
  1642. #define SLAPI_DB2LDIF_DECRYPT 304
  1643. /* uniqueid generation options */
  1644. #define SLAPI_UNIQUEID_GENERATE_NONE 0 /* do not generate */
  1645. #define SLAPI_UNIQUEID_GENERATE_TIME_BASED 1 /* generate time based id */
  1646. #define SLAPI_UNIQUEID_GENERATE_NAME_BASED 2 /* generate name based id */
  1647. /* db2ldif arguments */
  1648. /* print keys or not in ldif */
  1649. #define SLAPI_DB2LDIF_PRINTKEY 183
  1650. /* filename to export */
  1651. #define SLAPI_DB2LDIF_FILE 184
  1652. /* dump uniqueid */
  1653. #define SLAPI_DB2LDIF_DUMP_UNIQUEID 176
  1654. #define SLAPI_DB2LDIF_SERVER_RUNNING 197
  1655. /* db2ldif/ldif2db/bak2db/db2bak arguments */
  1656. #define SLAPI_BACKEND_INSTANCE_NAME 178
  1657. #define SLAPI_BACKEND_TASK 179
  1658. #define SLAPI_TASK_FLAGS 181
  1659. /* bulk import (online wire import) */
  1660. #define SLAPI_BULK_IMPORT_ENTRY 182
  1661. #define SLAPI_BULK_IMPORT_STATE 192
  1662. /* the actual states (these are not pblock args) */
  1663. #define SLAPI_BI_STATE_START 1
  1664. #define SLAPI_BI_STATE_DONE 2
  1665. #define SLAPI_BI_STATE_ADD 3
  1666. /* possible error codes from a bulk import */
  1667. #define SLAPI_BI_ERR_BUSY -23 /* backend is busy; try later */
  1668. /* transaction arguments */
  1669. #define SLAPI_PARENT_TXN 190
  1670. #define SLAPI_TXN 191
  1671. /*
  1672. * The following are used to pass information back and forth
  1673. * between the front end and the back end. The backend
  1674. * creates a search result set as an opaque structure and
  1675. * passes a reference to this back to the front end. The
  1676. * front end uses the backend's iterator entry point to
  1677. * step through the results. The entry, nentries, and
  1678. * referrals options, below, are set/read by both the
  1679. * front end and back end while stepping through the
  1680. * search results.
  1681. */
  1682. /* Search result set */
  1683. #define SLAPI_SEARCH_RESULT_SET 193
  1684. /* Search result - next entry returned from search result set */
  1685. #define SLAPI_SEARCH_RESULT_ENTRY 194
  1686. #define SLAPI_SEARCH_RESULT_ENTRY_EXT 1944
  1687. /* Number of entries returned from search */
  1688. #define SLAPI_NENTRIES 195
  1689. /* Any referrals encountered during the search */
  1690. #define SLAPI_SEARCH_REFERRALS 196
  1691. #define SLAPI_RESULT_CODE 881
  1692. #define SLAPI_RESULT_TEXT 882
  1693. #define SLAPI_RESULT_MATCHED 883
  1694. #define SLAPI_PB_RESULT_TEXT 885
  1695. /* Size of the database, in kilobytes */
  1696. #define SLAPI_DBSIZE 199
  1697. /* convenience macros for checking modify operation types */
  1698. #define SLAPI_IS_MOD_ADD(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_ADD)
  1699. #define SLAPI_IS_MOD_DELETE(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_DELETE)
  1700. #define SLAPI_IS_MOD_REPLACE(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_REPLACE)
  1701. #ifdef __cplusplus
  1702. }
  1703. #endif
  1704. #endif /* _SLAPIPLUGIN */