2 * Copyright 1998-2002 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, struct berval **val, int *iscritical);
58 void slapi_register_supported_control(char *controloid, unsigned long controlops);
59 #define SLAPI_OPERATION_BIND 0x00000001L
60 #define SLAPI_OPERATION_UNBIND 0x00000002L
61 #define SLAPI_OPERATION_SEARCH 0x00000004L
62 #define SLAPI_OPERATION_MODIFY 0x00000008L
63 #define SLAPI_OPERATION_ADD 0x00000010L
64 #define SLAPI_OPERATION_DELETE 0x00000020L
65 #define SLAPI_OPERATION_MODDN 0x00000040L
66 #define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN
67 #define SLAPI_OPERATION_COMPARE 0x00000080L
68 #define SLAPI_OPERATION_ABANDON 0x00000100L
69 #define SLAPI_OPERATION_EXTENDED 0x00000200L
70 #define SLAPI_OPERATION_ANY 0xFFFFFFFFL
71 #define SLAPI_OPERATION_NONE 0x00000000L
72 int slapi_get_supported_controls(char ***ctrloidsp, unsigned long **ctrlopsp);
73 void slapi_register_supported_saslmechanism(char *mechanism);
74 char **slapi_get_supported_saslmechanisms();
75 char **slapi_get_supported_extended_ops(void);
78 /* send ldap result back */
79 void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched, char *text,
80 int nentries, struct berval **urls );
81 int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **ectrls,
82 char **attrs, int attrsonly );
85 Slapi_Filter *slapi_str2filter( char *str );
86 void slapi_filter_free( Slapi_Filter *f, int recurse );
87 int slapi_filter_get_choice( Slapi_Filter *f);
88 int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
89 Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
90 Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
92 /* internal add/delete/search/modify routines */
93 Slapi_PBlock *slapi_search_internal( char *base, int scope, char *filter,
94 LDAPControl **controls, char **attrs, int attrsonly );
95 Slapi_PBlock *slapi_modify_internal( char *dn, LDAPMod **mods,
96 LDAPControl **controls, int log_change);
97 Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e, LDAPControl **controls, int log_change );
98 Slapi_PBlock *slapi_add_internal( char * dn, LDAPMod **attrs, LDAPControl **controls, int log_changes );
99 Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e, LDAPControl **controls, int log_change );
100 Slapi_PBlock *slapi_delete_internal( char * dn, LDAPControl **controls, int log_change );
101 Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn, char *newParent, int deloldrdn, LDAPControl **controls, int log_change);
102 void slapi_free_search_results_internal(Slapi_PBlock *pb);
104 /* connection related routines */
105 int slapi_is_connection_ssl(Slapi_PBlock *pPB, int *isSSL);
106 int slapi_get_client_port(Slapi_PBlock *pPB, int *fromPort);
108 /* parameters currently supported */
111 /* plugin types supported */
113 #define SLAPI_PLUGIN_DATABASE 1
114 #define SLAPI_PLUGIN_EXTENDEDOP 2
115 #define SLAPI_PLUGIN_PREOPERATION 3
116 #define SLAPI_PLUGIN_POSTOPERATION 4
117 #define SLAPI_PLUGIN_AUDIT 7
121 #define SLAPI_BACKEND 130
122 #define SLAPI_CONNECTION 131
123 #define SLAPI_OPERATION 132
124 #define SLAPI_REQUESTOR_ISROOT 133
125 #define SLAPI_BE_MONITORDN 134
126 #define SLAPI_BE_TYPE 135
127 #define SLAPI_BE_READONLY 136
128 #define SLAPI_BE_LASTMOD 137
129 #define SLAPI_CONN_ID 139
131 /* operation params */
132 #define SLAPI_OPINITIATED_TIME 140
133 #define SLAPI_REQUESTOR_DN 141
134 #define SLAPI_REQUESTOR_ISUPDATEDN 142
136 /* connection structure params*/
137 #define SLAPI_CONN_DN 143
138 #define SLAPI_CONN_AUTHTYPE 144
140 /* Authentication types */
141 #define SLAPD_AUTH_NONE "none"
142 #define SLAPD_AUTH_SIMPLE "simple"
143 #define SLAPD_AUTH_SSL "SSL"
144 #define SLAPD_AUTH_SASL "SASL "
146 /* plugin configuration parmams */
147 #define SLAPI_PLUGIN 3
148 #define SLAPI_PLUGIN_PRIVATE 4
149 #define SLAPI_PLUGIN_TYPE 5
150 #define SLAPI_PLUGIN_ARGV 6
151 #define SLAPI_PLUGIN_ARGC 7
152 #define SLAPI_PLUGIN_VERSION 8
153 #define SLAPI_PLUGIN_OPRETURN 9
154 #define SLAPI_PLUGIN_OBJECT 10
155 #define SLAPI_PLUGIN_DESTROY_FN 11
156 #define SLAPI_PLUGIN_DESCRIPTION 12
158 /* internal opreations params */
159 #define SLAPI_PLUGIN_INTOP_RESULT 15
160 #define SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES 16
161 #define SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS 17
163 /* function pointer params for backends */
164 #define SLAPI_PLUGIN_DB_BIND_FN 200
165 #define SLAPI_PLUGIN_DB_UNBIND_FN 201
166 #define SLAPI_PLUGIN_DB_SEARCH_FN 202
167 #define SLAPI_PLUGIN_DB_COMPARE_FN 203
168 #define SLAPI_PLUGIN_DB_MODIFY_FN 204
169 #define SLAPI_PLUGIN_DB_MODRDN_FN 205
170 #define SLAPI_PLUGIN_DB_ADD_FN 206
171 #define SLAPI_PLUGIN_DB_DELETE_FN 207
172 #define SLAPI_PLUGIN_DB_ABANDON_FN 208
173 #define SLAPI_PLUGIN_DB_CONFIG_FN 209
174 #define SLAPI_PLUGIN_CLOSE_FN 210
175 #define SLAPI_PLUGIN_DB_FLUSH_FN 211
176 #define SLAPI_PLUGIN_START_FN 212
177 #define SLAPI_PLUGIN_DB_SEQ_FN 213
178 #define SLAPI_PLUGIN_DB_ENTRY_FN 214
179 #define SLAPI_PLUGIN_DB_REFERRAL_FN 215
180 #define SLAPI_PLUGIN_DB_RESULT_FN 216
181 #define SLAPI_PLUGIN_DB_LDIF2DB_FN 217
182 #define SLAPI_PLUGIN_DB_DB2LDIF_FN 218
183 #define SLAPI_PLUGIN_DB_BEGIN_FN 219
184 #define SLAPI_PLUGIN_DB_COMMIT_FN 220
185 #define SLAPI_PLUGIN_DB_ABORT_FN 221
186 #define SLAPI_PLUGIN_DB_ARCHIVE2DB_FN 222
187 #define SLAPI_PLUGIN_DB_DB2ARCHIVE_FN 223
188 #define SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN 224
189 #define SLAPI_PLUGIN_DB_FREE_RESULT_SET_FN 225
190 #define SLAPI_PLUGIN_DB_SIZE_FN 226
191 #define SLAPI_PLUGIN_DB_TEST_FN 227
194 /* functions pointers for LDAP V3 extended ops */
195 #define SLAPI_PLUGIN_EXT_OP_FN 300
196 #define SLAPI_PLUGIN_EXT_OP_OIDLIST 301
198 /* functions for preoperation functions */
199 #define SLAPI_PLUGIN_PRE_BIND_FN 401
200 #define SLAPI_PLUGIN_PRE_UNBIND_FN 402
201 #define SLAPI_PLUGIN_PRE_SEARCH_FN 403
202 #define SLAPI_PLUGIN_PRE_COMPARE_FN 404
203 #define SLAPI_PLUGIN_PRE_MODIFY_FN 405
204 #define SLAPI_PLUGIN_PRE_MODRDN_FN 406
205 #define SLAPI_PLUGIN_PRE_ADD_FN 407
206 #define SLAPI_PLUGIN_PRE_DELETE_FN 408
207 #define SLAPI_PLUGIN_PRE_ABANDON_FN 409
208 #define SLAPI_PLUGIN_PRE_ENTRY_FN 410
209 #define SLAPI_PLUGIN_PRE_REFERRAL_FN 411
210 #define SLAPI_PLUGIN_PRE_RESULT_FN 412
212 /* functions for postoperation functions*/
213 #define SLAPI_PLUGIN_POST_BIND_FN 501
214 #define SLAPI_PLUGIN_POST_UNBIND_FN 502
215 #define SLAPI_PLUGIN_POST_SEARCH_FN 503
216 #define SLAPI_PLUGIN_POST_COMPARE_FN 504
217 #define SLAPI_PLUGIN_POST_MODIFY_FN 505
218 #define SLAPI_PLUGIN_POST_MODRDN_FN 506
219 #define SLAPI_PLUGIN_POST_ADD_FN 507
220 #define SLAPI_PLUGIN_POST_DELETE_FN 508
221 #define SLAPI_PLUGIN_POST_ABANDON_FN 509
222 #define SLAPI_PLUGIN_POST_ENTRY_FN 510
223 #define SLAPI_PLUGIN_POST_REFERRAL_FN 511
224 #define SLAPI_PLUGIN_POST_RESULT_FN 512
226 /* audit plugin defines */
227 #define SLAPI_PLUGIN_AUDIT_DATA 1100
228 #define SLAPI_PLUGIN_AUDIT_FN 1101
230 /* managedsait control */
231 #define SLAPI_MANAGEDSAIT 1000
234 #define SLAPI_CONFIG_FILENAME 40
235 #define SLAPI_CONFIG_LINENO 41
236 #define SLAPI_CONFIG_ARGC 42
237 #define SLAPI_CONFIG_ARGV 43
239 /* operational params */
240 #define SLAPI_TARGET_DN 50
241 #define SLAPI_REQCONTROLS 51
243 /* server LDAPv3 controls */
244 #define SLAPI_RESCONTROLS 55
245 #define SLAPI_ADD_RESCONTROL 56
248 #define SLAPI_ADD_TARGET SLAPI_TARGET_DN
249 #define SLAPI_ADD_ENTRY 60
252 #define SLAPI_BIND_TARGET SLAPI_TARGET_DN
253 #define SLAPI_BIND_METHOD 70
254 #define SLAPI_BIND_CREDENTIALS 71
255 #define SLAPI_BIND_SASLMECHANISM 72
256 #define SLAPI_BIND_RET_SASLCREDS 73
259 #define SLAPI_COMPARE_TARGET SLAPI_TARGET_DN
260 #define SLAPI_COMPARE_TYPE 80
261 #define SLAPI_COMPARE_VALUE 81
264 #define SLAPI_DELETE_TARGET SLAPI_TARGET_DN
267 #define SLAPI_MODIFY_TARGET SLAPI_TARGET_DN
268 #define SLAPI_MODIFY_MODS 90
271 #define SLAPI_MODRDN_TARGET SLAPI_TARGET_DN
272 #define SLAPI_MODRDN_NEWRDN 100
273 #define SLAPI_MODRDN_DELOLDRDN 101
274 #define SLAPI_MODRDN_NEWSUPERIOR 102 /* v3 only */
277 #define SLAPI_SEARCH_TARGET SLAPI_TARGET_DN
278 #define SLAPI_SEARCH_SCOPE 110
279 #define SLAPI_SEARCH_DEREF 111
280 #define SLAPI_SEARCH_SIZELIMIT 112
281 #define SLAPI_SEARCH_TIMELIMIT 113
282 #define SLAPI_SEARCH_FILTER 114
283 #define SLAPI_SEARCH_STRFILTER 115
284 #define SLAPI_SEARCH_ATTRS 116
285 #define SLAPI_SEARCH_ATTRSONLY 117
288 #define SLAPI_ABANDON_MSGID 120
290 /* extended operation params */
291 #define SLAPI_EXT_OP_REQ_OID 160
292 #define SLAPI_EXT_OP_REQ_VALUE 161
294 /* extended operation return codes */
295 #define SLAPI_EXT_OP_RET_OID 162
296 #define SLAPI_EXT_OP_RET_VALUE 163
298 #define SLAPI_PLUGIN_EXTENDED_SENT_RESULT -1
300 /* Search result params */
301 #define SLAPI_SEARCH_RESULT_SET 193
302 #define SLAPI_SEARCH_RESULT_ENTRY 194
303 #define SLAPI_NENTRIES 195
304 #define SLAPI_SEARCH_REFERRALS 196
308 #ifndef LDAP_FILTER_AND
309 #define LDAP_FILTER_AND 0xa0L
311 #ifndef LDAP_FILTER_OR
312 #define LDAP_FILTER_OR 0xa1L
314 #ifndef LDAP_FILTER_NOT
315 #define LDAP_FILTER_NOT 0xa2L
317 #ifndef LDAP_FILTER_EQUALITY
318 #define LDAP_FILTER_EQUALITY 0xa3L
320 #ifndef LDAP_FILTER_SUBSTRINGS
321 #define LDAP_FILTER_SUBSTRINGS 0xa4L
323 #ifndef LDAP_FILTER_GE
324 #define LDAP_FILTER_GE 0xa5L
326 #ifndef LDAP_FILTER_LE
327 #define LDAP_FILTER_LE 0xa6L
329 #ifndef LDAP_FILTER_PRESENT
330 #define LDAP_FILTER_PRESENT 0x87L
332 #ifndef LDAP_FILTER_APPROX
333 #define LDAP_FILTER_APPROX 0xa8L
335 #ifndef LDAP_FILTER_EXT_MATCH
336 #define LDAP_FILTER_EXT_MATCH 0xa9L
339 int slapi_log_error( int severity, char *subsystem, char *fmt, ... );
340 #define SLAPI_LOG_FATAL 0
341 #define SLAPI_LOG_TRACE 1
342 #define SLAPI_LOG_PACKETS 2
343 #define SLAPI_LOG_ARGS 3
344 #define SLAPI_LOG_CONNS 4
345 #define SLAPI_LOG_BER 5
346 #define SLAPI_LOG_FILTER 6
347 #define SLAPI_LOG_CONFIG 7
348 #define SLAPI_LOG_ACL 8
349 #define SLAPI_LOG_SHELL 9
350 #define SLAPI_LOG_PARSE 10
351 #define SLAPI_LOG_HOUSE 11
352 #define SLAPI_LOG_REPL 12
353 #define SLAPI_LOG_CACHE 13
354 #define SLAPI_LOG_PLUGIN 14
355 #define SLAPI_LOG_TIMING 15
357 #define SLAPI_PLUGIN_DESCRIPTION 12
358 typedef struct slapi_plugindesc {
362 char *spd_description;
365 #define SLAPI_PLUGIN_VERSION_01 "01"
366 #define SLAPI_PLUGIN_VERSION_02 "02"
367 #define SLAPI_PLUGIN_VERSION_03 "03"
368 #define SLAPI_PLUGIN_CURRENT_VERSION SLAPI_PLUGIN_VERSION_03