1 /* $OpenLDAP: pkg/ldap/servers/slapd/slapi/slapi_ops.c,v 1.111.2.4 2008/03/21 01:01:07 hyc 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:
25 #include <ac/string.h>
26 #include <ac/stdarg.h>
28 #include <ac/unistd.h>
36 static struct slap_listener slapi_listener
= {
42 slapi_int_dup_controls( LDAPControl
**controls
)
47 if ( controls
== NULL
)
50 for ( i
= 0; controls
[i
] != NULL
; i
++ )
53 c
= (LDAPControl
**) slapi_ch_calloc( i
+ 1, sizeof(LDAPControl
*) );
55 for ( i
= 0; controls
[i
] != NULL
; i
++ ) {
56 c
[i
] = slapi_dup_control( controls
[i
] );
67 Slapi_PBlock
*pb
= SLAPI_OPERATION_PBLOCK( op
);
68 plugin_result_callback prc
= NULL
;
69 void *callback_data
= NULL
;
70 LDAPControl
**ctrls
= NULL
;
74 slapi_pblock_get( pb
, SLAPI_X_INTOP_RESULT_CALLBACK
, (void **)&prc
);
75 slapi_pblock_get( pb
, SLAPI_X_INTOP_CALLBACK_DATA
, &callback_data
);
77 /* we need to duplicate controls because they might go out of scope */
78 ctrls
= slapi_int_dup_controls( rs
->sr_ctrls
);
79 slapi_pblock_set( pb
, SLAPI_RESCONTROLS
, ctrls
);
82 (*prc
)( rs
->sr_err
, callback_data
);
89 slapi_int_search_entry(
93 Slapi_PBlock
*pb
= SLAPI_OPERATION_PBLOCK( op
);
94 plugin_search_entry_callback psec
= NULL
;
95 void *callback_data
= NULL
;
96 int rc
= LDAP_SUCCESS
;
100 slapi_pblock_get( pb
, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK
, (void **)&psec
);
101 slapi_pblock_get( pb
, SLAPI_X_INTOP_CALLBACK_DATA
, &callback_data
);
103 if ( psec
!= NULL
) {
104 rc
= (*psec
)( rs
->sr_entry
, callback_data
);
111 slapi_int_search_reference(
115 int i
, rc
= LDAP_SUCCESS
;
116 plugin_referral_entry_callback prec
= NULL
;
117 void *callback_data
= NULL
;
118 Slapi_PBlock
*pb
= SLAPI_OPERATION_PBLOCK( op
);
120 assert( pb
!= NULL
);
122 slapi_pblock_get( pb
, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK
, (void **)&prec
);
123 slapi_pblock_get( pb
, SLAPI_X_INTOP_CALLBACK_DATA
, &callback_data
);
125 if ( prec
!= NULL
) {
126 for ( i
= 0; rs
->sr_ref
[i
].bv_val
!= NULL
; i
++ ) {
127 rc
= (*prec
)( rs
->sr_ref
[i
].bv_val
, callback_data
);
128 if ( rc
!= LDAP_SUCCESS
) {
138 slapi_int_response( Slapi_Operation
*op
, SlapReply
*rs
)
142 switch ( rs
->sr_type
) {
144 rc
= slapi_int_result( op
, rs
);
147 rc
= slapi_int_search_entry( op
, rs
);
150 rc
= slapi_int_search_reference( op
, rs
);
157 assert( rc
!= SLAP_CB_CONTINUE
); /* never try to send a wire response */
163 slapi_int_get_ctrls( Slapi_PBlock
*pb
)
166 int rc
= LDAP_SUCCESS
;
168 if ( pb
->pb_op
->o_ctrls
!= NULL
) {
169 for ( c
= pb
->pb_op
->o_ctrls
; *c
!= NULL
; c
++ ) {
170 rc
= slap_parse_ctrl( pb
->pb_op
, pb
->pb_rs
, *c
, &pb
->pb_rs
->sr_text
);
171 if ( rc
!= LDAP_SUCCESS
)
180 slapi_int_connection_init_pb( Slapi_PBlock
*pb
, ber_tag_t tag
)
184 ber_len_t max
= sockbuf_max_incoming
;
186 conn
= (Connection
*) slapi_ch_calloc( 1, sizeof(Connection
) );
188 LDAP_STAILQ_INIT( &conn
->c_pending_ops
);
190 op
= (Operation
*) slapi_ch_calloc( 1, sizeof(OperationBuffer
) );
191 op
->o_hdr
= &((OperationBuffer
*) op
)->ob_hdr
;
192 op
->o_controls
= ((OperationBuffer
*) op
)->ob_controls
;
194 op
->o_callback
= (slap_callback
*) slapi_ch_calloc( 1, sizeof(slap_callback
) );
195 op
->o_callback
->sc_response
= slapi_int_response
;
196 op
->o_callback
->sc_cleanup
= NULL
;
197 op
->o_callback
->sc_private
= pb
;
198 op
->o_callback
->sc_next
= NULL
;
200 conn
->c_pending_ops
.stqh_first
= op
;
202 /* connection object authorization information */
203 conn
->c_authtype
= LDAP_AUTH_NONE
;
204 BER_BVZERO( &conn
->c_authmech
);
205 BER_BVZERO( &conn
->c_dn
);
206 BER_BVZERO( &conn
->c_ndn
);
208 conn
->c_listener
= &slapi_listener
;
209 ber_dupbv( &conn
->c_peer_domain
, (struct berval
*)&slap_unknown_bv
);
210 ber_dupbv( &conn
->c_peer_name
, (struct berval
*)&slap_unknown_bv
);
212 LDAP_STAILQ_INIT( &conn
->c_ops
);
214 BER_BVZERO( &conn
->c_sasl_bind_mech
);
215 conn
->c_sasl_authctx
= NULL
;
216 conn
->c_sasl_sockctx
= NULL
;
217 conn
->c_sasl_extra
= NULL
;
219 conn
->c_sb
= ber_sockbuf_alloc();
221 ber_sockbuf_ctrl( conn
->c_sb
, LBER_SB_OPT_SET_MAX_INCOMING
, &max
);
223 conn
->c_currentber
= NULL
;
225 /* should check status of thread calls */
226 ldap_pvt_thread_mutex_init( &conn
->c_mutex
);
227 ldap_pvt_thread_mutex_init( &conn
->c_write_mutex
);
228 ldap_pvt_thread_cond_init( &conn
->c_write_cv
);
230 ldap_pvt_thread_mutex_lock( &conn
->c_mutex
);
232 conn
->c_n_ops_received
= 0;
233 conn
->c_n_ops_executing
= 0;
234 conn
->c_n_ops_pending
= 0;
235 conn
->c_n_ops_completed
= 0;
241 conn
->c_protocol
= LDAP_VERSION3
;
243 conn
->c_activitytime
= conn
->c_starttime
= slap_get_time();
246 * A real connection ID is required, because syncrepl associates
247 * pending CSNs with unique ( connection, operation ) tuples.
248 * Setting a fake connection ID will cause slap_get_commit_csn()
249 * to return a stale value.
251 connection_assign_nextid( conn
);
253 conn
->c_conn_state
= 0x01; /* SLAP_C_ACTIVE */
254 conn
->c_struct_state
= 0x02; /* SLAP_C_USED */
256 conn
->c_ssf
= conn
->c_transport_ssf
= local_ssf
;
259 backend_connection_init( conn
);
261 conn
->c_send_ldap_result
= slap_send_ldap_result
;
262 conn
->c_send_search_entry
= slap_send_search_entry
;
263 conn
->c_send_ldap_extended
= slap_send_ldap_extended
;
264 conn
->c_send_search_reference
= slap_send_search_reference
;
266 /* operation object */
268 op
->o_protocol
= LDAP_VERSION3
;
269 BER_BVZERO( &op
->o_authmech
);
270 op
->o_time
= slap_get_time();
271 op
->o_do_not_cache
= 1;
272 op
->o_threadctx
= ldap_pvt_thread_pool_context();
273 op
->o_tmpmemctx
= NULL
;
274 op
->o_tmpmfuncs
= &ch_mfuncs
;
276 op
->o_connid
= conn
->c_connid
;
277 op
->o_bd
= frontendDB
;
280 slapi_int_create_object_extensions( SLAPI_X_EXT_OPERATION
, op
);
281 slapi_int_create_object_extensions( SLAPI_X_EXT_CONNECTION
, conn
);
283 pb
->pb_rs
= (SlapReply
*)slapi_ch_calloc( 1, sizeof(SlapReply
) );
288 ldap_pvt_thread_mutex_unlock( &conn
->c_mutex
);
292 slapi_int_set_operation_dn( Slapi_PBlock
*pb
)
295 Operation
*op
= pb
->pb_op
;
297 if ( BER_BVISNULL( &op
->o_ndn
) ) {
299 be
= select_backend( &op
->o_req_ndn
, 1 );
301 ber_dupbv( &op
->o_dn
, &be
->be_rootdn
);
302 ber_dupbv( &op
->o_ndn
, &be
->be_rootndn
);
308 slapi_int_connection_done_pb( Slapi_PBlock
*pb
)
313 PBLOCK_ASSERT_INTOP( pb
, 0 );
318 /* free allocated DNs */
319 if ( !BER_BVISNULL( &op
->o_dn
) )
320 op
->o_tmpfree( op
->o_dn
.bv_val
, op
->o_tmpmemctx
);
321 if ( !BER_BVISNULL( &op
->o_ndn
) )
322 op
->o_tmpfree( op
->o_ndn
.bv_val
, op
->o_tmpmemctx
);
324 if ( !BER_BVISNULL( &op
->o_req_dn
) )
325 op
->o_tmpfree( op
->o_req_dn
.bv_val
, op
->o_tmpmemctx
);
326 if ( !BER_BVISNULL( &op
->o_req_ndn
) )
327 op
->o_tmpfree( op
->o_req_ndn
.bv_val
, op
->o_tmpmemctx
);
329 switch ( op
->o_tag
) {
330 case LDAP_REQ_MODRDN
:
331 if ( !BER_BVISNULL( &op
->orr_newrdn
))
332 op
->o_tmpfree( op
->orr_newrdn
.bv_val
, op
->o_tmpmemctx
);
333 if ( !BER_BVISNULL( &op
->orr_nnewrdn
))
334 op
->o_tmpfree( op
->orr_nnewrdn
.bv_val
, op
->o_tmpmemctx
);
335 if ( op
->orr_newSup
!= NULL
) {
336 assert( !BER_BVISNULL( op
->orr_newSup
) );
337 op
->o_tmpfree( op
->orr_newSup
->bv_val
, op
->o_tmpmemctx
);
338 op
->o_tmpfree( op
->orr_newSup
, op
->o_tmpmemctx
);
340 if ( op
->orr_nnewSup
!= NULL
) {
341 assert( !BER_BVISNULL( op
->orr_nnewSup
) );
342 op
->o_tmpfree( op
->orr_nnewSup
->bv_val
, op
->o_tmpmemctx
);
343 op
->o_tmpfree( op
->orr_nnewSup
, op
->o_tmpmemctx
);
345 slap_mods_free( op
->orr_modlist
, 1 );
348 slap_mods_free( op
->ora_modlist
, 0 );
350 case LDAP_REQ_MODIFY
:
351 slap_mods_free( op
->orm_modlist
, 1 );
353 case LDAP_REQ_SEARCH
:
354 if ( op
->ors_attrs
!= NULL
) {
355 op
->o_tmpfree( op
->ors_attrs
, op
->o_tmpmemctx
);
356 op
->ors_attrs
= NULL
;
363 slapi_ch_free_string( &conn
->c_authmech
.bv_val
);
364 slapi_ch_free_string( &conn
->c_dn
.bv_val
);
365 slapi_ch_free_string( &conn
->c_ndn
.bv_val
);
366 slapi_ch_free_string( &conn
->c_peer_domain
.bv_val
);
367 slapi_ch_free_string( &conn
->c_peer_name
.bv_val
);
369 if ( conn
->c_sb
!= NULL
) {
370 ber_sockbuf_free( conn
->c_sb
);
373 slapi_int_free_object_extensions( SLAPI_X_EXT_OPERATION
, op
);
374 slapi_int_free_object_extensions( SLAPI_X_EXT_CONNECTION
, conn
);
376 slapi_ch_free( (void **)&pb
->pb_op
->o_callback
);
377 slapi_ch_free( (void **)&pb
->pb_op
);
378 slapi_ch_free( (void **)&pb
->pb_conn
);
379 slapi_ch_free( (void **)&pb
->pb_rs
);
383 slapi_int_func_internal_pb( Slapi_PBlock
*pb
, slap_operation_t which
)
386 SlapReply
*rs
= pb
->pb_rs
;
389 PBLOCK_ASSERT_INTOP( pb
, 0 );
391 rc
= slapi_int_get_ctrls( pb
);
392 if ( rc
!= LDAP_SUCCESS
) {
397 pb
->pb_op
->o_bd
= frontendDB
;
398 func
= &frontendDB
->be_bind
;
400 return func
[which
]( pb
->pb_op
, pb
->pb_rs
);
404 slapi_delete_internal_pb( Slapi_PBlock
*pb
)
410 PBLOCK_ASSERT_INTOP( pb
, LDAP_REQ_DELETE
);
412 slapi_int_func_internal_pb( pb
, op_delete
);
418 slapi_add_internal_pb( Slapi_PBlock
*pb
)
421 Slapi_Entry
*entry_orig
= NULL
;
429 PBLOCK_ASSERT_INTOP( pb
, LDAP_REQ_ADD
);
433 entry_orig
= pb
->pb_op
->ora_e
;
434 pb
->pb_op
->ora_e
= NULL
;
437 * The caller can specify a new entry, or a target DN and set
438 * of modifications, but not both.
440 if ( entry_orig
!= NULL
) {
441 if ( pb
->pb_op
->ora_modlist
!= NULL
|| !BER_BVISNULL( &pb
->pb_op
->o_req_ndn
)) {
442 rs
->sr_err
= LDAP_PARAM_ERROR
;
446 assert( BER_BVISNULL( &pb
->pb_op
->o_req_dn
) ); /* shouldn't get set */
447 ber_dupbv( &pb
->pb_op
->o_req_dn
, &entry_orig
->e_name
);
448 ber_dupbv( &pb
->pb_op
->o_req_ndn
, &entry_orig
->e_nname
);
449 } else if ( pb
->pb_op
->ora_modlist
== NULL
|| BER_BVISNULL( &pb
->pb_op
->o_req_ndn
)) {
450 rs
->sr_err
= LDAP_PARAM_ERROR
;
454 pb
->pb_op
->ora_e
= (Entry
*)slapi_ch_calloc( 1, sizeof(Entry
) );
455 ber_dupbv( &pb
->pb_op
->ora_e
->e_name
, &pb
->pb_op
->o_req_dn
);
456 ber_dupbv( &pb
->pb_op
->ora_e
->e_nname
, &pb
->pb_op
->o_req_ndn
);
458 if ( entry_orig
!= NULL
) {
459 assert( pb
->pb_op
->ora_modlist
== NULL
);
461 rs
->sr_err
= slap_entry2mods( entry_orig
, &pb
->pb_op
->ora_modlist
,
462 &rs
->sr_text
, pb
->pb_textbuf
, sizeof( pb
->pb_textbuf
) );
463 if ( rs
->sr_err
!= LDAP_SUCCESS
) {
467 assert( pb
->pb_op
->ora_modlist
!= NULL
);
470 rs
->sr_err
= slap_mods_check( pb
->pb_op
, pb
->pb_op
->ora_modlist
, &rs
->sr_text
,
471 pb
->pb_textbuf
, sizeof( pb
->pb_textbuf
), NULL
);
472 if ( rs
->sr_err
!= LDAP_SUCCESS
) {
476 /* Duplicate the values, because we may call slapi_entry_free() */
477 rs
->sr_err
= slap_mods2entry( pb
->pb_op
->ora_modlist
, &pb
->pb_op
->ora_e
,
478 1, 0, &rs
->sr_text
, pb
->pb_textbuf
, sizeof( pb
->pb_textbuf
) );
479 if ( rs
->sr_err
!= LDAP_SUCCESS
) {
483 oex
.oe
.oe_key
= (void *)do_add
;
485 LDAP_SLIST_INSERT_HEAD(&pb
->pb_op
->o_extra
, &oex
.oe
, oe_next
);
486 rc
= slapi_int_func_internal_pb( pb
, op_add
);
487 LDAP_SLIST_REMOVE(&pb
->pb_op
->o_extra
, &oex
.oe
, OpExtra
, oe_next
);
490 if ( pb
->pb_op
->ora_e
!= NULL
&& oex
.oe_db
!= NULL
) {
491 BackendDB
*bd
= pb
->pb_op
->o_bd
;
493 pb
->pb_op
->o_bd
= oex
.oe_db
;
494 be_entry_release_w( pb
->pb_op
, pb
->pb_op
->ora_e
);
495 pb
->pb_op
->ora_e
= NULL
;
496 pb
->pb_op
->o_bd
= bd
;
502 if ( pb
->pb_op
->ora_e
!= NULL
) {
503 slapi_entry_free( pb
->pb_op
->ora_e
);
504 pb
->pb_op
->ora_e
= NULL
;
506 if ( entry_orig
!= NULL
) {
507 pb
->pb_op
->ora_e
= entry_orig
;
508 slap_mods_free( pb
->pb_op
->ora_modlist
, 1 );
509 pb
->pb_op
->ora_modlist
= NULL
;
516 slapi_modrdn_internal_pb( Slapi_PBlock
*pb
)
522 PBLOCK_ASSERT_INTOP( pb
, LDAP_REQ_MODRDN
);
524 if ( BER_BVISEMPTY( &pb
->pb_op
->o_req_ndn
) ) {
525 pb
->pb_rs
->sr_err
= LDAP_UNWILLING_TO_PERFORM
;
529 slapi_int_func_internal_pb( pb
, op_modrdn
);
537 slapi_modify_internal_pb( Slapi_PBlock
*pb
)
545 PBLOCK_ASSERT_INTOP( pb
, LDAP_REQ_MODIFY
);
549 if ( pb
->pb_op
->orm_modlist
== NULL
) {
550 rs
->sr_err
= LDAP_PARAM_ERROR
;
554 if ( BER_BVISEMPTY( &pb
->pb_op
->o_req_ndn
) ) {
555 rs
->sr_err
= LDAP_UNWILLING_TO_PERFORM
;
559 rs
->sr_err
= slap_mods_check( pb
->pb_op
, pb
->pb_op
->orm_modlist
,
560 &rs
->sr_text
, pb
->pb_textbuf
, sizeof( pb
->pb_textbuf
), NULL
);
561 if ( rs
->sr_err
!= LDAP_SUCCESS
) {
565 slapi_int_func_internal_pb( pb
, op_modify
);
573 slapi_int_search_entry_callback( Slapi_Entry
*entry
, void *callback_data
)
575 int nentries
= 0, i
= 0;
576 Slapi_Entry
**head
= NULL
, **tp
;
577 Slapi_PBlock
*pb
= (Slapi_PBlock
*)callback_data
;
579 PBLOCK_ASSERT_INTOP( pb
, LDAP_REQ_SEARCH
);
581 entry
= slapi_entry_dup( entry
);
582 if ( entry
== NULL
) {
583 return LDAP_NO_MEMORY
;
586 slapi_pblock_get( pb
, SLAPI_NENTRIES
, &nentries
);
587 slapi_pblock_get( pb
, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES
, &head
);
590 if ( nentries
== 0 ) {
591 tp
= (Slapi_Entry
**)slapi_ch_malloc( 2 * sizeof(Slapi_Entry
*) );
593 slapi_entry_free( entry
);
594 return LDAP_NO_MEMORY
;
599 tp
= (Slapi_Entry
**)slapi_ch_realloc( (char *)head
,
600 sizeof(Slapi_Entry
*) * ( i
+ 1 ) );
602 slapi_entry_free( entry
);
603 return LDAP_NO_MEMORY
;
609 slapi_pblock_set( pb
, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES
, (void *)tp
);
610 slapi_pblock_set( pb
, SLAPI_NENTRIES
, (void *)&i
);
616 slapi_search_internal_pb( Slapi_PBlock
*pb
)
618 return slapi_search_internal_callback_pb( pb
,
621 slapi_int_search_entry_callback
,
626 slapi_search_internal_callback_pb( Slapi_PBlock
*pb
,
628 plugin_result_callback prc
,
629 plugin_search_entry_callback psec
,
630 plugin_referral_entry_callback prec
)
639 PBLOCK_ASSERT_INTOP( pb
, LDAP_REQ_SEARCH
);
643 /* search callback and arguments */
644 slapi_pblock_set( pb
, SLAPI_X_INTOP_RESULT_CALLBACK
, (void *)prc
);
645 slapi_pblock_set( pb
, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK
, (void *)psec
);
646 slapi_pblock_set( pb
, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK
, (void *)prec
);
647 slapi_pblock_set( pb
, SLAPI_X_INTOP_CALLBACK_DATA
, (void *)callback_data
);
649 if ( BER_BVISEMPTY( &pb
->pb_op
->ors_filterstr
)) {
650 rs
->sr_err
= LDAP_PARAM_ERROR
;
654 if ( pb
->pb_op
->ors_filter
== NULL
) {
655 pb
->pb_op
->ors_filter
= slapi_str2filter( pb
->pb_op
->ors_filterstr
.bv_val
);
656 if ( pb
->pb_op
->ors_filter
== NULL
) {
657 rs
->sr_err
= LDAP_PROTOCOL_ERROR
;
664 slapi_int_func_internal_pb( pb
, op_search
);
668 slapi_filter_free( pb
->pb_op
->ors_filter
, 1 );
669 pb
->pb_op
->ors_filter
= NULL
;
672 slapi_pblock_delete_param( pb
, SLAPI_X_INTOP_RESULT_CALLBACK
);
673 slapi_pblock_delete_param( pb
, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK
);
674 slapi_pblock_delete_param( pb
, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK
);
675 slapi_pblock_delete_param( pb
, SLAPI_X_INTOP_CALLBACK_DATA
);
680 /* Wrappers for old API */
683 slapi_search_internal_set_pb( Slapi_PBlock
*pb
,
689 LDAPControl
**controls
,
690 const char *uniqueid
,
691 Slapi_ComponentId
*plugin_identity
,
692 int operation_flags
)
694 int no_limit
= SLAP_NO_LIMIT
;
695 int deref
= LDAP_DEREF_NEVER
;
697 slapi_int_connection_init_pb( pb
, LDAP_REQ_SEARCH
);
698 slapi_pblock_set( pb
, SLAPI_SEARCH_TARGET
, (void *)base
);
699 slapi_pblock_set( pb
, SLAPI_SEARCH_SCOPE
, (void *)&scope
);
700 slapi_pblock_set( pb
, SLAPI_SEARCH_FILTER
, (void *)0 );
701 slapi_pblock_set( pb
, SLAPI_SEARCH_STRFILTER
, (void *)filter
);
702 slapi_pblock_set( pb
, SLAPI_SEARCH_ATTRS
, (void *)attrs
);
703 slapi_pblock_set( pb
, SLAPI_SEARCH_ATTRSONLY
, (void *)&attrsonly
);
704 slapi_pblock_set( pb
, SLAPI_REQCONTROLS
, (void *)controls
);
705 slapi_pblock_set( pb
, SLAPI_TARGET_UNIQUEID
, (void *)uniqueid
);
706 slapi_pblock_set( pb
, SLAPI_PLUGIN_IDENTITY
, (void *)plugin_identity
);
707 slapi_pblock_set( pb
, SLAPI_X_INTOP_FLAGS
, (void *)&operation_flags
);
708 slapi_pblock_set( pb
, SLAPI_SEARCH_DEREF
, (void *)&deref
);
709 slapi_pblock_set( pb
, SLAPI_SEARCH_SIZELIMIT
, (void *)&no_limit
);
710 slapi_pblock_set( pb
, SLAPI_SEARCH_TIMELIMIT
, (void *)&no_limit
);
712 slapi_int_set_operation_dn( pb
);
716 slapi_search_internal(
720 LDAPControl
**controls
,
726 pb
= slapi_pblock_new();
728 slapi_search_internal_set_pb( pb
, ldn
, scope
, filStr
,
730 controls
, NULL
, NULL
, 0 );
732 slapi_search_internal_pb( pb
);
738 slapi_modify_internal_set_pb( Slapi_PBlock
*pb
,
741 LDAPControl
**controls
,
742 const char *uniqueid
,
743 Slapi_ComponentId
*plugin_identity
,
744 int operation_flags
)
746 slapi_int_connection_init_pb( pb
, LDAP_REQ_MODIFY
);
747 slapi_pblock_set( pb
, SLAPI_MODIFY_TARGET
, (void *)dn
);
748 slapi_pblock_set( pb
, SLAPI_MODIFY_MODS
, (void *)mods
);
749 slapi_pblock_set( pb
, SLAPI_REQCONTROLS
, (void *)controls
);
750 slapi_pblock_set( pb
, SLAPI_TARGET_UNIQUEID
, (void *)uniqueid
);
751 slapi_pblock_set( pb
, SLAPI_PLUGIN_IDENTITY
, (void *)plugin_identity
);
752 slapi_pblock_set( pb
, SLAPI_X_INTOP_FLAGS
, (void *)&operation_flags
);
753 slapi_int_set_operation_dn( pb
);
756 /* Function : slapi_modify_internal
758 * Description: Plugin functions call this routine to modify an entry
759 * in the backend directly
760 * Return values : LDAP_SUCCESS
764 * LDAP_UNWILLING_TO_PERFORM
767 slapi_modify_internal(
770 LDAPControl
**controls
,
775 pb
= slapi_pblock_new();
777 slapi_modify_internal_set_pb( pb
, ldn
, mods
, controls
, NULL
, NULL
, 0 );
778 slapi_pblock_set( pb
, SLAPI_LOG_OPERATION
, (void *)&log_change
);
779 slapi_modify_internal_pb( pb
);
785 slapi_add_internal_set_pb( Slapi_PBlock
*pb
,
788 LDAPControl
**controls
,
789 Slapi_ComponentId
*plugin_identity
,
790 int operation_flags
)
792 slapi_int_connection_init_pb( pb
, LDAP_REQ_ADD
);
793 slapi_pblock_set( pb
, SLAPI_ADD_TARGET
, (void *)dn
);
794 slapi_pblock_set( pb
, SLAPI_MODIFY_MODS
, (void *)attrs
);
795 slapi_pblock_set( pb
, SLAPI_REQCONTROLS
, (void *)controls
);
796 slapi_pblock_set( pb
, SLAPI_PLUGIN_IDENTITY
, (void *)plugin_identity
);
797 slapi_pblock_set( pb
, SLAPI_X_INTOP_FLAGS
, (void *)&operation_flags
);
798 slapi_int_set_operation_dn( pb
);
807 LDAPControl
**controls
,
812 pb
= slapi_pblock_new();
814 slapi_add_internal_set_pb( pb
, dn
, attrs
, controls
, NULL
, 0);
815 slapi_pblock_set( pb
, SLAPI_LOG_OPERATION
, (void *)&log_change
);
816 slapi_add_internal_pb( pb
);
822 slapi_add_entry_internal_set_pb( Slapi_PBlock
*pb
,
824 LDAPControl
**controls
,
825 Slapi_ComponentId
*plugin_identity
,
826 int operation_flags
)
828 slapi_int_connection_init_pb( pb
, LDAP_REQ_ADD
);
829 slapi_pblock_set( pb
, SLAPI_ADD_ENTRY
, (void *)e
);
830 slapi_pblock_set( pb
, SLAPI_REQCONTROLS
, (void *)controls
);
831 slapi_pblock_set( pb
, SLAPI_PLUGIN_IDENTITY
, (void *)plugin_identity
);
832 slapi_pblock_set( pb
, SLAPI_X_INTOP_FLAGS
, (void *)&operation_flags
);
833 slapi_int_set_operation_dn( pb
);
837 slapi_add_entry_internal(
839 LDAPControl
**controls
,
844 pb
= slapi_pblock_new();
846 slapi_add_entry_internal_set_pb( pb
, e
, controls
, NULL
, 0 );
847 slapi_pblock_set( pb
, SLAPI_LOG_OPERATION
, (void *)&log_change
);
848 slapi_add_internal_pb( pb
);
854 slapi_rename_internal_set_pb( Slapi_PBlock
*pb
,
857 const char *newsuperior
,
859 LDAPControl
**controls
,
860 const char *uniqueid
,
861 Slapi_ComponentId
*plugin_identity
,
862 int operation_flags
)
864 slapi_int_connection_init_pb( pb
, LDAP_REQ_MODRDN
);
865 slapi_pblock_set( pb
, SLAPI_MODRDN_TARGET
, (void *)olddn
);
866 slapi_pblock_set( pb
, SLAPI_MODRDN_NEWRDN
, (void *)newrdn
);
867 slapi_pblock_set( pb
, SLAPI_MODRDN_NEWSUPERIOR
, (void *)newsuperior
);
868 slapi_pblock_set( pb
, SLAPI_MODRDN_DELOLDRDN
, (void *)&deloldrdn
);
869 slapi_pblock_set( pb
, SLAPI_REQCONTROLS
, (void *)controls
);
870 slapi_pblock_set( pb
, SLAPI_TARGET_UNIQUEID
, (void *)uniqueid
);
871 slapi_pblock_set( pb
, SLAPI_PLUGIN_IDENTITY
, (void *)plugin_identity
);
872 slapi_pblock_set( pb
, SLAPI_X_INTOP_FLAGS
, (void *)&operation_flags
);
873 slap_modrdn2mods( pb
->pb_op
, pb
->pb_rs
);
874 slapi_int_set_operation_dn( pb
);
877 /* Function : slapi_modrdn_internal
879 * Description : Plugin functions call this routine to modify the rdn
880 * of an entry in the backend directly
881 * Return values : LDAP_SUCCESS
885 * LDAP_UNWILLING_TO_PERFORM
887 * NOTE: This function does not support the "newSuperior" option from LDAP V3.
890 slapi_modrdn_internal(
894 LDAPControl
**controls
,
899 pb
= slapi_pblock_new ();
901 slapi_rename_internal_set_pb( pb
, olddn
, lnewrdn
, NULL
,
902 deloldrdn
, controls
, NULL
, NULL
, 0 );
903 slapi_pblock_set( pb
, SLAPI_LOG_OPERATION
, (void *)&log_change
);
904 slapi_modrdn_internal_pb( pb
);
910 slapi_delete_internal_set_pb( Slapi_PBlock
*pb
,
912 LDAPControl
**controls
,
913 const char *uniqueid
,
914 Slapi_ComponentId
*plugin_identity
,
915 int operation_flags
)
917 slapi_int_connection_init_pb( pb
, LDAP_REQ_DELETE
);
918 slapi_pblock_set( pb
, SLAPI_TARGET_DN
, (void *)dn
);
919 slapi_pblock_set( pb
, SLAPI_REQCONTROLS
, (void *)controls
);
920 slapi_pblock_set( pb
, SLAPI_TARGET_UNIQUEID
, (void *)uniqueid
);
921 slapi_pblock_set( pb
, SLAPI_PLUGIN_IDENTITY
, (void *)plugin_identity
);
922 slapi_pblock_set( pb
, SLAPI_X_INTOP_FLAGS
, (void *)&operation_flags
);
923 slapi_int_set_operation_dn( pb
);
926 /* Function : slapi_delete_internal
928 * Description : Plugin functions call this routine to delete an entry
929 * in the backend directly
930 * Return values : LDAP_SUCCESS
934 * LDAP_UNWILLING_TO_PERFORM
937 slapi_delete_internal(
939 LDAPControl
**controls
,
944 pb
= slapi_pblock_new();
946 slapi_delete_internal_set_pb( pb
, ldn
, controls
, NULL
, NULL
, 0 );
947 slapi_pblock_set( pb
, SLAPI_LOG_OPERATION
, (void *)&log_change
);
948 slapi_delete_internal_pb( pb
);
953 #endif /* LDAP_SLAPI */