2 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * Portions Copyright IBM Corp. 1997,2002-2003
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
9 * Public License, version 2.7 or later.
17 isOkNetscapeParam( int param )
21 case SLAPI_CONNECTION:
23 case SLAPI_OPERATION_PARAMETERS:
24 case SLAPI_OPERATION_TYPE:
25 case SLAPI_OPERATION_ID:
26 case SLAPI_OPERATION_AUTHTYPE:
27 case SLAPI_REQUESTOR_ISROOT:
28 case SLAPI_BE_MONITORDN:
30 case SLAPI_BE_READONLY:
31 case SLAPI_BE_LASTMOD:
33 case SLAPI_OPINITIATED_TIME:
34 case SLAPI_REQUESTOR_DN:
35 case SLAPI_REQUESTOR_ISUPDATEDN:
37 case SLAPI_CONN_CLIENTIP:
38 case SLAPI_CONN_SERVERIP:
39 case SLAPI_CONN_AUTHTYPE:
40 case SLAPI_CONN_AUTHMETHOD:
42 case SLAPI_X_CONN_IS_UDP:
43 case SLAPI_X_CONN_CLIENTPATH:
44 case SLAPI_X_CONN_SERVERPATH:
45 case SLAPI_X_CONN_SSF:
46 case SLAPI_X_CONN_SASL_CONTEXT:
47 case SLAPI_IBM_CONN_DN_ALT:
48 case SLAPI_IBM_CONN_DN_ORIG:
49 case SLAPI_IBM_GSSAPI_CONTEXT:
51 case SLAPI_PLUGIN_PRIVATE:
52 case SLAPI_PLUGIN_TYPE:
53 case SLAPI_PLUGIN_ARGV:
54 case SLAPI_PLUGIN_ARGC:
55 case SLAPI_PLUGIN_VERSION:
56 case SLAPI_PLUGIN_OPRETURN:
57 case SLAPI_PLUGIN_OBJECT:
58 case SLAPI_PLUGIN_DESTROY_FN:
59 case SLAPI_PLUGIN_DESCRIPTION:
60 case SLAPI_PLUGIN_INTOP_RESULT:
61 case SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES:
62 case SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS:
63 case SLAPI_PLUGIN_DB_BIND_FN:
64 case SLAPI_PLUGIN_DB_UNBIND_FN:
65 case SLAPI_PLUGIN_DB_SEARCH_FN:
66 case SLAPI_PLUGIN_DB_COMPARE_FN:
67 case SLAPI_PLUGIN_DB_MODIFY_FN:
68 case SLAPI_PLUGIN_DB_MODRDN_FN:
69 case SLAPI_PLUGIN_DB_ADD_FN:
70 case SLAPI_PLUGIN_DB_DELETE_FN:
71 case SLAPI_PLUGIN_DB_ABANDON_FN:
72 case SLAPI_PLUGIN_DB_CONFIG_FN:
73 case SLAPI_PLUGIN_CLOSE_FN:
74 case SLAPI_PLUGIN_DB_FLUSH_FN:
75 case SLAPI_PLUGIN_START_FN:
76 case SLAPI_PLUGIN_DB_SEQ_FN:
77 case SLAPI_PLUGIN_DB_ENTRY_FN:
78 case SLAPI_PLUGIN_DB_REFERRAL_FN:
79 case SLAPI_PLUGIN_DB_RESULT_FN:
80 case SLAPI_PLUGIN_DB_LDIF2DB_FN:
81 case SLAPI_PLUGIN_DB_DB2LDIF_FN:
82 case SLAPI_PLUGIN_DB_BEGIN_FN:
83 case SLAPI_PLUGIN_DB_COMMIT_FN:
84 case SLAPI_PLUGIN_DB_ABORT_FN:
85 case SLAPI_PLUGIN_DB_ARCHIVE2DB_FN:
86 case SLAPI_PLUGIN_DB_DB2ARCHIVE_FN:
87 case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN:
88 case SLAPI_PLUGIN_DB_FREE_RESULT_SET_FN:
89 case SLAPI_PLUGIN_DB_SIZE_FN:
90 case SLAPI_PLUGIN_DB_TEST_FN:
91 case SLAPI_PLUGIN_DB_NO_ACL:
92 case SLAPI_PLUGIN_EXT_OP_FN:
93 case SLAPI_PLUGIN_EXT_OP_OIDLIST:
94 case SLAPI_PLUGIN_PRE_BIND_FN:
95 case SLAPI_PLUGIN_PRE_UNBIND_FN:
96 case SLAPI_PLUGIN_PRE_SEARCH_FN:
97 case SLAPI_PLUGIN_PRE_COMPARE_FN:
98 case SLAPI_PLUGIN_PRE_MODIFY_FN:
99 case SLAPI_PLUGIN_PRE_MODRDN_FN:
100 case SLAPI_PLUGIN_PRE_ADD_FN:
101 case SLAPI_PLUGIN_PRE_DELETE_FN:
102 case SLAPI_PLUGIN_PRE_ABANDON_FN:
103 case SLAPI_PLUGIN_PRE_ENTRY_FN:
104 case SLAPI_PLUGIN_PRE_REFERRAL_FN:
105 case SLAPI_PLUGIN_PRE_RESULT_FN:
106 case SLAPI_PLUGIN_POST_BIND_FN:
107 case SLAPI_PLUGIN_POST_UNBIND_FN:
108 case SLAPI_PLUGIN_POST_SEARCH_FN:
109 case SLAPI_PLUGIN_POST_COMPARE_FN:
110 case SLAPI_PLUGIN_POST_MODIFY_FN:
111 case SLAPI_PLUGIN_POST_MODRDN_FN:
112 case SLAPI_PLUGIN_POST_ADD_FN:
113 case SLAPI_PLUGIN_POST_DELETE_FN:
114 case SLAPI_PLUGIN_POST_ABANDON_FN:
115 case SLAPI_PLUGIN_POST_ENTRY_FN:
116 case SLAPI_PLUGIN_POST_REFERRAL_FN:
117 case SLAPI_PLUGIN_POST_RESULT_FN:
118 case SLAPI_PLUGIN_MR_FILTER_CREATE_FN:
119 case SLAPI_PLUGIN_MR_INDEXER_CREATE_FN:
120 case SLAPI_PLUGIN_MR_FILTER_MATCH_FN:
121 case SLAPI_PLUGIN_MR_FILTER_INDEX_FN:
122 case SLAPI_PLUGIN_MR_FILTER_RESET_FN:
123 case SLAPI_PLUGIN_MR_INDEX_FN:
124 case SLAPI_PLUGIN_MR_OID:
125 case SLAPI_PLUGIN_MR_TYPE:
126 case SLAPI_PLUGIN_MR_VALUE:
127 case SLAPI_PLUGIN_MR_VALUES:
128 case SLAPI_PLUGIN_MR_KEYS:
129 case SLAPI_PLUGIN_MR_FILTER_REUSABLE:
130 case SLAPI_PLUGIN_MR_QUERY_OPERATOR:
131 case SLAPI_PLUGIN_MR_USAGE:
133 case SLAPI_OP_LESS_OR_EQUAL:
134 case SLAPI_PLUGIN_MR_USAGE_INDEX:
135 case SLAPI_PLUGIN_SYNTAX_FILTER_AVA:
136 case SLAPI_PLUGIN_SYNTAX_FILTER_SUB:
137 case SLAPI_PLUGIN_SYNTAX_VALUES2KEYS:
138 case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA:
139 case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB:
140 case SLAPI_PLUGIN_SYNTAX_NAMES:
141 case SLAPI_PLUGIN_SYNTAX_OID:
142 case SLAPI_PLUGIN_SYNTAX_FLAGS:
143 case SLAPI_PLUGIN_SYNTAX_COMPARE:
144 case SLAPI_MANAGEDSAIT:
145 case SLAPI_CONFIG_FILENAME:
146 case SLAPI_CONFIG_LINENO:
147 case SLAPI_CONFIG_ARGC:
148 case SLAPI_CONFIG_ARGV:
149 case SLAPI_TARGET_DN:
150 case SLAPI_REQCONTROLS:
151 case SLAPI_ENTRY_PRE_OP:
152 case SLAPI_ENTRY_POST_OP:
153 case SLAPI_RESCONTROLS:
154 case SLAPI_ADD_RESCONTROL:
155 case SLAPI_ADD_ENTRY:
156 case SLAPI_BIND_METHOD:
157 case SLAPI_BIND_CREDENTIALS:
158 case SLAPI_BIND_SASLMECHANISM:
159 case SLAPI_BIND_RET_SASLCREDS:
160 case SLAPI_COMPARE_TYPE:
161 case SLAPI_COMPARE_VALUE:
162 case SLAPI_MODIFY_MODS:
163 case SLAPI_MODRDN_NEWRDN:
164 case SLAPI_MODRDN_DELOLDRDN:
165 case SLAPI_MODRDN_NEWSUPERIOR:
166 case SLAPI_SEARCH_SCOPE:
167 case SLAPI_SEARCH_DEREF:
168 case SLAPI_SEARCH_SIZELIMIT:
169 case SLAPI_SEARCH_TIMELIMIT:
170 case SLAPI_SEARCH_FILTER:
171 case SLAPI_SEARCH_STRFILTER:
172 case SLAPI_SEARCH_ATTRS:
173 case SLAPI_SEARCH_ATTRSONLY:
174 case SLAPI_ABANDON_MSGID:
176 case SLAPI_SEQ_ATTRNAME:
178 case SLAPI_EXT_OP_REQ_OID:
179 case SLAPI_EXT_OP_REQ_VALUE:
180 case SLAPI_EXT_OP_RET_OID:
181 case SLAPI_EXT_OP_RET_VALUE:
182 case SLAPI_MR_FILTER_ENTRY:
183 case SLAPI_MR_FILTER_TYPE:
184 case SLAPI_MR_FILTER_VALUE:
185 case SLAPI_MR_FILTER_OID:
186 case SLAPI_MR_FILTER_DNATTRS:
187 case SLAPI_LDIF2DB_FILE:
188 case SLAPI_LDIF2DB_REMOVEDUPVALS:
189 case SLAPI_DB2LDIF_PRINTKEY:
190 case SLAPI_PARENT_TXN:
192 case SLAPI_SEARCH_RESULT_SET:
193 case SLAPI_SEARCH_RESULT_ENTRY:
195 case SLAPI_SEARCH_REFERRALS:
196 case SLAPI_CHANGENUMBER:
197 case SLAPI_LOG_OPERATION:
199 case SLAPI_RESULT_CODE:
200 case SLAPI_RESULT_TEXT:
201 case SLAPI_RESULT_MATCHED:
202 case SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN:
203 case SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN:
204 case SLAPI_PLUGIN_ACL_ALLOW_ACCESS:
207 return INVALID_PARAM;
212 isValidParam( Slapi_PBlock *pb, int param )
214 if ( pb->ckParams == TRUE ) {
215 if ( IBM_RESERVED( param ) ) return LDAP_SUCCESS;
216 if (param == SLAPI_PLUGIN_AUDIT_FN ||
217 param == SLAPI_PLUGIN_AUDIT_DATA )
219 if ( param < LAST_IBM_PARAM ) {
220 return INVALID_PARAM;
221 } else if ( NETSCAPE_RESERVED( param ) ) {
222 return INVALID_PARAM;
224 return isOkNetscapeParam(param);
232 Lock( Slapi_PBlock *pb )
234 ldap_pvt_thread_mutex_lock(&pb->pblockMutex);
238 unLock( Slapi_PBlock *pb )
240 ldap_pvt_thread_mutex_unlock(&pb->pblockMutex);
244 get( Slapi_PBlock *pb, int param, void **val )
248 if ( isValidParam( pb, param ) == INVALID_PARAM ) {
255 for ( i = 0; i < pb->numParams; i++ ) {
256 if ( pb->curParams[i] == param ) {
257 *val = pb->curVals[i];
266 set( Slapi_PBlock *pb, int param, void *val )
268 #if defined(LDAP_SLAPI)
271 if ( isValidParam( pb, param ) == INVALID_PARAM ) {
277 if ( pb->numParams == PBLOCK_MAX_PARAMS ) {
284 case SLAPI_CONN_AUTHMETHOD:
285 case SLAPI_IBM_CONN_DN_ALT:
286 case SLAPI_IBM_CONN_DN_ORIG:
287 case SLAPI_RESULT_TEXT:
288 case SLAPI_RESULT_MATCHED:
293 for( i = 0; i < pb->numParams; i++ ) {
294 if ( pb->curParams[i] == param ) {
299 if ( i >= pb->numParams ) {
300 pb->curParams[i] = param;
303 if ( freeit ) ch_free( pb->curVals[i] );
304 pb->curVals[i] = val;
308 #endif /* LDAP_SLAPI */
313 clearPB( Slapi_PBlock *pb )
319 checkParams( Slapi_PBlock *pb, int flag )
325 deleteParam( Slapi_PBlock *p, int param )
330 for ( i = 0; i < p->numParams; i++ ) {
331 if ( p->curParams[i] == param ) {
336 if (i >= p->numParams ) {
340 if ( p->numParams > 1 ) {
341 p->curParams[i] = p->curParams[p->numParams];
342 p->curVals[i] = p->curVals[p->numParams];
352 #if defined(LDAP_SLAPI)
355 pb = (Slapi_PBlock *) ch_malloc(sizeof(Slapi_PBlock));
358 ldap_pvt_thread_mutex_init( &pb->pblockMutex );
359 memset( pb->curParams, 0, sizeof(pb->curParams) );
360 memset( pb->curVals, 0, sizeof(pb->curVals) );
361 pb->curParams[0] = SLAPI_IBM_PBLOCK;
362 pb->curVals[0] = NULL;
366 #endif /* LDAP_SLAPI */
371 slapi_pblock_destroy( Slapi_PBlock* pb )
373 #if defined(LDAP_SLAPI)
376 get( pb, SLAPI_CONN_DN,(void **)&str );
382 get( pb, SLAPI_CONN_AUTHMETHOD, (void **)&str );
388 get( pb, SLAPI_IBM_CONN_DN_ALT, (void **)&str );
394 get( pb, SLAPI_IBM_CONN_DN_ORIG, (void **)&str );
399 get( pb, SLAPI_RESULT_TEXT, (void **)&str );
405 get( pb, SLAPI_RESULT_MATCHED, (void **)&str );
411 ldap_pvt_thread_mutex_destroy( &pb->pblockMutex );
414 #endif /* LDAP_SLAPI */
418 slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value )
420 #if defined(LDAP_SLAPI)
421 return get( pb, arg, (void **)value );
422 #endif /* LDAP_SLAPI */
427 slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value )
429 #if defined(LDAP_SLAPI)
434 case SLAPI_CONN_AUTHMETHOD:
435 case SLAPI_IBM_CONN_DN_ALT:
436 case SLAPI_IBM_CONN_DN_ORIG:
437 case SLAPI_RESULT_TEXT:
438 case SLAPI_RESULT_MATCHED:
439 if ( value != NULL ) {
440 pTmp = (void *)slapi_ch_strdup((char *)value);
441 if ( pTmp == NULL ) {
442 return LDAP_NO_MEMORY;
450 return set( pb, arg, pTmp );
451 #endif /* LDAP_SLAPI */
452 return LDAP_NO_MEMORY;
456 slapi_pblock_clear( Slapi_PBlock *pb )
458 #if defined(LDAP_SLAPI)
460 #endif /* LDAP_SLAPI */
464 slapi_pblock_delete_param( Slapi_PBlock *p, int param )
466 #if defined(LDAP_SLAPI)
467 return deleteParam( p, param );
468 #endif /* LDAP_SLAPI */
473 slapi_pblock_check_params( Slapi_PBlock *pb, int flag )
475 #if defined(LDAP_SLAPI)
476 checkParams( pb, flag );
477 #endif /* LDAP_SLAPI */
484 slapi_x_pblock_get_first( Backend *be, Slapi_PBlock **pb )
486 #if defined(LDAP_SLAPI)
488 *pb = (Slapi_PBlock *)be->be_pb;
489 return (*pb == NULL ? LDAP_OTHER : LDAP_SUCCESS);
490 #else /* LDAP_SLAPI */
492 #endif /* LDAP_SLAPI */
499 slapi_x_pblock_get_next( Slapi_PBlock **pb )
501 #if defined(LDAP_SLAPI)
503 return slapi_pblock_get( *pb, SLAPI_IBM_PBLOCK, pb );
504 #else /* LDAP_SLAPI */
506 #endif /* LDAP_SLAPI */