1 /* distproc.c - implement distributed procedures */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2005-2006 The OpenLDAP Foundation.
6 * Portions Copyright 2003 Howard Chu.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in the file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Pierangelo Masarati for inclusion
19 * in OpenLDAP Software.
20 * Based on back-ldap and slapo-chain, developed by Howard Chu
29 #include <ac/string.h>
30 #include <ac/socket.h>
33 #include "back-ldap.h"
38 * From <draft-sermersheim-ldap-distproc>
41 ContinuationReference ::= SET {
42 referralURI [0] SET SIZE (1..MAX) OF URI,
43 localReference [2] LDAPDN,
44 referenceType [3] ReferenceType,
45 remainingName [4] RelativeLDAPDN OPTIONAL,
46 searchScope [5] SearchScope OPTIONAL,
47 searchedSubtrees [6] SearchedSubtrees OPTIONAL,
48 failedName [7] LDAPDN OPTIONAL,
51 ReferenceType ::= ENUMERATED {
55 nonSpecificSubordinate (3),
58 immediateSuperior (6),
62 SearchScope ::= ENUMERATED {
66 subordinateSubtree (3),
69 SearchedSubtrees ::= SET OF RelativeLDAPDN
71 LDAPDN, RelativeLDAPDN, and LDAPString, are defined in [RFC2251].
75 typedef enum ReferenceType_t {
76 LDAP_DP_RT_UNKNOWN = -1,
77 LDAP_DP_RT_SUPERIOR = 0,
78 LDAP_DP_RT_SUBORDINATE = 1,
80 LDAP_DP_RT_NONSPECIFICSUBORDINATE = 3,
81 LDAP_DP_RT_SUPPLIER = 4,
82 LDAP_DP_RT_MASTER = 5,
83 LDAP_DP_RT_IMMEDIATESUPERIOR = 6,
88 typedef enum SearchScope_t {
89 LDAP_DP_SS_UNKNOWN = -1,
90 LDAP_DP_SS_BASEOBJECT = 0,
91 LDAP_DP_SS_SINGLELEVEL = 1,
92 LDAP_DP_SS_WHOLESUBTREE = 2,
93 LDAP_DP_SS_SUBORDINATESUBTREE = 3,
97 typedef struct ContinuationReference_t {
98 BerVarray cr_referralURI;
100 struct berval cr_localReference;
101 ReferenceType_t cr_referenceType;
102 struct berval cr_remainingName;
103 SearchScope_t cr_searchScope;
104 BerVarray cr_searchedSubtrees;
105 struct berval cr_failedName;
106 } ContinuationReference_t;
107 #define CR_INIT { NULL, BER_BVNULL, LDAP_DP_RT_UNKNOWN, BER_BVNULL, LDAP_DP_SS_UNKNOWN, NULL, BER_BVNULL }
109 static struct berval bv2rt[] = {
110 BER_BVC( "superior" ),
111 BER_BVC( "subordinate" ),
113 BER_BVC( "nonSpecificSubordinate" ),
114 BER_BVC( "supplier" ),
116 BER_BVC( "immediateSuperior" ),
121 static struct berval bv2ss[] = {
122 BER_BVC( "baseObject" ),
123 BER_BVC( "singleLevel" ),
124 BER_BVC( "wholeSubtree" ),
125 BER_BVC( "subordinateSubtree" ),
129 static struct berval *
130 ldap_distproc_rt2bv( ReferenceType_t rt )
136 ldap_distproc_rt2str( ReferenceType_t rt )
138 return bv2rt[ rt ].bv_val;
141 static ReferenceType_t
142 ldap_distproc_bv2rt( struct berval *bv )
146 for ( rt = 0; !BER_BVISNULL( &bv2rt[ rt ] ); rt++ ) {
147 if ( ber_bvstrcasecmp( bv, &bv2rt[ rt ] ) == 0 ) {
152 return LDAP_DP_RT_UNKNOWN;
155 static ReferenceType_t
156 ldap_distproc_str2rt( const char *s )
160 ber_str2bv( s, 0, 0, &bv );
161 return ldap_distproc_bv2rt( &bv );
164 static struct berval *
165 ldap_distproc_ss2bv( SearchScope_t ss )
171 ldap_distproc_ss2str( SearchScope_t ss )
173 return bv2ss[ ss ].bv_val;
177 ldap_distproc_bv2ss( struct berval *bv )
181 for ( ss = 0; !BER_BVISNULL( &bv2ss[ ss ] ); ss++ ) {
182 if ( ber_bvstrcasecmp( bv, &bv2ss[ ss ] ) == 0 ) {
187 return LDAP_DP_SS_UNKNOWN;
191 ldap_distproc_str2ss( const char *s )
195 ber_str2bv( s, 0, 0, &bv );
196 return ldap_distproc_bv2ss( &bv );
200 * NOTE: this overlay assumes that the chainingBehavior control
201 * is registered by the chain overlay; it may move here some time.
202 * This overlay provides support for that control as well.
206 static int sc_returnContRef;
207 #define o_returnContRef o_ctrlflag[sc_returnContRef]
208 #define get_returnContRef(op) ((op)->o_returnContRef & SLAP_CONTROL_MASK)
210 static struct berval slap_EXOP_CHAINEDREQUEST = BER_BVC( LDAP_EXOP_X_CHAINEDREQUEST );
211 static struct berval slap_FEATURE_CANCHAINOPS = BER_BVC( LDAP_FEATURE_X_CANCHAINOPS );
213 static BackendInfo *lback;
215 typedef struct ldap_distproc_t {
216 /* "common" configuration info (anything occurring before an "uri") */
217 ldapinfo_t *lc_common_li;
219 /* current configuration info */
220 ldapinfo_t *lc_cfg_li;
222 /* tree of configured[/generated?] "uri" info */
223 ldap_avl_info_t lc_lai;
226 #define LDAP_DISTPROC_F_NONE (0x00U)
227 #define LDAP_DISTPROC_F_CHAINING (0x01U)
228 #define LDAP_DISTPROC_F_CACHE_URI (0x10U)
230 #define LDAP_DISTPROC_CHAINING( lc ) ( ( (lc)->lc_flags & LDAP_DISTPROC_F_CHAINING ) == LDAP_DISTPROC_F_CHAINING )
231 #define LDAP_DISTPROC_CACHE_URI( lc ) ( ( (lc)->lc_flags & LDAP_DISTPROC_F_CACHE_URI ) == LDAP_DISTPROC_F_CACHE_URI )
235 static int ldap_distproc_db_init_common( BackendDB *be );
236 static int ldap_distproc_db_init_one( BackendDB *be );
237 #define ldap_distproc_db_open_one(be) (lback)->bi_db_open( (be) )
238 #define ldap_distproc_db_close_one(be) (0)
239 #define ldap_distproc_db_destroy_one(be) (lback)->bi_db_destroy( (be) )
242 ldap_distproc_parse_ctrl(
248 ldap_distproc_uri_cmp( const void *c1, const void *c2 )
250 const ldapinfo_t *li1 = (const ldapinfo_t *)c1;
251 const ldapinfo_t *li2 = (const ldapinfo_t *)c2;
253 assert( li1->li_bvuri != NULL );
254 assert( !BER_BVISNULL( &li1->li_bvuri[ 0 ] ) );
255 assert( BER_BVISNULL( &li1->li_bvuri[ 1 ] ) );
257 assert( li2->li_bvuri != NULL );
258 assert( !BER_BVISNULL( &li2->li_bvuri[ 0 ] ) );
259 assert( BER_BVISNULL( &li2->li_bvuri[ 1 ] ) );
261 /* If local DNs don't match, it is definitely not a match */
262 return ber_bvcmp( &li1->li_bvuri[ 0 ], &li2->li_bvuri[ 0 ] );
266 ldap_distproc_uri_dup( void *c1, void *c2 )
268 ldapinfo_t *li1 = (ldapinfo_t *)c1;
269 ldapinfo_t *li2 = (ldapinfo_t *)c2;
271 assert( li1->li_bvuri != NULL );
272 assert( !BER_BVISNULL( &li1->li_bvuri[ 0 ] ) );
273 assert( BER_BVISNULL( &li1->li_bvuri[ 1 ] ) );
275 assert( li2->li_bvuri != NULL );
276 assert( !BER_BVISNULL( &li2->li_bvuri[ 0 ] ) );
277 assert( BER_BVISNULL( &li2->li_bvuri[ 1 ] ) );
279 /* Cannot have more than one shared session with same DN */
280 if ( ber_bvcmp( &li1->li_bvuri[ 0 ], &li2->li_bvuri[ 0 ] ) == 0 ) {
288 ldap_distproc_operational( Operation *op, SlapReply *rs )
290 /* Trap entries generated by back-ldap.
292 * FIXME: we need a better way to recognize them; a cleaner
293 * solution would be to be able to intercept the response
294 * of be_operational(), so that we can divert only those
295 * calls that fail because operational attributes were
296 * requested for entries that do not belong to the underlying
297 * database. This fix is likely to intercept also entries
298 * generated by back-perl and so. */
299 if ( rs->sr_entry->e_private == NULL ) {
303 return SLAP_CB_CONTINUE;
307 ldap_distproc_response( Operation *op, SlapReply *rs )
309 return SLAP_CB_CONTINUE;
317 /* NOTE: the chaining behavior control is registered
318 * by the chain overlay; it may move here some time */
325 static ConfigDriver distproc_cfgen;
326 static ConfigCfAdd distproc_cfadd;
327 static ConfigLDAPadd distproc_ldadd;
329 static ConfigTable distproc_cfg[] = {
330 { "distproc-chaining", "args",
331 2, 4, 0, ARG_MAGIC|ARG_BERVAL|DP_CHAINING, distproc_cfgen,
332 /* NOTE: using the same attributeTypes defined
333 * for the "chain" overlay */
334 "( OLcfgOvAt:3.1 NAME 'olcChainingBehavior' "
335 "DESC 'Chaining behavior control parameters (draft-sermersheim-ldap-chaining)' "
336 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
337 { "distproc-cache-uri", "TRUE/FALSE",
338 2, 2, 0, ARG_MAGIC|ARG_ON_OFF|DP_CACHE_URI, distproc_cfgen,
339 "( OLcfgOvAt:3.2 NAME 'olcCacheURI' "
340 "DESC 'Enables caching of URIs not present in configuration' "
341 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
342 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
345 static ConfigOCs distproc_ocs[] = {
347 "NAME 'olcDistProcConfig' "
348 "DESC 'Distributed procedures <draft-sermersheim-ldap-distproc> configuration' "
349 "SUP olcOverlayConfig "
351 "olcChainingBehavior $ "
354 Cft_Overlay, distproc_cfg, NULL, distproc_cfadd },
356 "NAME 'olcDistProcDatabase' "
357 "DESC 'Distributed procedure remote server configuration' "
359 Cft_Misc, distproc_cfg, distproc_ldadd },
364 distproc_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
371 AttributeDescription *ad = NULL;
377 if ( p->ce_type != Cft_Overlay
379 || p->ce_bi->bi_cf_ocs != distproc_ocs )
381 return LDAP_CONSTRAINT_VIOLATION;
384 on = (slap_overinst *)p->ce_bi;
385 lc = (ldap_distproc_t *)on->on_bi.bi_private;
387 assert( ca->be == NULL );
388 ca->be = (BackendDB *)ch_calloc( 1, sizeof( BackendDB ) );
390 ca->be->bd_info = (BackendInfo *)on;
392 rc = slap_str2ad( "olcDbURI", &ad, &text );
393 assert( rc == LDAP_SUCCESS );
395 at = attr_find( e->e_attrs, ad );
396 if ( lc->lc_common_li == NULL && at != NULL ) {
397 /* FIXME: we should generate an empty default entry
398 * if none is supplied */
399 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
400 "first underlying database \"%s\" "
401 "cannot contain attribute \"%s\".\n",
402 e->e_name.bv_val, ad->ad_cname.bv_val, 0 );
403 rc = LDAP_CONSTRAINT_VIOLATION;
406 } else if ( lc->lc_common_li != NULL && at == NULL ) {
407 /* FIXME: we should generate an empty default entry
408 * if none is supplied */
409 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
410 "subsequent underlying database \"%s\" "
411 "must contain attribute \"%s\".\n",
412 e->e_name.bv_val, ad->ad_cname.bv_val, 0 );
413 rc = LDAP_CONSTRAINT_VIOLATION;
417 if ( lc->lc_common_li == NULL ) {
418 rc = ldap_distproc_db_init_common( ca->be );
421 rc = ldap_distproc_db_init_one( ca->be );
425 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
426 "unable to init %sunderlying database \"%s\".\n",
427 lc->lc_common_li == NULL ? "common " : "", e->e_name.bv_val, 0 );
428 return LDAP_CONSTRAINT_VIOLATION;
431 li = ca->be->be_private;
433 if ( lc->lc_common_li == NULL ) {
434 lc->lc_common_li = li;
436 } else if ( avl_insert( &lc->lc_lai.lai_tree, (caddr_t)li,
437 ldap_distproc_uri_cmp, ldap_distproc_uri_dup ) )
439 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
440 "database \"%s\" insert failed.\n",
441 e->e_name.bv_val, 0, 0 );
442 rc = LDAP_CONSTRAINT_VIOLATION;
447 if ( rc != LDAP_SUCCESS ) {
448 (void)ldap_distproc_db_destroy_one( ca->be );
456 typedef struct ldap_distproc_cfadd_apply_t {
462 } ldap_distproc_cfadd_apply_t;
465 ldap_distproc_cfadd_apply( void *datum, void *arg )
467 ldapinfo_t *li = (ldapinfo_t *)datum;
468 ldap_distproc_cfadd_apply_t *lca = (ldap_distproc_cfadd_apply_t *)arg;
472 /* FIXME: should not hardcode "olcDatabase" here */
473 bv.bv_len = snprintf( lca->ca->msg, sizeof( lca->ca->msg ),
474 "olcDatabase={%d}%s", lca->count, lback->bi_type );
475 bv.bv_val = lca->ca->msg;
477 lca->ca->be->be_private = (void *)li;
478 config_build_entry( lca->op, lca->rs, lca->p->e_private, lca->ca,
479 &bv, lback->bi_cf_ocs, &distproc_ocs[ 1 ] );
487 distproc_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *ca )
489 CfEntryInfo *pe = p->e_private;
490 slap_overinst *on = (slap_overinst *)pe->ce_bi;
491 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
492 void *priv = (void *)ca->be->be_private;
494 if ( lback->bi_cf_ocs ) {
495 ldap_distproc_cfadd_apply_t lca = { 0 };
503 (void)ldap_distproc_cfadd_apply( (void *)lc->lc_common_li, (void *)&lca );
505 (void)avl_apply( lc->lc_lai.lai_tree, ldap_distproc_cfadd_apply,
506 &lca, 1, AVL_INORDER );
508 ca->be->be_private = priv;
515 distproc_cfgen( ConfigArgs *c )
517 slap_overinst *on = (slap_overinst *)c->bi;
518 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
522 if ( c->op == SLAP_CONFIG_EMIT ) {
525 c->value_int = LDAP_DISTPROC_CACHE_URI( lc );
534 } else if ( c->op == LDAP_MOD_DELETE ) {
540 lc->lc_flags &= ~LDAP_DISTPROC_F_CACHE_URI;
551 if ( c->value_int ) {
552 lc->lc_flags |= LDAP_DISTPROC_F_CACHE_URI;
554 lc->lc_flags &= ~LDAP_DISTPROC_F_CACHE_URI;
567 ldap_distproc_db_init(
570 slap_overinst *on = (slap_overinst *)be->bd_info;
571 ldap_distproc_t *lc = NULL;
573 if ( lback == NULL ) {
574 lback = backend_info( "ldap" );
576 if ( lback == NULL ) {
581 lc = ch_malloc( sizeof( ldap_distproc_t ) );
585 memset( lc, 0, sizeof( ldap_distproc_t ) );
587 on->on_bi.bi_private = (void *)lc;
593 ldap_distproc_db_config(
600 slap_overinst *on = (slap_overinst *)be->bd_info;
601 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
603 int rc = SLAP_CONF_UNKNOWN;
605 if ( lc->lc_common_li == NULL ) {
606 void *be_private = be->be_private;
607 ldap_distproc_db_init_common( be );
608 lc->lc_common_li = lc->lc_cfg_li = (ldapinfo_t *)be->be_private;
609 be->be_private = be_private;
612 /* Something for the distproc database? */
613 if ( strncasecmp( argv[ 0 ], "distproc-", STRLENOF( "distproc-" ) ) == 0 ) {
614 char *save_argv0 = argv[ 0 ];
615 BackendInfo *bd_info = be->bd_info;
616 void *be_private = be->be_private;
617 ConfigOCs *be_cf_ocs = be->be_cf_ocs;
620 argv[ 0 ] += STRLENOF( "distproc-" );
622 if ( strcasecmp( argv[ 0 ], "uri" ) == 0 ) {
623 rc = ldap_distproc_db_init_one( be );
625 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
626 "underlying slapd-ldap initialization failed.\n.",
630 lc->lc_cfg_li = be->be_private;
634 /* TODO: add checks on what other slapd-ldap(5) args
635 * should be put in the template; this is not quite
636 * harmful, because attributes that shouldn't don't
637 * get actually used, but the user should at least
642 be->be_private = (void *)lc->lc_cfg_li;
643 be->be_cf_ocs = lback->bi_cf_ocs;
645 rc = config_generic_wrapper( be, fname, lineno, argc, argv );
647 argv[ 0 ] = save_argv0;
648 be->be_cf_ocs = be_cf_ocs;
649 be->be_private = be_private;
650 be->bd_info = bd_info;
658 db.be_private = (void *)lc->lc_cfg_li;
659 ldap_distproc_db_destroy_one( &db );
660 lc->lc_cfg_li = NULL;
663 if ( lc->lc_cfg_li->li_bvuri == NULL
664 || BER_BVISNULL( &lc->lc_cfg_li->li_bvuri[ 0 ] )
665 || !BER_BVISNULL( &lc->lc_cfg_li->li_bvuri[ 1 ] ) )
667 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
668 "no URI list allowed in slapo-distproc.\n",
671 goto private_destroy;
674 if ( avl_insert( &lc->lc_lai.lai_tree,
675 (caddr_t)lc->lc_cfg_li,
676 ldap_distproc_uri_cmp, ldap_distproc_uri_dup ) )
678 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
679 "duplicate URI in slapo-distproc.\n",
682 goto private_destroy;
699 typedef struct ldap_distproc_db_apply_t {
702 } ldap_distproc_db_apply_t;
705 ldap_distproc_db_apply( void *datum, void *arg )
707 ldapinfo_t *li = (ldapinfo_t *)datum;
708 ldap_distproc_db_apply_t *lca = (ldap_distproc_db_apply_t *)arg;
710 lca->be->be_private = (void *)li;
712 return lca->func( lca->be );
716 ldap_distproc_db_func(
721 slap_overinst *on = (slap_overinst *)be->bd_info;
722 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
727 BI_db_func *func = (&lback->bi_db_open)[ which ];
729 if ( func != NULL && lc->lc_common_li != NULL ) {
733 db.be_private = lc->lc_common_li;
741 if ( lc->lc_lai.lai_tree != NULL ) {
742 ldap_distproc_db_apply_t lca;
747 rc = avl_apply( lc->lc_lai.lai_tree,
748 ldap_distproc_db_apply, (void *)&lca,
749 1, AVL_INORDER ) != AVL_NOMORE;
758 ldap_distproc_db_open(
761 return ldap_distproc_db_func( be, db_open );
765 ldap_distproc_db_close(
768 return ldap_distproc_db_func( be, db_close );
772 ldap_distproc_db_destroy(
775 slap_overinst *on = (slap_overinst *) be->bd_info;
776 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
780 rc = ldap_distproc_db_func( be, db_destroy );
783 avl_free( lc->lc_lai.lai_tree, NULL );
791 * inits one instance of the slapd-ldap backend, and stores
792 * the private info in be_private of the arg
795 ldap_distproc_db_init_common(
798 BackendInfo *bi = be->bd_info;
802 be->be_private = NULL;
803 t = lback->bi_db_init( be );
813 * inits one instance of the slapd-ldap backend, stores
814 * the private info in be_private of the arg and fills
815 * selected fields with data from the template.
817 * NOTE: add checks about the other fields of the template,
818 * which are ignored and SHOULD NOT be configured by the user.
821 ldap_distproc_db_init_one(
824 slap_overinst *on = (slap_overinst *)be->bd_info;
825 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
827 BackendInfo *bi = be->bd_info;
833 be->be_private = NULL;
834 t = lback->bi_db_init( be );
838 li = (ldapinfo_t *)be->be_private;
840 /* copy common data */
841 li->li_nretries = lc->lc_common_li->li_nretries;
842 li->li_flags = lc->lc_common_li->li_flags;
843 li->li_version = lc->lc_common_li->li_version;
844 for ( t = 0; t < LDAP_BACK_OP_LAST; t++ ) {
845 li->li_timeout[ t ] = lc->lc_common_li->li_timeout[ t ];
852 typedef struct ldap_distproc_conn_apply_t {
855 } ldap_distproc_conn_apply_t;
858 ldap_distproc_conn_apply( void *datum, void *arg )
860 ldapinfo_t *li = (ldapinfo_t *)datum;
861 ldap_distproc_conn_apply_t *lca = (ldap_distproc_conn_apply_t *)arg;
863 lca->be->be_private = (void *)li;
865 return lback->bi_connection_destroy( lca->be, lca->conn );
869 ldap_distproc_connection_destroy(
874 slap_overinst *on = (slap_overinst *) be->bd_info;
875 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
876 void *private = be->be_private;
877 ldap_distproc_conn_apply_t lca;
880 be->be_private = NULL;
883 ldap_pvt_thread_mutex_lock( &lc->lc_lai.lai_mutex );
884 rc = avl_apply( lc->lc_lai.lai_tree, ldap_distproc_conn_apply,
885 (void *)&lca, 1, AVL_INORDER ) != AVL_NOMORE;
886 ldap_pvt_thread_mutex_unlock( &lc->lc_lai.lai_mutex );
887 be->be_private = private;
893 ldap_distproc_parse_returnContRef_ctrl(
898 if ( get_returnContRef( op ) != SLAP_CONTROL_NONE ) {
899 rs->sr_text = "returnContinuationReference control specified multiple times";
900 return LDAP_PROTOCOL_ERROR;
903 if ( op->o_pagedresults != SLAP_CONTROL_NONE ) {
904 rs->sr_text = "returnContinuationReference control specified with pagedResults control";
905 return LDAP_PROTOCOL_ERROR;
908 if ( !BER_BVISEMPTY( &ctrl->ldctl_value ) ) {
909 rs->sr_text = "returnContinuationReference control: value must be NULL";
910 return LDAP_PROTOCOL_ERROR;
913 op->o_returnContRef = ctrl->ldctl_iscritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
919 ldap_exop_chained_request(
923 Statslog( LDAP_DEBUG_STATS, "%s CHAINED REQUEST\n",
924 op->o_log_prefix, 0, 0, 0, 0 );
926 rs->sr_err = backend_check_restrictions( op, rs,
927 (struct berval *)&slap_EXOP_CHAINEDREQUEST );
928 if ( rs->sr_err != LDAP_SUCCESS ) {
932 /* by now, just reject requests */
933 rs->sr_text = "under development";
934 return LDAP_UNWILLING_TO_PERFORM;
938 static slap_overinst distproc;
941 distproc_initialize( void )
945 /* Make sure we don't exceed the bits reserved for userland */
946 config_check_userland( DP_LAST );
948 rc = load_extop( (struct berval *)&slap_EXOP_CHAINEDREQUEST,
949 SLAP_EXOP_HIDE, ldap_exop_chained_request );
950 if ( rc != LDAP_SUCCESS ) {
951 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
952 "unable to register chainedRequest exop: %d.\n",
957 rc = supported_feature_load( &slap_FEATURE_CANCHAINOPS );
958 if ( rc != LDAP_SUCCESS ) {
959 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
960 "unable to register canChainOperations supported feature: %d.\n",
965 rc = register_supported_control( LDAP_CONTROL_X_RETURNCONTREF,
966 SLAP_CTRL_GLOBAL|SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE, NULL,
967 ldap_distproc_parse_returnContRef_ctrl, &sc_returnContRef );
968 if ( rc != LDAP_SUCCESS ) {
969 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
970 "unable to register returnContinuationReference control: %d.\n",
975 distproc.on_bi.bi_type = "distproc";
976 distproc.on_bi.bi_db_init = ldap_distproc_db_init;
977 distproc.on_bi.bi_db_config = ldap_distproc_db_config;
978 distproc.on_bi.bi_db_open = ldap_distproc_db_open;
979 distproc.on_bi.bi_db_close = ldap_distproc_db_close;
980 distproc.on_bi.bi_db_destroy = ldap_distproc_db_destroy;
982 /* ... otherwise the underlying backend's function would be called,
983 * likely passing an invalid entry; on the contrary, the requested
984 * operational attributes should have been returned while chasing
985 * the referrals. This all in all is a bit messy, because part
986 * of the operational attributes are generated by the backend;
987 * part by the frontend; back-ldap should receive all the available
988 * ones from the remote server, but then, on its own, it strips those
989 * it assumes will be (re)generated by the frontend (e.g.
990 * subschemaSubentry, entryDN, ...) */
991 distproc.on_bi.bi_operational = ldap_distproc_operational;
993 distproc.on_bi.bi_connection_destroy = ldap_distproc_connection_destroy;
995 distproc.on_response = ldap_distproc_response;
997 distproc.on_bi.bi_cf_ocs = distproc_ocs;
999 rc = config_register_schema( distproc_cfg, distproc_ocs );
1004 return overlay_register( &distproc );
1007 #endif /* LDAP_DEVEL */