2 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * (C) Copyright IBM Corp. 1997,2002
7 * Redistribution and use in source and binary forms are permitted
8 * provided that this notice is preserved and that due credit is
9 * given to IBM Corporation. This software is provided ``as is''
10 * without express or implied warranty.
13 #ifndef _SLAPI_PLUGIN_H
14 #define _SLAPI_PLUGIN_H
19 typedef struct slapi_pblock Slapi_PBlock;
20 typedef struct slapi_entry Slapi_Entry;
21 typedef struct slapi_attr Slapi_Attr;
22 typedef struct slapi_filter Slapi_Filter;
26 int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value );
27 int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value );
28 Slapi_PBlock *slapi_pblock_new();
29 void slapi_pblock_destroy( Slapi_PBlock* );
31 /* entry/attr/dn routines */
32 Slapi_Entry *slapi_str2entry( char *s, int flags );
33 char *slapi_entry2str( Slapi_Entry *e, int *len );
34 char *slapi_entry_get_dn( Slapi_Entry *e );
35 void slapi_entry_set_dn( Slapi_Entry *e, char *dn );
36 Slapi_Entry *slapi_entry_dup( Slapi_Entry *e );
37 int slapi_entry_attr_delete( Slapi_Entry *e, char *type );
38 Slapi_Entry *slapi_entry_alloc();
39 void slapi_entry_free( Slapi_Entry *e );
40 int slapi_entry_attr_merge( Slapi_Entry *e, char *type, struct berval **vals );
41 int slapi_entry_attr_find( Slapi_Entry *e, char *type, Slapi_Attr **attr );
42 int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals );
43 char *slapi_dn_normalize( char *dn );
44 char *slapi_dn_normalize_case( char *dn );
45 int slapi_dn_issuffix( char *dn, char *suffix );
46 char *slapi_dn_ignore_case( char *dn );
49 char *slapi_ch_malloc( unsigned long size );
50 void slapi_ch_free( void *ptr );
51 char *slapi_ch_calloc( unsigned long nelem, unsigned long size );
52 char *slapi_ch_realloc( char *block, unsigned long size );
53 char *slapi_ch_strdup( char *s );
56 /* LDAP V3 routines */
57 int slapi_control_present( LDAPControl **controls, char *oid,
58 struct berval **val, int *iscritical);
59 void slapi_register_supported_control(char *controloid,
60 unsigned long controlops);
61 #define SLAPI_OPERATION_BIND 0x00000001L
62 #define SLAPI_OPERATION_UNBIND 0x00000002L
63 #define SLAPI_OPERATION_SEARCH 0x00000004L
64 #define SLAPI_OPERATION_MODIFY 0x00000008L
65 #define SLAPI_OPERATION_ADD 0x00000010L
66 #define SLAPI_OPERATION_DELETE 0x00000020L
67 #define SLAPI_OPERATION_MODDN 0x00000040L
68 #define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN
69 #define SLAPI_OPERATION_COMPARE 0x00000080L
70 #define SLAPI_OPERATION_ABANDON 0x00000100L
71 #define SLAPI_OPERATION_EXTENDED 0x00000200L
72 #define SLAPI_OPERATION_ANY 0xFFFFFFFFL
73 #define SLAPI_OPERATION_NONE 0x00000000L
74 int slapi_get_supported_controls(char ***ctrloidsp, unsigned long **ctrlopsp);
75 void slapi_register_supported_saslmechanism(char *mechanism);
76 char **slapi_get_supported_saslmechanisms();
77 char **slapi_get_supported_extended_ops(void);
80 /* send ldap result back */
81 void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched,
82 char *text, int nentries, struct berval **urls );
83 int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e,
84 LDAPControl **ectrls, char **attrs, int attrsonly );
87 Slapi_Filter *slapi_str2filter( char *str );
88 void slapi_filter_free( Slapi_Filter *f, int recurse );
89 int slapi_filter_get_choice( Slapi_Filter *f);
90 int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
91 Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
92 Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
94 /* internal add/delete/search/modify routines */
95 Slapi_PBlock *slapi_search_internal( char *base, int scope, char *filter,
96 LDAPControl **controls, char **attrs, int attrsonly );
97 Slapi_PBlock *slapi_modify_internal( char *dn, LDAPMod **mods,
98 LDAPControl **controls, int log_change);
99 Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e,
100 LDAPControl **controls, int log_change );
101 Slapi_PBlock *slapi_add_internal( char * dn, LDAPMod **attrs,
102 LDAPControl **controls, int log_changes );
103 Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e,
104 LDAPControl **controls, int log_change );
105 Slapi_PBlock *slapi_delete_internal( char * dn, LDAPControl **controls,
107 Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn,
108 char *newParent, int deloldrdn, LDAPControl **controls,
110 void slapi_free_search_results_internal(Slapi_PBlock *pb);
112 /* connection related routines */
113 int slapi_is_connection_ssl(Slapi_PBlock *pPB, int *isSSL);
114 int slapi_get_client_port(Slapi_PBlock *pPB, int *fromPort);
116 /* parameters currently supported */
119 /* plugin types supported */
121 #define SLAPI_PLUGIN_DATABASE 1
122 #define SLAPI_PLUGIN_EXTENDEDOP 2
123 #define SLAPI_PLUGIN_PREOPERATION 3
124 #define SLAPI_PLUGIN_POSTOPERATION 4
125 #define SLAPI_PLUGIN_AUDIT 7
129 #define SLAPI_BACKEND 130
130 #define SLAPI_CONNECTION 131
131 #define SLAPI_OPERATION 132
132 #define SLAPI_REQUESTOR_ISROOT 133
133 #define SLAPI_BE_MONITORDN 134
134 #define SLAPI_BE_TYPE 135
135 #define SLAPI_BE_READONLY 136
136 #define SLAPI_BE_LASTMOD 137
137 #define SLAPI_CONN_ID 139
139 /* operation params */
140 #define SLAPI_OPINITIATED_TIME 140
141 #define SLAPI_REQUESTOR_DN 141
142 #define SLAPI_REQUESTOR_ISUPDATEDN 142
144 /* connection structure params*/
145 #define SLAPI_CONN_DN 143
146 #define SLAPI_CONN_AUTHTYPE 144
148 /* Authentication types */
149 #define SLAPD_AUTH_NONE "none"
150 #define SLAPD_AUTH_SIMPLE "simple"
151 #define SLAPD_AUTH_SSL "SSL"
152 #define SLAPD_AUTH_SASL "SASL "
154 /* plugin configuration parmams */
155 #define SLAPI_PLUGIN 3
156 #define SLAPI_PLUGIN_PRIVATE 4
157 #define SLAPI_PLUGIN_TYPE 5
158 #define SLAPI_PLUGIN_ARGV 6
159 #define SLAPI_PLUGIN_ARGC 7
160 #define SLAPI_PLUGIN_VERSION 8
161 #define SLAPI_PLUGIN_OPRETURN 9
162 #define SLAPI_PLUGIN_OBJECT 10
163 #define SLAPI_PLUGIN_DESTROY_FN 11
164 #define SLAPI_PLUGIN_DESCRIPTION 12
166 /* internal opreations params */
167 #define SLAPI_PLUGIN_INTOP_RESULT 15
168 #define SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES 16
169 #define SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS 17
171 /* function pointer params for backends */
172 #define SLAPI_PLUGIN_DB_BIND_FN 200
173 #define SLAPI_PLUGIN_DB_UNBIND_FN 201
174 #define SLAPI_PLUGIN_DB_SEARCH_FN 202
175 #define SLAPI_PLUGIN_DB_COMPARE_FN 203
176 #define SLAPI_PLUGIN_DB_MODIFY_FN 204
177 #define SLAPI_PLUGIN_DB_MODRDN_FN 205
178 #define SLAPI_PLUGIN_DB_ADD_FN 206
179 #define SLAPI_PLUGIN_DB_DELETE_FN 207
180 #define SLAPI_PLUGIN_DB_ABANDON_FN 208
181 #define SLAPI_PLUGIN_DB_CONFIG_FN 209
182 #define SLAPI_PLUGIN_CLOSE_FN 210
183 #define SLAPI_PLUGIN_DB_FLUSH_FN 211
184 #define SLAPI_PLUGIN_START_FN 212
185 #define SLAPI_PLUGIN_DB_SEQ_FN 213
186 #define SLAPI_PLUGIN_DB_ENTRY_FN 214
187 #define SLAPI_PLUGIN_DB_REFERRAL_FN 215
188 #define SLAPI_PLUGIN_DB_RESULT_FN 216
189 #define SLAPI_PLUGIN_DB_LDIF2DB_FN 217
190 #define SLAPI_PLUGIN_DB_DB2LDIF_FN 218
191 #define SLAPI_PLUGIN_DB_BEGIN_FN 219
192 #define SLAPI_PLUGIN_DB_COMMIT_FN 220
193 #define SLAPI_PLUGIN_DB_ABORT_FN 221
194 #define SLAPI_PLUGIN_DB_ARCHIVE2DB_FN 222
195 #define SLAPI_PLUGIN_DB_DB2ARCHIVE_FN 223
196 #define SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN 224
197 #define SLAPI_PLUGIN_DB_FREE_RESULT_SET_FN 225
198 #define SLAPI_PLUGIN_DB_SIZE_FN 226
199 #define SLAPI_PLUGIN_DB_TEST_FN 227
202 /* functions pointers for LDAP V3 extended ops */
203 #define SLAPI_PLUGIN_EXT_OP_FN 300
204 #define SLAPI_PLUGIN_EXT_OP_OIDLIST 301
206 /* functions for preoperation functions */
207 #define SLAPI_PLUGIN_PRE_BIND_FN 401
208 #define SLAPI_PLUGIN_PRE_UNBIND_FN 402
209 #define SLAPI_PLUGIN_PRE_SEARCH_FN 403
210 #define SLAPI_PLUGIN_PRE_COMPARE_FN 404
211 #define SLAPI_PLUGIN_PRE_MODIFY_FN 405
212 #define SLAPI_PLUGIN_PRE_MODRDN_FN 406
213 #define SLAPI_PLUGIN_PRE_ADD_FN 407
214 #define SLAPI_PLUGIN_PRE_DELETE_FN 408
215 #define SLAPI_PLUGIN_PRE_ABANDON_FN 409
216 #define SLAPI_PLUGIN_PRE_ENTRY_FN 410
217 #define SLAPI_PLUGIN_PRE_REFERRAL_FN 411
218 #define SLAPI_PLUGIN_PRE_RESULT_FN 412
220 /* functions for postoperation functions*/
221 #define SLAPI_PLUGIN_POST_BIND_FN 501
222 #define SLAPI_PLUGIN_POST_UNBIND_FN 502
223 #define SLAPI_PLUGIN_POST_SEARCH_FN 503
224 #define SLAPI_PLUGIN_POST_COMPARE_FN 504
225 #define SLAPI_PLUGIN_POST_MODIFY_FN 505
226 #define SLAPI_PLUGIN_POST_MODRDN_FN 506
227 #define SLAPI_PLUGIN_POST_ADD_FN 507
228 #define SLAPI_PLUGIN_POST_DELETE_FN 508
229 #define SLAPI_PLUGIN_POST_ABANDON_FN 509
230 #define SLAPI_PLUGIN_POST_ENTRY_FN 510
231 #define SLAPI_PLUGIN_POST_REFERRAL_FN 511
232 #define SLAPI_PLUGIN_POST_RESULT_FN 512
234 /* audit plugin defines */
235 #define SLAPI_PLUGIN_AUDIT_DATA 1100
236 #define SLAPI_PLUGIN_AUDIT_FN 1101
238 /* managedsait control */
239 #define SLAPI_MANAGEDSAIT 1000
242 #define SLAPI_CONFIG_FILENAME 40
243 #define SLAPI_CONFIG_LINENO 41
244 #define SLAPI_CONFIG_ARGC 42
245 #define SLAPI_CONFIG_ARGV 43
247 /* operational params */
248 #define SLAPI_TARGET_DN 50
249 #define SLAPI_REQCONTROLS 51
251 /* server LDAPv3 controls */
252 #define SLAPI_RESCONTROLS 55
253 #define SLAPI_ADD_RESCONTROL 56
256 #define SLAPI_ADD_TARGET SLAPI_TARGET_DN
257 #define SLAPI_ADD_ENTRY 60
260 #define SLAPI_BIND_TARGET SLAPI_TARGET_DN
261 #define SLAPI_BIND_METHOD 70
262 #define SLAPI_BIND_CREDENTIALS 71
263 #define SLAPI_BIND_SASLMECHANISM 72
264 #define SLAPI_BIND_RET_SASLCREDS 73
267 #define SLAPI_COMPARE_TARGET SLAPI_TARGET_DN
268 #define SLAPI_COMPARE_TYPE 80
269 #define SLAPI_COMPARE_VALUE 81
272 #define SLAPI_DELETE_TARGET SLAPI_TARGET_DN
275 #define SLAPI_MODIFY_TARGET SLAPI_TARGET_DN
276 #define SLAPI_MODIFY_MODS 90
279 #define SLAPI_MODRDN_TARGET SLAPI_TARGET_DN
280 #define SLAPI_MODRDN_NEWRDN 100
281 #define SLAPI_MODRDN_DELOLDRDN 101
282 #define SLAPI_MODRDN_NEWSUPERIOR 102 /* v3 only */
285 #define SLAPI_SEARCH_TARGET SLAPI_TARGET_DN
286 #define SLAPI_SEARCH_SCOPE 110
287 #define SLAPI_SEARCH_DEREF 111
288 #define SLAPI_SEARCH_SIZELIMIT 112
289 #define SLAPI_SEARCH_TIMELIMIT 113
290 #define SLAPI_SEARCH_FILTER 114
291 #define SLAPI_SEARCH_STRFILTER 115
292 #define SLAPI_SEARCH_ATTRS 116
293 #define SLAPI_SEARCH_ATTRSONLY 117
296 #define SLAPI_ABANDON_MSGID 120
298 /* extended operation params */
299 #define SLAPI_EXT_OP_REQ_OID 160
300 #define SLAPI_EXT_OP_REQ_VALUE 161
302 /* extended operation return codes */
303 #define SLAPI_EXT_OP_RET_OID 162
304 #define SLAPI_EXT_OP_RET_VALUE 163
306 #define SLAPI_PLUGIN_EXTENDED_SENT_RESULT -1
308 /* Search result params */
309 #define SLAPI_SEARCH_RESULT_SET 193
310 #define SLAPI_SEARCH_RESULT_ENTRY 194
311 #define SLAPI_NENTRIES 195
312 #define SLAPI_SEARCH_REFERRALS 196
316 #ifndef LDAP_FILTER_AND
317 #define LDAP_FILTER_AND 0xa0L
319 #ifndef LDAP_FILTER_OR
320 #define LDAP_FILTER_OR 0xa1L
322 #ifndef LDAP_FILTER_NOT
323 #define LDAP_FILTER_NOT 0xa2L
325 #ifndef LDAP_FILTER_EQUALITY
326 #define LDAP_FILTER_EQUALITY 0xa3L
328 #ifndef LDAP_FILTER_SUBSTRINGS
329 #define LDAP_FILTER_SUBSTRINGS 0xa4L
331 #ifndef LDAP_FILTER_GE
332 #define LDAP_FILTER_GE 0xa5L
334 #ifndef LDAP_FILTER_LE
335 #define LDAP_FILTER_LE 0xa6L
337 #ifndef LDAP_FILTER_PRESENT
338 #define LDAP_FILTER_PRESENT 0x87L
340 #ifndef LDAP_FILTER_APPROX
341 #define LDAP_FILTER_APPROX 0xa8L
343 #ifndef LDAP_FILTER_EXT_MATCH
344 #define LDAP_FILTER_EXT_MATCH 0xa9L
347 int slapi_log_error( int severity, char *subsystem, char *fmt, ... );
348 #define SLAPI_LOG_FATAL 0
349 #define SLAPI_LOG_TRACE 1
350 #define SLAPI_LOG_PACKETS 2
351 #define SLAPI_LOG_ARGS 3
352 #define SLAPI_LOG_CONNS 4
353 #define SLAPI_LOG_BER 5
354 #define SLAPI_LOG_FILTER 6
355 #define SLAPI_LOG_CONFIG 7
356 #define SLAPI_LOG_ACL 8
357 #define SLAPI_LOG_SHELL 9
358 #define SLAPI_LOG_PARSE 10
359 #define SLAPI_LOG_HOUSE 11
360 #define SLAPI_LOG_REPL 12
361 #define SLAPI_LOG_CACHE 13
362 #define SLAPI_LOG_PLUGIN 14
363 #define SLAPI_LOG_TIMING 15
365 #define SLAPI_PLUGIN_DESCRIPTION 12
366 typedef struct slapi_plugindesc {
370 char *spd_description;
373 #define SLAPI_PLUGIN_VERSION_01 "01"
374 #define SLAPI_PLUGIN_VERSION_02 "02"
375 #define SLAPI_PLUGIN_VERSION_03 "03"
376 #define SLAPI_PLUGIN_CURRENT_VERSION SLAPI_PLUGIN_VERSION_03
378 #endif /* _SLAPI_PLUGIN_H */