1 /* $OpenLDAP: pkg/ldap/servers/slapd/slapi/slapi_pblock.c,v 1.63.2.7 2008/02/11 23:26:49 kurt Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2002-2008 The OpenLDAP Foundation.
5 * Portions Copyright 1997,2002-2003 IBM Corporation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by IBM Corporation for use in
18 * IBM products and subsequently ported to OpenLDAP Software by
19 * Steve Omrani. Additional significant contributors include:
29 /* some parameters require a valid connection and operation */
30 #define PBLOCK_LOCK_CONN( _pb ) do { \
31 ldap_pvt_thread_mutex_lock( &(_pb)->pb_conn->c_mutex ); \
34 #define PBLOCK_UNLOCK_CONN( _pb ) do { \
35 ldap_pvt_thread_mutex_unlock( &(_pb)->pb_conn->c_mutex ); \
38 /* some parameters are only settable for internal operations */
39 #define PBLOCK_VALIDATE_IS_INTOP( _pb ) do { if ( (_pb)->pb_intop == 0 ) break; } while ( 0 )
41 static slapi_pblock_class_t
42 pblock_get_param_class( int param
)
45 case SLAPI_PLUGIN_TYPE
:
46 case SLAPI_PLUGIN_ARGC
:
47 case SLAPI_PLUGIN_OPRETURN
:
48 case SLAPI_PLUGIN_INTOP_RESULT
:
49 case SLAPI_CONFIG_LINENO
:
50 case SLAPI_CONFIG_ARGC
:
51 case SLAPI_BIND_METHOD
:
52 case SLAPI_MODRDN_DELOLDRDN
:
53 case SLAPI_SEARCH_SCOPE
:
54 case SLAPI_SEARCH_DEREF
:
55 case SLAPI_SEARCH_SIZELIMIT
:
56 case SLAPI_SEARCH_TIMELIMIT
:
57 case SLAPI_SEARCH_ATTRSONLY
:
59 case SLAPI_CHANGENUMBER
:
61 case SLAPI_REQUESTOR_ISROOT
:
62 case SLAPI_BE_READONLY
:
63 case SLAPI_BE_LASTMOD
:
64 case SLAPI_DB2LDIF_PRINTKEY
:
65 case SLAPI_LDIF2DB_REMOVEDUPVALS
:
66 case SLAPI_MANAGEDSAIT
:
68 case SLAPI_X_OPERATION_NO_SCHEMA_CHECK
:
69 case SLAPI_IS_REPLICATED_OPERATION
:
70 case SLAPI_X_CONN_IS_UDP
:
71 case SLAPI_X_CONN_SSF
:
72 case SLAPI_RESULT_CODE
:
73 case SLAPI_LOG_OPERATION
:
74 case SLAPI_IS_INTERNAL_OPERATION
:
75 return PBLOCK_CLASS_INTEGER
;
79 case SLAPI_OPERATION_ID
:
80 case SLAPI_OPINITIATED_TIME
:
81 case SLAPI_ABANDON_MSGID
:
82 case SLAPI_X_OPERATION_DELETE_GLUE_PARENT
:
83 case SLAPI_OPERATION_MSGID
:
84 return PBLOCK_CLASS_LONG_INTEGER
;
87 case SLAPI_PLUGIN_DESTROY_FN
:
88 case SLAPI_PLUGIN_DB_BIND_FN
:
89 case SLAPI_PLUGIN_DB_UNBIND_FN
:
90 case SLAPI_PLUGIN_DB_SEARCH_FN
:
91 case SLAPI_PLUGIN_DB_COMPARE_FN
:
92 case SLAPI_PLUGIN_DB_MODIFY_FN
:
93 case SLAPI_PLUGIN_DB_MODRDN_FN
:
94 case SLAPI_PLUGIN_DB_ADD_FN
:
95 case SLAPI_PLUGIN_DB_DELETE_FN
:
96 case SLAPI_PLUGIN_DB_ABANDON_FN
:
97 case SLAPI_PLUGIN_DB_CONFIG_FN
:
98 case SLAPI_PLUGIN_CLOSE_FN
:
99 case SLAPI_PLUGIN_DB_FLUSH_FN
:
100 case SLAPI_PLUGIN_START_FN
:
101 case SLAPI_PLUGIN_DB_SEQ_FN
:
102 case SLAPI_PLUGIN_DB_ENTRY_FN
:
103 case SLAPI_PLUGIN_DB_REFERRAL_FN
:
104 case SLAPI_PLUGIN_DB_RESULT_FN
:
105 case SLAPI_PLUGIN_DB_LDIF2DB_FN
:
106 case SLAPI_PLUGIN_DB_DB2LDIF_FN
:
107 case SLAPI_PLUGIN_DB_BEGIN_FN
:
108 case SLAPI_PLUGIN_DB_COMMIT_FN
:
109 case SLAPI_PLUGIN_DB_ABORT_FN
:
110 case SLAPI_PLUGIN_DB_ARCHIVE2DB_FN
:
111 case SLAPI_PLUGIN_DB_DB2ARCHIVE_FN
:
112 case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN
:
113 case SLAPI_PLUGIN_DB_FREE_RESULT_SET_FN
:
114 case SLAPI_PLUGIN_DB_SIZE_FN
:
115 case SLAPI_PLUGIN_DB_TEST_FN
:
116 case SLAPI_PLUGIN_DB_NO_ACL
:
117 case SLAPI_PLUGIN_EXT_OP_FN
:
118 case SLAPI_PLUGIN_EXT_OP_OIDLIST
:
119 case SLAPI_PLUGIN_PRE_BIND_FN
:
120 case SLAPI_PLUGIN_PRE_UNBIND_FN
:
121 case SLAPI_PLUGIN_PRE_SEARCH_FN
:
122 case SLAPI_PLUGIN_PRE_COMPARE_FN
:
123 case SLAPI_PLUGIN_PRE_MODIFY_FN
:
124 case SLAPI_PLUGIN_PRE_MODRDN_FN
:
125 case SLAPI_PLUGIN_PRE_ADD_FN
:
126 case SLAPI_PLUGIN_PRE_DELETE_FN
:
127 case SLAPI_PLUGIN_PRE_ABANDON_FN
:
128 case SLAPI_PLUGIN_PRE_ENTRY_FN
:
129 case SLAPI_PLUGIN_PRE_REFERRAL_FN
:
130 case SLAPI_PLUGIN_PRE_RESULT_FN
:
131 case SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN
:
132 case SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN
:
133 case SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN
:
134 case SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN
:
135 case SLAPI_PLUGIN_BE_PRE_ADD_FN
:
136 case SLAPI_PLUGIN_BE_PRE_MODIFY_FN
:
137 case SLAPI_PLUGIN_BE_PRE_MODRDN_FN
:
138 case SLAPI_PLUGIN_BE_PRE_DELETE_FN
:
139 case SLAPI_PLUGIN_POST_BIND_FN
:
140 case SLAPI_PLUGIN_POST_UNBIND_FN
:
141 case SLAPI_PLUGIN_POST_SEARCH_FN
:
142 case SLAPI_PLUGIN_POST_COMPARE_FN
:
143 case SLAPI_PLUGIN_POST_MODIFY_FN
:
144 case SLAPI_PLUGIN_POST_MODRDN_FN
:
145 case SLAPI_PLUGIN_POST_ADD_FN
:
146 case SLAPI_PLUGIN_POST_DELETE_FN
:
147 case SLAPI_PLUGIN_POST_ABANDON_FN
:
148 case SLAPI_PLUGIN_POST_ENTRY_FN
:
149 case SLAPI_PLUGIN_POST_REFERRAL_FN
:
150 case SLAPI_PLUGIN_POST_RESULT_FN
:
151 case SLAPI_PLUGIN_INTERNAL_POST_ADD_FN
:
152 case SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN
:
153 case SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN
:
154 case SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN
:
155 case SLAPI_PLUGIN_BE_POST_ADD_FN
:
156 case SLAPI_PLUGIN_BE_POST_MODIFY_FN
:
157 case SLAPI_PLUGIN_BE_POST_MODRDN_FN
:
158 case SLAPI_PLUGIN_BE_POST_DELETE_FN
:
159 case SLAPI_PLUGIN_MR_FILTER_CREATE_FN
:
160 case SLAPI_PLUGIN_MR_INDEXER_CREATE_FN
:
161 case SLAPI_PLUGIN_MR_FILTER_MATCH_FN
:
162 case SLAPI_PLUGIN_MR_FILTER_INDEX_FN
:
163 case SLAPI_PLUGIN_MR_FILTER_RESET_FN
:
164 case SLAPI_PLUGIN_MR_INDEX_FN
:
165 case SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN
:
166 case SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN
:
167 case SLAPI_PLUGIN_ACL_ALLOW_ACCESS
:
168 case SLAPI_X_PLUGIN_PRE_GROUP_FN
:
169 case SLAPI_X_PLUGIN_POST_GROUP_FN
:
170 case SLAPI_PLUGIN_AUDIT_FN
:
171 case SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN
:
172 case SLAPI_PLUGIN_INTERNAL_PRE_UNBIND_FN
:
173 case SLAPI_PLUGIN_INTERNAL_PRE_SEARCH_FN
:
174 case SLAPI_PLUGIN_INTERNAL_PRE_COMPARE_FN
:
175 case SLAPI_PLUGIN_INTERNAL_PRE_ABANDON_FN
:
176 case SLAPI_PLUGIN_INTERNAL_POST_BIND_FN
:
177 case SLAPI_PLUGIN_INTERNAL_POST_UNBIND_FN
:
178 case SLAPI_PLUGIN_INTERNAL_POST_SEARCH_FN
:
179 case SLAPI_PLUGIN_INTERNAL_POST_COMPARE_FN
:
180 case SLAPI_PLUGIN_INTERNAL_POST_ABANDON_FN
:
181 return PBLOCK_CLASS_FUNCTION_POINTER
;
185 case SLAPI_CONNECTION
:
186 case SLAPI_OPERATION
:
187 case SLAPI_OPERATION_PARAMETERS
:
188 case SLAPI_OPERATION_TYPE
:
189 case SLAPI_OPERATION_AUTHTYPE
:
190 case SLAPI_BE_MONITORDN
:
192 case SLAPI_REQUESTOR_DN
:
194 case SLAPI_CONN_CLIENTIP
:
195 case SLAPI_CONN_SERVERIP
:
196 case SLAPI_CONN_AUTHTYPE
:
197 case SLAPI_CONN_AUTHMETHOD
:
198 case SLAPI_CONN_CERT
:
199 case SLAPI_X_CONN_CLIENTPATH
:
200 case SLAPI_X_CONN_SERVERPATH
:
201 case SLAPI_X_CONN_SASL_CONTEXT
:
202 case SLAPI_X_CONFIG_ARGV
:
203 case SLAPI_X_INTOP_FLAGS
:
204 case SLAPI_X_INTOP_RESULT_CALLBACK
:
205 case SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK
:
206 case SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK
:
207 case SLAPI_X_INTOP_CALLBACK_DATA
:
208 case SLAPI_PLUGIN_MR_OID
:
209 case SLAPI_PLUGIN_MR_TYPE
:
210 case SLAPI_PLUGIN_MR_VALUE
:
211 case SLAPI_PLUGIN_MR_VALUES
:
212 case SLAPI_PLUGIN_MR_KEYS
:
214 case SLAPI_PLUGIN_PRIVATE
:
215 case SLAPI_PLUGIN_ARGV
:
216 case SLAPI_PLUGIN_OBJECT
:
217 case SLAPI_PLUGIN_DESCRIPTION
:
218 case SLAPI_PLUGIN_IDENTITY
:
219 case SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES
:
220 case SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS
:
221 case SLAPI_PLUGIN_MR_FILTER_REUSABLE
:
222 case SLAPI_PLUGIN_MR_QUERY_OPERATOR
:
223 case SLAPI_PLUGIN_MR_USAGE
:
225 case SLAPI_OP_LESS_OR_EQUAL
:
226 case SLAPI_PLUGIN_MR_USAGE_INDEX
:
227 case SLAPI_PLUGIN_SYNTAX_FILTER_AVA
:
228 case SLAPI_PLUGIN_SYNTAX_FILTER_SUB
:
229 case SLAPI_PLUGIN_SYNTAX_VALUES2KEYS
:
230 case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA
:
231 case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB
:
232 case SLAPI_PLUGIN_SYNTAX_NAMES
:
233 case SLAPI_PLUGIN_SYNTAX_OID
:
234 case SLAPI_PLUGIN_SYNTAX_FLAGS
:
235 case SLAPI_PLUGIN_SYNTAX_COMPARE
:
236 case SLAPI_CONFIG_FILENAME
:
237 case SLAPI_CONFIG_ARGV
:
238 case SLAPI_TARGET_ADDRESS
:
239 case SLAPI_TARGET_UNIQUEID
:
240 case SLAPI_TARGET_DN
:
241 case SLAPI_REQCONTROLS
:
242 case SLAPI_ENTRY_PRE_OP
:
243 case SLAPI_ENTRY_POST_OP
:
244 case SLAPI_RESCONTROLS
:
245 case SLAPI_X_OLD_RESCONTROLS
:
246 case SLAPI_ADD_RESCONTROL
:
247 case SLAPI_CONTROLS_ARG
:
248 case SLAPI_ADD_ENTRY
:
249 case SLAPI_ADD_EXISTING_DN_ENTRY
:
250 case SLAPI_ADD_PARENT_ENTRY
:
251 case SLAPI_ADD_PARENT_UNIQUEID
:
252 case SLAPI_ADD_EXISTING_UNIQUEID_ENTRY
:
253 case SLAPI_BIND_CREDENTIALS
:
254 case SLAPI_BIND_SASLMECHANISM
:
255 case SLAPI_BIND_RET_SASLCREDS
:
256 case SLAPI_COMPARE_TYPE
:
257 case SLAPI_COMPARE_VALUE
:
258 case SLAPI_MODIFY_MODS
:
259 case SLAPI_MODRDN_NEWRDN
:
260 case SLAPI_MODRDN_NEWSUPERIOR
:
261 case SLAPI_MODRDN_PARENT_ENTRY
:
262 case SLAPI_MODRDN_NEWPARENT_ENTRY
:
263 case SLAPI_MODRDN_TARGET_ENTRY
:
264 case SLAPI_MODRDN_NEWSUPERIOR_ADDRESS
:
265 case SLAPI_SEARCH_FILTER
:
266 case SLAPI_SEARCH_STRFILTER
:
267 case SLAPI_SEARCH_ATTRS
:
269 case SLAPI_SEQ_ATTRNAME
:
271 case SLAPI_EXT_OP_REQ_OID
:
272 case SLAPI_EXT_OP_REQ_VALUE
:
273 case SLAPI_EXT_OP_RET_OID
:
274 case SLAPI_EXT_OP_RET_VALUE
:
275 case SLAPI_MR_FILTER_ENTRY
:
276 case SLAPI_MR_FILTER_TYPE
:
277 case SLAPI_MR_FILTER_VALUE
:
278 case SLAPI_MR_FILTER_OID
:
279 case SLAPI_MR_FILTER_DNATTRS
:
280 case SLAPI_LDIF2DB_FILE
:
281 case SLAPI_PARENT_TXN
:
283 case SLAPI_SEARCH_RESULT_SET
:
284 case SLAPI_SEARCH_RESULT_ENTRY
:
285 case SLAPI_SEARCH_REFERRALS
:
286 case SLAPI_RESULT_TEXT
:
287 case SLAPI_RESULT_MATCHED
:
288 case SLAPI_X_GROUP_ENTRY
:
289 case SLAPI_X_GROUP_ATTRIBUTE
:
290 case SLAPI_X_GROUP_OPERATION_DN
:
291 case SLAPI_X_GROUP_TARGET_ENTRY
:
292 case SLAPI_X_ADD_STRUCTURAL_CLASS
:
293 case SLAPI_PLUGIN_AUDIT_DATA
:
294 case SLAPI_IBM_PBLOCK
:
295 case SLAPI_PLUGIN_VERSION
:
296 return PBLOCK_CLASS_POINTER
;
302 return PBLOCK_CLASS_INVALID
;
306 pblock_lock( Slapi_PBlock
*pb
)
308 ldap_pvt_thread_mutex_lock( &pb
->pb_mutex
);
312 pblock_unlock( Slapi_PBlock
*pb
)
314 ldap_pvt_thread_mutex_unlock( &pb
->pb_mutex
);
318 pblock_get_default( Slapi_PBlock
*pb
, int param
, void **value
)
321 slapi_pblock_class_t pbClass
;
323 pbClass
= pblock_get_param_class( param
);
324 if ( pbClass
== PBLOCK_CLASS_INVALID
) {
329 case PBLOCK_CLASS_INTEGER
:
332 case PBLOCK_CLASS_LONG_INTEGER
:
333 *((long *)value
) = 0L;
335 case PBLOCK_CLASS_POINTER
:
336 case PBLOCK_CLASS_FUNCTION_POINTER
:
339 case PBLOCK_CLASS_INVALID
:
343 for ( i
= 0; i
< pb
->pb_nParams
; i
++ ) {
344 if ( pb
->pb_params
[i
] == param
) {
346 case PBLOCK_CLASS_INTEGER
:
347 *((int *)value
) = pb
->pb_values
[i
].pv_integer
;
349 case PBLOCK_CLASS_LONG_INTEGER
:
350 *((long *)value
) = pb
->pb_values
[i
].pv_long_integer
;
352 case PBLOCK_CLASS_POINTER
:
353 *value
= pb
->pb_values
[i
].pv_pointer
;
355 case PBLOCK_CLASS_FUNCTION_POINTER
:
356 *value
= pb
->pb_values
[i
].pv_function_pointer
;
365 return PBLOCK_SUCCESS
;
369 pblock_get_authtype( AuthorizationInformation
*authz
, int is_tls
)
373 switch ( authz
->sai_method
) {
375 authType
= SLAPD_AUTH_SASL
;
377 case LDAP_AUTH_SIMPLE
:
378 authType
= SLAPD_AUTH_SIMPLE
;
381 authType
= SLAPD_AUTH_NONE
;
388 if ( is_tls
&& authType
== NULL
) {
389 authType
= SLAPD_AUTH_SSL
;
396 pblock_set_default( Slapi_PBlock
*pb
, int param
, void *value
)
398 slapi_pblock_class_t pbClass
;
401 pbClass
= pblock_get_param_class( param
);
402 if ( pbClass
== PBLOCK_CLASS_INVALID
) {
406 if ( pb
->pb_nParams
== PBLOCK_MAX_PARAMS
) {
410 for ( i
= 0; i
< pb
->pb_nParams
; i
++ ) {
411 if ( pb
->pb_params
[i
] == param
)
414 if ( i
>= pb
->pb_nParams
) {
415 pb
->pb_params
[i
] = param
;
420 case PBLOCK_CLASS_INTEGER
:
421 pb
->pb_values
[i
].pv_integer
= (*((int *)value
));
423 case PBLOCK_CLASS_LONG_INTEGER
:
424 pb
->pb_values
[i
].pv_long_integer
= (*((long *)value
));
426 case PBLOCK_CLASS_POINTER
:
427 pb
->pb_values
[i
].pv_pointer
= value
;
429 case PBLOCK_CLASS_FUNCTION_POINTER
:
430 pb
->pb_values
[i
].pv_function_pointer
= value
;
436 return PBLOCK_SUCCESS
;
440 pblock_be_call( Slapi_PBlock
*pb
, int (*bep
)(Operation
*) )
446 PBLOCK_ASSERT_OP( pb
, 0 );
450 op
->o_bd
= select_backend( &op
->o_req_ndn
, 0 );
458 pblock_get( Slapi_PBlock
*pb
, int param
, void **value
)
460 int rc
= PBLOCK_SUCCESS
;
465 case SLAPI_OPERATION
:
468 case SLAPI_OPINITIATED_TIME
:
469 PBLOCK_ASSERT_OP( pb
, 0 );
470 *((long *)value
) = pb
->pb_op
->o_time
;
472 case SLAPI_OPERATION_ID
:
473 PBLOCK_ASSERT_OP( pb
, 0 );
474 *((long *)value
) = pb
->pb_op
->o_opid
;
476 case SLAPI_OPERATION_TYPE
:
477 PBLOCK_ASSERT_OP( pb
, 0 );
478 *((ber_tag_t
*)value
) = pb
->pb_op
->o_tag
;
480 case SLAPI_OPERATION_MSGID
:
481 PBLOCK_ASSERT_OP( pb
, 0 );
482 *((long *)value
) = pb
->pb_op
->o_msgid
;
484 case SLAPI_X_OPERATION_DELETE_GLUE_PARENT
:
485 PBLOCK_ASSERT_OP( pb
, 0 );
486 *((int *)value
) = pb
->pb_op
->o_delete_glue_parent
;
488 case SLAPI_X_OPERATION_NO_SCHEMA_CHECK
:
489 PBLOCK_ASSERT_OP( pb
, 0 );
490 *((int *)value
) = get_no_schema_check( pb
->pb_op
);
492 case SLAPI_X_ADD_STRUCTURAL_CLASS
:
493 PBLOCK_ASSERT_OP( pb
, 0 );
495 if ( pb
->pb_op
->o_tag
== LDAP_REQ_ADD
) {
496 struct berval tmpval
= BER_BVNULL
;
498 rc
= mods_structural_class( pb
->pb_op
->ora_modlist
,
499 &tmpval
, &pb
->pb_rs
->sr_text
,
500 pb
->pb_textbuf
, sizeof( pb
->pb_textbuf
),
501 pb
->pb_op
->o_tmpmemctx
);
502 *((char **)value
) = tmpval
.bv_val
;
507 case SLAPI_X_OPERATION_NO_SUBORDINATE_GLUE
:
508 PBLOCK_ASSERT_OP( pb
, 0 );
509 *((int *)value
) = pb
->pb_op
->o_no_subordinate_glue
;
511 case SLAPI_REQCONTROLS
:
512 PBLOCK_ASSERT_OP( pb
, 0 );
513 *((LDAPControl
***)value
) = pb
->pb_op
->o_ctrls
;
515 case SLAPI_REQUESTOR_DN
:
516 PBLOCK_ASSERT_OP( pb
, 0 );
517 *((char **)value
) = pb
->pb_op
->o_dn
.bv_val
;
519 case SLAPI_MANAGEDSAIT
:
520 PBLOCK_ASSERT_OP( pb
, 0 );
521 *((int *)value
) = get_manageDSAit( pb
->pb_op
);
524 PBLOCK_ASSERT_OP( pb
, 0 );
525 *((int *)value
) = get_relax( pb
->pb_op
);
528 PBLOCK_ASSERT_OP( pb
, 0 );
529 *((BackendDB
**)value
) = select_backend( &pb
->pb_op
->o_req_ndn
, 0 );
532 PBLOCK_ASSERT_OP( pb
, 0 );
533 if ( pb
->pb_op
->o_bd
!= NULL
)
534 *((char **)value
) = pb
->pb_op
->o_bd
->bd_info
->bi_type
;
538 case SLAPI_CONNECTION
:
539 *value
= pb
->pb_conn
;
541 case SLAPI_X_CONN_SSF
:
542 PBLOCK_ASSERT_OP( pb
, 0 );
543 *((slap_ssf_t
*)value
) = pb
->pb_conn
->c_ssf
;
545 case SLAPI_X_CONN_SASL_CONTEXT
:
546 PBLOCK_ASSERT_CONN( pb
);
547 if ( pb
->pb_conn
->c_sasl_authctx
!= NULL
)
548 *value
= pb
->pb_conn
->c_sasl_authctx
;
550 *value
= pb
->pb_conn
->c_sasl_sockctx
;
552 case SLAPI_TARGET_DN
:
553 PBLOCK_ASSERT_OP( pb
, 0 );
554 *((char **)value
) = pb
->pb_op
->o_req_dn
.bv_val
;
556 case SLAPI_REQUESTOR_ISROOT
:
557 *((int *)value
) = pblock_be_call( pb
, be_isroot
);
559 case SLAPI_IS_REPLICATED_OPERATION
:
560 *((int *)value
) = pblock_be_call( pb
, be_slurp_update
);
562 case SLAPI_CONN_AUTHTYPE
:
563 case SLAPI_CONN_AUTHMETHOD
: /* XXX should return SASL mech */
564 PBLOCK_ASSERT_CONN( pb
);
565 *((char **)value
) = pblock_get_authtype( &pb
->pb_conn
->c_authz
,
567 pb
->pb_conn
->c_is_tls
573 case SLAPI_IS_INTERNAL_OPERATION
:
574 *((int *)value
) = pb
->pb_intop
;
576 case SLAPI_X_CONN_IS_UDP
:
577 PBLOCK_ASSERT_CONN( pb
);
578 #ifdef LDAP_CONNECTIONLESS
579 *((int *)value
) = pb
->pb_conn
->c_is_udp
;
585 PBLOCK_ASSERT_CONN( pb
);
586 *((long *)value
) = pb
->pb_conn
->c_connid
;
589 PBLOCK_ASSERT_CONN( pb
);
591 /* This would be necessary to keep plugin compat after the fix in ITS#4158 */
592 if ( pb
->pb_op
->o_tag
== LDAP_REQ_BIND
&& pb
->pb_rs
->sr_err
== LDAP_SUCCESS
)
593 *((char **)value
) = pb
->pb_op
->orb_edn
.bv_val
;
596 *((char **)value
) = pb
->pb_conn
->c_dn
.bv_val
;
598 case SLAPI_CONN_CLIENTIP
:
599 PBLOCK_ASSERT_CONN( pb
);
600 if ( strncmp( pb
->pb_conn
->c_peer_name
.bv_val
, "IP=", 3 ) == 0 )
601 *((char **)value
) = &pb
->pb_conn
->c_peer_name
.bv_val
[3];
605 case SLAPI_X_CONN_CLIENTPATH
:
606 PBLOCK_ASSERT_CONN( pb
);
607 if ( strncmp( pb
->pb_conn
->c_peer_name
.bv_val
, "PATH=", 3 ) == 0 )
608 *((char **)value
) = &pb
->pb_conn
->c_peer_name
.bv_val
[5];
612 case SLAPI_CONN_SERVERIP
:
613 PBLOCK_ASSERT_CONN( pb
);
614 if ( strncmp( pb
->pb_conn
->c_sock_name
.bv_val
, "IP=", 3 ) == 0 )
615 *((char **)value
) = &pb
->pb_conn
->c_sock_name
.bv_val
[3];
619 case SLAPI_X_CONN_SERVERPATH
:
620 PBLOCK_ASSERT_CONN( pb
);
621 if ( strncmp( pb
->pb_conn
->c_sock_name
.bv_val
, "PATH=", 3 ) == 0 )
622 *((char **)value
) = &pb
->pb_conn
->c_sock_name
.bv_val
[5];
626 case SLAPI_RESULT_CODE
:
627 case SLAPI_PLUGIN_INTOP_RESULT
:
628 PBLOCK_ASSERT_OP( pb
, 0 );
629 *((int *)value
) = pb
->pb_rs
->sr_err
;
631 case SLAPI_RESULT_TEXT
:
632 PBLOCK_ASSERT_OP( pb
, 0 );
633 *((const char **)value
) = pb
->pb_rs
->sr_text
;
635 case SLAPI_RESULT_MATCHED
:
636 PBLOCK_ASSERT_OP( pb
, 0 );
637 *((const char **)value
) = pb
->pb_rs
->sr_matched
;
639 case SLAPI_ADD_ENTRY
:
640 PBLOCK_ASSERT_OP( pb
, 0 );
641 if ( pb
->pb_op
->o_tag
== LDAP_REQ_ADD
)
642 *((Slapi_Entry
**)value
) = pb
->pb_op
->ora_e
;
646 case SLAPI_MODIFY_MODS
: {
647 LDAPMod
**mods
= NULL
;
648 Modifications
*ml
= NULL
;
650 pblock_get_default( pb
, param
, (void **)&mods
);
651 if ( mods
== NULL
&& pb
->pb_intop
== 0 ) {
652 switch ( pb
->pb_op
->o_tag
) {
653 case LDAP_REQ_MODIFY
:
654 ml
= pb
->pb_op
->orm_modlist
;
656 case LDAP_REQ_MODRDN
:
657 ml
= pb
->pb_op
->orr_modlist
;
663 if ( rc
!= PBLOCK_ERROR
) {
664 mods
= slapi_int_modifications2ldapmods( ml
);
665 pblock_set_default( pb
, param
, (void *)mods
);
668 *((LDAPMod
***)value
) = mods
;
671 case SLAPI_MODRDN_NEWRDN
:
672 PBLOCK_ASSERT_OP( pb
, 0 );
673 if ( pb
->pb_op
->o_tag
== LDAP_REQ_MODRDN
)
674 *((char **)value
) = pb
->pb_op
->orr_newrdn
.bv_val
;
678 case SLAPI_MODRDN_NEWSUPERIOR
:
679 PBLOCK_ASSERT_OP( pb
, 0 );
680 if ( pb
->pb_op
->o_tag
== LDAP_REQ_MODRDN
&& pb
->pb_op
->orr_newSup
!= NULL
)
681 *((char **)value
) = pb
->pb_op
->orr_newSup
->bv_val
;
685 case SLAPI_MODRDN_DELOLDRDN
:
686 PBLOCK_ASSERT_OP( pb
, 0 );
687 if ( pb
->pb_op
->o_tag
== LDAP_REQ_MODRDN
)
688 *((int *)value
) = pb
->pb_op
->orr_deleteoldrdn
;
692 case SLAPI_SEARCH_SCOPE
:
693 PBLOCK_ASSERT_OP( pb
, 0 );
694 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
695 *((int *)value
) = pb
->pb_op
->ors_scope
;
699 case SLAPI_SEARCH_DEREF
:
700 PBLOCK_ASSERT_OP( pb
, 0 );
701 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
702 *((int *)value
) = pb
->pb_op
->ors_deref
;
706 case SLAPI_SEARCH_SIZELIMIT
:
707 PBLOCK_ASSERT_OP( pb
, 0 );
708 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
709 *((int *)value
) = pb
->pb_op
->ors_slimit
;
713 case SLAPI_SEARCH_TIMELIMIT
:
714 PBLOCK_ASSERT_OP( pb
, 0 );
715 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
716 *((int *)value
) = pb
->pb_op
->ors_tlimit
;
720 case SLAPI_SEARCH_FILTER
:
721 PBLOCK_ASSERT_OP( pb
, 0 );
722 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
723 *((Slapi_Filter
**)value
) = pb
->pb_op
->ors_filter
;
725 *((Slapi_Filter
**)value
) = NULL
;
727 case SLAPI_SEARCH_STRFILTER
:
728 PBLOCK_ASSERT_OP( pb
, 0 );
729 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
730 *((char **)value
) = pb
->pb_op
->ors_filterstr
.bv_val
;
732 *((char **)value
) = NULL
;
734 case SLAPI_SEARCH_ATTRS
: {
737 PBLOCK_ASSERT_OP( pb
, 0 );
738 if ( pb
->pb_op
->o_tag
!= LDAP_REQ_SEARCH
) {
742 pblock_get_default( pb
, param
, (void **)&attrs
);
743 if ( attrs
== NULL
&& pb
->pb_intop
== 0 ) {
744 attrs
= anlist2charray_x( pb
->pb_op
->ors_attrs
, 0, pb
->pb_op
->o_tmpmemctx
);
745 pblock_set_default( pb
, param
, (void *)attrs
);
747 *((char ***)value
) = attrs
;
750 case SLAPI_SEARCH_ATTRSONLY
:
751 PBLOCK_ASSERT_OP( pb
, 0 );
752 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
753 *((int *)value
) = pb
->pb_op
->ors_attrsonly
;
757 case SLAPI_SEARCH_RESULT_ENTRY
:
758 PBLOCK_ASSERT_OP( pb
, 0 );
759 *((Slapi_Entry
**)value
) = pb
->pb_rs
->sr_entry
;
761 case SLAPI_BIND_RET_SASLCREDS
:
762 PBLOCK_ASSERT_OP( pb
, 0 );
763 *((struct berval
**)value
) = pb
->pb_rs
->sr_sasldata
;
765 case SLAPI_EXT_OP_REQ_OID
:
766 *((const char **)value
) = pb
->pb_op
->ore_reqoid
.bv_val
;
768 case SLAPI_EXT_OP_REQ_VALUE
:
769 *((struct berval
**)value
) = pb
->pb_op
->ore_reqdata
;
771 case SLAPI_EXT_OP_RET_OID
:
772 PBLOCK_ASSERT_OP( pb
, 0 );
773 *((const char **)value
) = pb
->pb_rs
->sr_rspoid
;
775 case SLAPI_EXT_OP_RET_VALUE
:
776 PBLOCK_ASSERT_OP( pb
, 0 );
777 *((struct berval
**)value
) = pb
->pb_rs
->sr_rspdata
;
779 case SLAPI_BIND_METHOD
:
780 if ( pb
->pb_op
->o_tag
== LDAP_REQ_BIND
)
781 *((int *)value
) = pb
->pb_op
->orb_method
;
785 case SLAPI_BIND_CREDENTIALS
:
786 if ( pb
->pb_op
->o_tag
== LDAP_REQ_BIND
)
787 *((struct berval
**)value
) = &pb
->pb_op
->orb_cred
;
791 case SLAPI_COMPARE_TYPE
:
792 if ( pb
->pb_op
->o_tag
== LDAP_REQ_COMPARE
)
793 *((char **)value
) = pb
->pb_op
->orc_ava
->aa_desc
->ad_cname
.bv_val
;
797 case SLAPI_COMPARE_VALUE
:
798 if ( pb
->pb_op
->o_tag
== LDAP_REQ_COMPARE
)
799 *((struct berval
**)value
) = &pb
->pb_op
->orc_ava
->aa_value
;
803 case SLAPI_ABANDON_MSGID
:
804 if ( pb
->pb_op
->o_tag
== LDAP_REQ_ABANDON
)
805 *((int *)value
) = pb
->pb_op
->orn_msgid
;
810 rc
= pblock_get_default( pb
, param
, value
);
820 pblock_add_control( Slapi_PBlock
*pb
, LDAPControl
*control
)
822 LDAPControl
**controls
= NULL
;
825 pblock_get_default( pb
, SLAPI_RESCONTROLS
, (void **)&controls
);
827 if ( controls
!= NULL
) {
828 for ( i
= 0; controls
[i
] != NULL
; i
++ )
834 controls
= (LDAPControl
**)slapi_ch_realloc( (char *)controls
,
835 ( i
+ 2 ) * sizeof(LDAPControl
*));
836 controls
[i
++] = slapi_dup_control( control
);
839 return pblock_set_default( pb
, SLAPI_RESCONTROLS
, (void *)controls
);
843 pblock_set_dn( void *value
, struct berval
*dn
, struct berval
*ndn
, void *memctx
)
847 if ( !BER_BVISNULL( dn
)) {
848 slap_sl_free( dn
->bv_val
, memctx
);
851 if ( !BER_BVISNULL( ndn
)) {
852 slap_sl_free( ndn
->bv_val
, memctx
);
856 bv
.bv_val
= (char *)value
;
857 bv
.bv_len
= ( value
!= NULL
) ? strlen( bv
.bv_val
) : 0;
859 return dnPrettyNormal( NULL
, &bv
, dn
, ndn
, memctx
);
863 pblock_set( Slapi_PBlock
*pb
, int param
, void *value
)
865 int rc
= PBLOCK_SUCCESS
;
870 case SLAPI_OPERATION
:
871 pb
->pb_op
= (Operation
*)value
;
873 case SLAPI_OPINITIATED_TIME
:
874 PBLOCK_ASSERT_OP( pb
, 0 );
875 pb
->pb_op
->o_time
= *((long *)value
);
877 case SLAPI_OPERATION_ID
:
878 PBLOCK_ASSERT_OP( pb
, 0 );
879 pb
->pb_op
->o_opid
= *((long *)value
);
881 case SLAPI_OPERATION_TYPE
:
882 PBLOCK_ASSERT_OP( pb
, 0 );
883 pb
->pb_op
->o_tag
= *((ber_tag_t
*)value
);
885 case SLAPI_OPERATION_MSGID
:
886 PBLOCK_ASSERT_OP( pb
, 0 );
887 pb
->pb_op
->o_msgid
= *((long *)value
);
889 case SLAPI_X_OPERATION_DELETE_GLUE_PARENT
:
890 PBLOCK_ASSERT_OP( pb
, 0 );
891 pb
->pb_op
->o_delete_glue_parent
= *((int *)value
);
893 case SLAPI_X_OPERATION_NO_SCHEMA_CHECK
:
894 PBLOCK_ASSERT_OP( pb
, 0 );
895 pb
->pb_op
->o_no_schema_check
= *((int *)value
);
897 case SLAPI_X_OPERATION_NO_SUBORDINATE_GLUE
:
898 PBLOCK_ASSERT_OP( pb
, 0 );
899 pb
->pb_op
->o_no_subordinate_glue
= *((int *)value
);
901 case SLAPI_REQCONTROLS
:
902 PBLOCK_ASSERT_OP( pb
, 0 );
903 pb
->pb_op
->o_ctrls
= (LDAPControl
**)value
;
905 case SLAPI_RESCONTROLS
: {
906 LDAPControl
**ctrls
= NULL
;
908 pblock_get_default( pb
, param
, (void **)&ctrls
);
909 if ( ctrls
!= NULL
) {
910 /* free old ones first */
911 ldap_controls_free( ctrls
);
913 rc
= pblock_set_default( pb
, param
, value
);
916 case SLAPI_ADD_RESCONTROL
:
917 PBLOCK_ASSERT_OP( pb
, 0 );
918 rc
= pblock_add_control( pb
, (LDAPControl
*)value
);
920 case SLAPI_REQUESTOR_DN
:
921 PBLOCK_ASSERT_OP( pb
, 0 );
922 rc
= pblock_set_dn( value
, &pb
->pb_op
->o_dn
, &pb
->pb_op
->o_ndn
, pb
->pb_op
->o_tmpmemctx
);
924 case SLAPI_MANAGEDSAIT
:
925 PBLOCK_ASSERT_OP( pb
, 0 );
926 pb
->pb_op
->o_managedsait
= *((int *)value
);
929 PBLOCK_ASSERT_OP( pb
, 0 );
930 pb
->pb_op
->o_relax
= *((int *)value
);
933 PBLOCK_ASSERT_OP( pb
, 0 );
934 pb
->pb_op
->o_bd
= (BackendDB
*)value
;
936 case SLAPI_CONNECTION
:
937 pb
->pb_conn
= (Connection
*)value
;
939 case SLAPI_X_CONN_SSF
:
940 PBLOCK_ASSERT_CONN( pb
);
941 PBLOCK_LOCK_CONN( pb
);
942 pb
->pb_conn
->c_ssf
= (slap_ssf_t
)(long)value
;
943 PBLOCK_UNLOCK_CONN( pb
);
945 case SLAPI_X_CONN_SASL_CONTEXT
:
946 PBLOCK_ASSERT_CONN( pb
);
947 PBLOCK_LOCK_CONN( pb
);
948 pb
->pb_conn
->c_sasl_authctx
= value
;
949 PBLOCK_UNLOCK_CONN( pb
);
951 case SLAPI_TARGET_DN
:
952 PBLOCK_ASSERT_OP( pb
, 0 );
953 rc
= pblock_set_dn( value
, &pb
->pb_op
->o_req_dn
, &pb
->pb_op
->o_req_ndn
, pb
->pb_op
->o_tmpmemctx
);
956 PBLOCK_ASSERT_CONN( pb
);
957 PBLOCK_LOCK_CONN( pb
);
958 pb
->pb_conn
->c_connid
= *((long *)value
);
959 PBLOCK_UNLOCK_CONN( pb
);
962 PBLOCK_ASSERT_CONN( pb
);
963 PBLOCK_LOCK_CONN( pb
);
964 rc
= pblock_set_dn( value
, &pb
->pb_conn
->c_dn
, &pb
->pb_conn
->c_ndn
, NULL
);
965 PBLOCK_UNLOCK_CONN( pb
);
967 case SLAPI_RESULT_CODE
:
968 case SLAPI_PLUGIN_INTOP_RESULT
:
969 PBLOCK_ASSERT_OP( pb
, 0 );
970 pb
->pb_rs
->sr_err
= *((int *)value
);
972 case SLAPI_RESULT_TEXT
:
973 PBLOCK_ASSERT_OP( pb
, 0 );
974 snprintf( pb
->pb_textbuf
, sizeof( pb
->pb_textbuf
), "%s", (char *)value
);
975 pb
->pb_rs
->sr_text
= pb
->pb_textbuf
;
977 case SLAPI_RESULT_MATCHED
:
978 PBLOCK_ASSERT_OP( pb
, 0 );
979 pb
->pb_rs
->sr_matched
= (char *)value
; /* XXX should dup? */
981 case SLAPI_ADD_ENTRY
:
982 PBLOCK_ASSERT_OP( pb
, 0 );
983 if ( pb
->pb_op
->o_tag
== LDAP_REQ_ADD
)
984 pb
->pb_op
->ora_e
= (Slapi_Entry
*)value
;
988 case SLAPI_MODIFY_MODS
: {
990 Modifications
*newmods
;
992 PBLOCK_ASSERT_OP( pb
, 0 );
993 rc
= pblock_set_default( pb
, param
, value
);
994 if ( rc
!= PBLOCK_SUCCESS
) {
998 if ( pb
->pb_op
->o_tag
== LDAP_REQ_MODIFY
) {
999 mlp
= &pb
->pb_op
->orm_modlist
;
1000 } else if ( pb
->pb_op
->o_tag
== LDAP_REQ_ADD
) {
1001 mlp
= &pb
->pb_op
->ora_modlist
;
1002 } else if ( pb
->pb_op
->o_tag
== LDAP_REQ_MODRDN
) {
1003 mlp
= &pb
->pb_op
->orr_modlist
;
1008 newmods
= slapi_int_ldapmods2modifications( pb
->pb_op
, (LDAPMod
**)value
);
1009 if ( newmods
!= NULL
) {
1010 slap_mods_free( *mlp
, 1 );
1015 case SLAPI_MODRDN_NEWRDN
:
1016 PBLOCK_ASSERT_OP( pb
, 0 );
1017 PBLOCK_VALIDATE_IS_INTOP( pb
);
1018 if ( pb
->pb_op
->o_tag
== LDAP_REQ_MODRDN
) {
1019 rc
= pblock_set_dn( value
, &pb
->pb_op
->orr_newrdn
, &pb
->pb_op
->orr_nnewrdn
, pb
->pb_op
->o_tmpmemctx
);
1020 if ( rc
== LDAP_SUCCESS
)
1021 rc
= rdn_validate( &pb
->pb_op
->orr_nnewrdn
);
1026 case SLAPI_MODRDN_NEWSUPERIOR
:
1027 PBLOCK_ASSERT_OP( pb
, 0 );
1028 PBLOCK_VALIDATE_IS_INTOP( pb
);
1029 if ( pb
->pb_op
->o_tag
== LDAP_REQ_MODRDN
) {
1030 if ( value
== NULL
) {
1031 if ( pb
->pb_op
->orr_newSup
!= NULL
) {
1032 pb
->pb_op
->o_tmpfree( pb
->pb_op
->orr_newSup
, pb
->pb_op
->o_tmpmemctx
);
1033 BER_BVZERO( pb
->pb_op
->orr_newSup
);
1034 pb
->pb_op
->orr_newSup
= NULL
;
1036 if ( pb
->pb_op
->orr_newSup
!= NULL
) {
1037 pb
->pb_op
->o_tmpfree( pb
->pb_op
->orr_nnewSup
, pb
->pb_op
->o_tmpmemctx
);
1038 BER_BVZERO( pb
->pb_op
->orr_nnewSup
);
1039 pb
->pb_op
->orr_nnewSup
= NULL
;
1042 if ( pb
->pb_op
->orr_newSup
== NULL
) {
1043 pb
->pb_op
->orr_newSup
= (struct berval
*)pb
->pb_op
->o_tmpalloc(
1044 sizeof(struct berval
), pb
->pb_op
->o_tmpmemctx
);
1045 BER_BVZERO( pb
->pb_op
->orr_newSup
);
1047 if ( pb
->pb_op
->orr_nnewSup
== NULL
) {
1048 pb
->pb_op
->orr_nnewSup
= (struct berval
*)pb
->pb_op
->o_tmpalloc(
1049 sizeof(struct berval
), pb
->pb_op
->o_tmpmemctx
);
1050 BER_BVZERO( pb
->pb_op
->orr_nnewSup
);
1052 rc
= pblock_set_dn( value
, pb
->pb_op
->orr_newSup
, pb
->pb_op
->orr_nnewSup
, pb
->pb_op
->o_tmpmemctx
);
1058 case SLAPI_MODRDN_DELOLDRDN
:
1059 PBLOCK_ASSERT_OP( pb
, 0 );
1060 PBLOCK_VALIDATE_IS_INTOP( pb
);
1061 if ( pb
->pb_op
->o_tag
== LDAP_REQ_MODRDN
)
1062 pb
->pb_op
->orr_deleteoldrdn
= *((int *)value
);
1066 case SLAPI_SEARCH_SCOPE
: {
1067 int scope
= *((int *)value
);
1069 PBLOCK_ASSERT_OP( pb
, 0 );
1070 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
) {
1071 switch ( *((int *)value
) ) {
1072 case LDAP_SCOPE_BASE
:
1073 case LDAP_SCOPE_ONELEVEL
:
1074 case LDAP_SCOPE_SUBTREE
:
1075 case LDAP_SCOPE_SUBORDINATE
:
1076 pb
->pb_op
->ors_scope
= scope
;
1087 case SLAPI_SEARCH_DEREF
:
1088 PBLOCK_ASSERT_OP( pb
, 0 );
1089 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
1090 pb
->pb_op
->ors_deref
= *((int *)value
);
1094 case SLAPI_SEARCH_SIZELIMIT
:
1095 PBLOCK_ASSERT_OP( pb
, 0 );
1096 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
1097 pb
->pb_op
->ors_slimit
= *((int *)value
);
1101 case SLAPI_SEARCH_TIMELIMIT
:
1102 PBLOCK_ASSERT_OP( pb
, 0 );
1103 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
1104 pb
->pb_op
->ors_tlimit
= *((int *)value
);
1108 case SLAPI_SEARCH_FILTER
:
1109 PBLOCK_ASSERT_OP( pb
, 0 );
1110 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
1111 pb
->pb_op
->ors_filter
= (Slapi_Filter
*)value
;
1115 case SLAPI_SEARCH_STRFILTER
:
1116 PBLOCK_ASSERT_OP( pb
, 0 );
1117 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
) {
1118 pb
->pb_op
->ors_filterstr
.bv_val
= (char *)value
;
1119 pb
->pb_op
->ors_filterstr
.bv_len
= strlen((char *)value
);
1124 case SLAPI_SEARCH_ATTRS
: {
1125 AttributeName
*an
= NULL
;
1126 size_t i
= 0, j
= 0;
1127 char **attrs
= (char **)value
;
1129 PBLOCK_ASSERT_OP( pb
, 0 );
1130 PBLOCK_VALIDATE_IS_INTOP( pb
);
1132 if ( pb
->pb_op
->o_tag
!= LDAP_REQ_SEARCH
) {
1136 /* also set mapped attrs */
1137 rc
= pblock_set_default( pb
, param
, value
);
1138 if ( rc
!= PBLOCK_SUCCESS
) {
1141 if ( pb
->pb_op
->ors_attrs
!= NULL
) {
1142 pb
->pb_op
->o_tmpfree( pb
->pb_op
->ors_attrs
, pb
->pb_op
->o_tmpmemctx
);
1143 pb
->pb_op
->ors_attrs
= NULL
;
1145 if ( attrs
!= NULL
) {
1146 for ( i
= 0; attrs
[i
] != NULL
; i
++ )
1150 an
= (AttributeName
*)pb
->pb_op
->o_tmpcalloc( i
+ 1,
1151 sizeof(AttributeName
), pb
->pb_op
->o_tmpmemctx
);
1152 for ( i
= 0; attrs
[i
] != NULL
; i
++ ) {
1153 an
[j
].an_desc
= NULL
;
1155 an
[j
].an_oc_exclude
= 0;
1156 an
[j
].an_name
.bv_val
= attrs
[i
];
1157 an
[j
].an_name
.bv_len
= strlen( attrs
[i
] );
1158 if ( slap_bv2ad( &an
[j
].an_name
, &an
[j
].an_desc
, &pb
->pb_rs
->sr_text
) == LDAP_SUCCESS
) {
1162 an
[j
].an_name
.bv_val
= NULL
;
1163 an
[j
].an_name
.bv_len
= 0;
1165 pb
->pb_op
->ors_attrs
= an
;
1168 case SLAPI_SEARCH_ATTRSONLY
:
1169 PBLOCK_ASSERT_OP( pb
, 0 );
1170 PBLOCK_VALIDATE_IS_INTOP( pb
);
1172 if ( pb
->pb_op
->o_tag
== LDAP_REQ_SEARCH
)
1173 pb
->pb_op
->ors_attrsonly
= *((int *)value
);
1177 case SLAPI_SEARCH_RESULT_ENTRY
:
1178 PBLOCK_ASSERT_OP( pb
, 0 );
1179 if ( pb
->pb_rs
->sr_flags
& REP_ENTRY_MUSTBEFREED
) {
1180 entry_free( pb
->pb_rs
->sr_entry
);
1181 } else if ( pb
->pb_rs
->sr_flags
& REP_ENTRY_MUSTRELEASE
) {
1182 be_entry_release_r( pb
->pb_op
, pb
->pb_rs
->sr_entry
);
1183 pb
->pb_rs
->sr_flags
^= REP_ENTRY_MUSTRELEASE
;
1185 pb
->pb_rs
->sr_entry
= (Slapi_Entry
*)value
;
1186 pb
->pb_rs
->sr_flags
|= REP_ENTRY_MUSTBEFREED
;
1188 case SLAPI_BIND_RET_SASLCREDS
:
1189 PBLOCK_ASSERT_OP( pb
, 0 );
1190 pb
->pb_rs
->sr_sasldata
= (struct berval
*)value
;
1192 case SLAPI_EXT_OP_REQ_OID
:
1193 PBLOCK_ASSERT_OP( pb
, 0 );
1194 PBLOCK_VALIDATE_IS_INTOP( pb
);
1196 if ( pb
->pb_op
->o_tag
== LDAP_REQ_EXTENDED
) {
1197 pb
->pb_op
->ore_reqoid
.bv_val
= (char *)value
;
1198 pb
->pb_op
->ore_reqoid
.bv_len
= strlen((char *)value
);
1203 case SLAPI_EXT_OP_REQ_VALUE
:
1204 PBLOCK_ASSERT_OP( pb
, 0 );
1205 PBLOCK_VALIDATE_IS_INTOP( pb
);
1207 if ( pb
->pb_op
->o_tag
== LDAP_REQ_EXTENDED
)
1208 pb
->pb_op
->ore_reqdata
= (struct berval
*)value
;
1212 case SLAPI_EXT_OP_RET_OID
:
1213 PBLOCK_ASSERT_OP( pb
, 0 );
1214 pb
->pb_rs
->sr_rspoid
= (char *)value
;
1216 case SLAPI_EXT_OP_RET_VALUE
:
1217 PBLOCK_ASSERT_OP( pb
, 0 );
1218 pb
->pb_rs
->sr_rspdata
= (struct berval
*)value
;
1220 case SLAPI_BIND_METHOD
:
1221 PBLOCK_ASSERT_OP( pb
, 0 );
1222 PBLOCK_VALIDATE_IS_INTOP( pb
);
1224 if ( pb
->pb_op
->o_tag
== LDAP_REQ_BIND
)
1225 pb
->pb_op
->orb_method
= *((int *)value
);
1229 case SLAPI_BIND_CREDENTIALS
:
1230 PBLOCK_ASSERT_OP( pb
, 0 );
1231 PBLOCK_VALIDATE_IS_INTOP( pb
);
1233 if ( pb
->pb_op
->o_tag
== LDAP_REQ_BIND
)
1234 pb
->pb_op
->orb_cred
= *((struct berval
*)value
);
1238 case SLAPI_COMPARE_TYPE
:
1239 PBLOCK_ASSERT_OP( pb
, 0 );
1240 PBLOCK_VALIDATE_IS_INTOP( pb
);
1242 if ( pb
->pb_op
->o_tag
== LDAP_REQ_COMPARE
) {
1245 pb
->pb_op
->orc_ava
->aa_desc
= NULL
;
1246 rc
= slap_str2ad( (char *)value
, &pb
->pb_op
->orc_ava
->aa_desc
, &text
);
1251 case SLAPI_COMPARE_VALUE
:
1252 PBLOCK_ASSERT_OP( pb
, 0 );
1253 PBLOCK_VALIDATE_IS_INTOP( pb
);
1255 if ( pb
->pb_op
->o_tag
== LDAP_REQ_COMPARE
)
1256 pb
->pb_op
->orc_ava
->aa_value
= *((struct berval
*)value
);
1260 case SLAPI_ABANDON_MSGID
:
1261 PBLOCK_ASSERT_OP( pb
, 0 );
1262 PBLOCK_VALIDATE_IS_INTOP( pb
);
1264 if ( pb
->pb_op
->o_tag
== LDAP_REQ_ABANDON
)
1265 pb
->pb_op
->orn_msgid
= *((int *)value
);
1269 case SLAPI_REQUESTOR_ISROOT
:
1270 case SLAPI_IS_REPLICATED_OPERATION
:
1271 case SLAPI_CONN_AUTHTYPE
:
1272 case SLAPI_CONN_AUTHMETHOD
:
1273 case SLAPI_IS_INTERNAL_OPERATION
:
1274 case SLAPI_X_CONN_IS_UDP
:
1275 case SLAPI_CONN_CLIENTIP
:
1276 case SLAPI_X_CONN_CLIENTPATH
:
1277 case SLAPI_CONN_SERVERIP
:
1278 case SLAPI_X_CONN_SERVERPATH
:
1279 case SLAPI_X_ADD_STRUCTURAL_CLASS
:
1280 /* These parameters cannot be set */
1284 rc
= pblock_set_default( pb
, param
, value
);
1288 pblock_unlock( pb
);
1294 pblock_clear( Slapi_PBlock
*pb
)
1300 pblock_delete_param( Slapi_PBlock
*p
, int param
)
1306 for ( i
= 0; i
< p
->pb_nParams
; i
++ ) {
1307 if ( p
->pb_params
[i
] == param
) {
1312 if (i
>= p
->pb_nParams
) {
1314 return PBLOCK_ERROR
;
1317 /* move last parameter to index of deleted parameter */
1318 if ( p
->pb_nParams
> 1 ) {
1319 p
->pb_params
[i
] = p
->pb_params
[p
->pb_nParams
- 1];
1320 p
->pb_values
[i
] = p
->pb_values
[p
->pb_nParams
- 1];
1326 return PBLOCK_SUCCESS
;
1330 slapi_pblock_new(void)
1334 pb
= (Slapi_PBlock
*) ch_calloc( 1, sizeof(Slapi_PBlock
) );
1336 ldap_pvt_thread_mutex_init( &pb
->pb_mutex
);
1338 pb
->pb_params
[0] = SLAPI_IBM_PBLOCK
;
1339 pb
->pb_values
[0].pv_pointer
= NULL
;
1350 pblock_destroy( Slapi_PBlock
*pb
)
1352 LDAPControl
**controls
= NULL
;
1353 LDAPMod
**mods
= NULL
;
1354 char **attrs
= NULL
;
1356 assert( pb
!= NULL
);
1358 pblock_get_default( pb
, SLAPI_RESCONTROLS
, (void **)&controls
);
1359 if ( controls
!= NULL
) {
1360 ldap_controls_free( controls
);
1363 if ( pb
->pb_intop
) {
1364 slapi_int_connection_done_pb( pb
);
1366 pblock_get_default( pb
, SLAPI_MODIFY_MODS
, (void **)&mods
);
1367 ldap_mods_free( mods
, 1 );
1369 pblock_get_default( pb
, SLAPI_SEARCH_ATTRS
, (void **)&attrs
);
1370 if ( attrs
!= NULL
)
1371 pb
->pb_op
->o_tmpfree( attrs
, pb
->pb_op
->o_tmpmemctx
);
1374 ldap_pvt_thread_mutex_destroy( &pb
->pb_mutex
);
1375 slapi_ch_free( (void **)&pb
);
1379 slapi_pblock_destroy( Slapi_PBlock
*pb
)
1382 pblock_destroy( pb
);
1387 slapi_pblock_get( Slapi_PBlock
*pb
, int arg
, void *value
)
1389 return pblock_get( pb
, arg
, (void **)value
);
1393 slapi_pblock_set( Slapi_PBlock
*pb
, int arg
, void *value
)
1395 return pblock_set( pb
, arg
, value
);
1399 slapi_pblock_clear( Slapi_PBlock
*pb
)
1405 slapi_pblock_delete_param( Slapi_PBlock
*p
, int param
)
1407 return pblock_delete_param( p
, param
);
1411 * OpenLDAP extension
1414 slapi_int_pblock_get_first( Backend
*be
, Slapi_PBlock
**pb
)
1416 assert( pb
!= NULL
);
1417 *pb
= SLAPI_BACKEND_PBLOCK( be
);
1418 return (*pb
== NULL
? LDAP_OTHER
: LDAP_SUCCESS
);
1422 * OpenLDAP extension
1425 slapi_int_pblock_get_next( Slapi_PBlock
**pb
)
1427 assert( pb
!= NULL
);
1428 return slapi_pblock_get( *pb
, SLAPI_IBM_PBLOCK
, pb
);
1431 #endif /* LDAP_SLAPI */