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 'olcChainCacheURI' "
340 "DESC 'Enables caching of URIs not present in configuration' "
342 "SINGLE-VALUE )", NULL, NULL },
343 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
346 static ConfigOCs distproc_ocs[] = {
348 "NAME 'olcDistProcConfig' "
349 "DESC 'Distributed procedures <draft-sermersheim-ldap-distproc> configuration' "
350 "SUP olcOverlayConfig "
352 "olcChainingBehavior $ "
355 Cft_Overlay, distproc_cfg, NULL, distproc_cfadd },
357 "NAME 'olcDistProcDatabase' "
358 "DESC 'Distributed procedure remote server configuration' "
360 Cft_Misc, distproc_cfg, distproc_ldadd },
365 distproc_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
372 AttributeDescription *ad = NULL;
378 if ( p->ce_type != Cft_Overlay
380 || p->ce_bi->bi_cf_ocs != distproc_ocs )
382 return LDAP_CONSTRAINT_VIOLATION;
385 on = (slap_overinst *)p->ce_bi;
386 lc = (ldap_distproc_t *)on->on_bi.bi_private;
388 assert( ca->be == NULL );
389 ca->be = (BackendDB *)ch_calloc( 1, sizeof( BackendDB ) );
391 ca->be->bd_info = (BackendInfo *)on;
393 rc = slap_str2ad( "olcDbURI", &ad, &text );
394 assert( rc == LDAP_SUCCESS );
396 at = attr_find( e->e_attrs, ad );
397 if ( lc->lc_common_li == NULL && at != NULL ) {
398 /* FIXME: we should generate an empty default entry
399 * if none is supplied */
400 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
401 "first underlying database \"%s\" "
402 "cannot contain attribute \"%s\".\n",
403 e->e_name.bv_val, ad->ad_cname.bv_val, 0 );
404 rc = LDAP_CONSTRAINT_VIOLATION;
407 } else if ( lc->lc_common_li != NULL && at == NULL ) {
408 /* FIXME: we should generate an empty default entry
409 * if none is supplied */
410 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
411 "subsequent underlying database \"%s\" "
412 "must contain attribute \"%s\".\n",
413 e->e_name.bv_val, ad->ad_cname.bv_val, 0 );
414 rc = LDAP_CONSTRAINT_VIOLATION;
418 if ( lc->lc_common_li == NULL ) {
419 rc = ldap_distproc_db_init_common( ca->be );
422 rc = ldap_distproc_db_init_one( ca->be );
426 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
427 "unable to init %sunderlying database \"%s\".\n",
428 lc->lc_common_li == NULL ? "common " : "", e->e_name.bv_val, 0 );
429 return LDAP_CONSTRAINT_VIOLATION;
432 li = ca->be->be_private;
434 if ( lc->lc_common_li == NULL ) {
435 lc->lc_common_li = li;
437 } else if ( avl_insert( &lc->lc_lai.lai_tree, (caddr_t)li,
438 ldap_distproc_uri_cmp, ldap_distproc_uri_dup ) )
440 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
441 "database \"%s\" insert failed.\n",
442 e->e_name.bv_val, 0, 0 );
443 rc = LDAP_CONSTRAINT_VIOLATION;
448 if ( rc != LDAP_SUCCESS ) {
449 (void)ldap_distproc_db_destroy_one( ca->be );
457 typedef struct ldap_distproc_cfadd_apply_t {
463 } ldap_distproc_cfadd_apply_t;
466 ldap_distproc_cfadd_apply( void *datum, void *arg )
468 ldapinfo_t *li = (ldapinfo_t *)datum;
469 ldap_distproc_cfadd_apply_t *lca = (ldap_distproc_cfadd_apply_t *)arg;
473 /* FIXME: should not hardcode "olcDatabase" here */
474 bv.bv_len = snprintf( lca->ca->msg, sizeof( lca->ca->msg ),
475 "olcDatabase={%d}%s", lca->count, lback->bi_type );
476 bv.bv_val = lca->ca->msg;
478 lca->ca->be->be_private = (void *)li;
479 config_build_entry( lca->op, lca->rs, lca->p->e_private, lca->ca,
480 &bv, lback->bi_cf_ocs, &distproc_ocs[ 1 ] );
488 distproc_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *ca )
490 CfEntryInfo *pe = p->e_private;
491 slap_overinst *on = (slap_overinst *)pe->ce_bi;
492 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
493 void *priv = (void *)ca->be->be_private;
495 if ( lback->bi_cf_ocs ) {
496 ldap_distproc_cfadd_apply_t lca = { 0 };
504 (void)ldap_distproc_cfadd_apply( (void *)lc->lc_common_li, (void *)&lca );
506 (void)avl_apply( lc->lc_lai.lai_tree, ldap_distproc_cfadd_apply,
507 &lca, 1, AVL_INORDER );
509 ca->be->be_private = priv;
516 distproc_cfgen( ConfigArgs *c )
518 slap_overinst *on = (slap_overinst *)c->bi;
519 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
523 if ( c->op == SLAP_CONFIG_EMIT ) {
526 c->value_int = LDAP_DISTPROC_CACHE_URI( lc );
535 } else if ( c->op == LDAP_MOD_DELETE ) {
541 lc->lc_flags &= ~LDAP_DISTPROC_F_CACHE_URI;
552 if ( c->value_int ) {
553 lc->lc_flags |= LDAP_DISTPROC_F_CACHE_URI;
555 lc->lc_flags &= ~LDAP_DISTPROC_F_CACHE_URI;
568 ldap_distproc_db_init(
571 slap_overinst *on = (slap_overinst *)be->bd_info;
572 ldap_distproc_t *lc = NULL;
574 if ( lback == NULL ) {
575 lback = backend_info( "ldap" );
577 if ( lback == NULL ) {
582 lc = ch_malloc( sizeof( ldap_distproc_t ) );
586 memset( lc, 0, sizeof( ldap_distproc_t ) );
587 ldap_pvt_thread_mutex_init( &lc->lc_lai.lai_mutex );
589 on->on_bi.bi_private = (void *)lc;
595 ldap_distproc_db_config(
602 slap_overinst *on = (slap_overinst *)be->bd_info;
603 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
605 int rc = SLAP_CONF_UNKNOWN;
607 if ( lc->lc_common_li == NULL ) {
608 void *be_private = be->be_private;
609 ldap_distproc_db_init_common( be );
610 lc->lc_common_li = lc->lc_cfg_li = (ldapinfo_t *)be->be_private;
611 be->be_private = be_private;
614 /* Something for the distproc database? */
615 if ( strncasecmp( argv[ 0 ], "distproc-", STRLENOF( "distproc-" ) ) == 0 ) {
616 char *save_argv0 = argv[ 0 ];
617 BackendInfo *bd_info = be->bd_info;
618 void *be_private = be->be_private;
619 ConfigOCs *be_cf_ocs = be->be_cf_ocs;
622 argv[ 0 ] += STRLENOF( "distproc-" );
624 if ( strcasecmp( argv[ 0 ], "uri" ) == 0 ) {
625 rc = ldap_distproc_db_init_one( be );
627 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
628 "underlying slapd-ldap initialization failed.\n.",
632 lc->lc_cfg_li = be->be_private;
636 /* TODO: add checks on what other slapd-ldap(5) args
637 * should be put in the template; this is not quite
638 * harmful, because attributes that shouldn't don't
639 * get actually used, but the user should at least
644 be->be_private = (void *)lc->lc_cfg_li;
645 be->be_cf_ocs = lback->bi_cf_ocs;
647 rc = config_generic_wrapper( be, fname, lineno, argc, argv );
649 argv[ 0 ] = save_argv0;
650 be->be_cf_ocs = be_cf_ocs;
651 be->be_private = be_private;
652 be->bd_info = bd_info;
660 db.be_private = (void *)lc->lc_cfg_li;
661 ldap_distproc_db_destroy_one( &db );
662 lc->lc_cfg_li = NULL;
665 if ( lc->lc_cfg_li->li_bvuri == NULL
666 || BER_BVISNULL( &lc->lc_cfg_li->li_bvuri[ 0 ] )
667 || !BER_BVISNULL( &lc->lc_cfg_li->li_bvuri[ 1 ] ) )
669 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
670 "no URI list allowed in slapo-distproc.\n",
673 goto private_destroy;
676 if ( avl_insert( &lc->lc_lai.lai_tree,
677 (caddr_t)lc->lc_cfg_li,
678 ldap_distproc_uri_cmp, ldap_distproc_uri_dup ) )
680 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
681 "duplicate URI in slapo-distproc.\n",
684 goto private_destroy;
701 typedef struct ldap_distproc_db_apply_t {
704 } ldap_distproc_db_apply_t;
707 ldap_distproc_db_apply( void *datum, void *arg )
709 ldapinfo_t *li = (ldapinfo_t *)datum;
710 ldap_distproc_db_apply_t *lca = (ldap_distproc_db_apply_t *)arg;
712 lca->be->be_private = (void *)li;
714 return lca->func( lca->be );
718 ldap_distproc_db_func(
723 slap_overinst *on = (slap_overinst *)be->bd_info;
724 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
729 BI_db_func *func = (&lback->bi_db_open)[ which ];
731 if ( func != NULL && lc->lc_common_li != NULL ) {
735 db.be_private = lc->lc_common_li;
743 if ( lc->lc_lai.lai_tree != NULL ) {
744 ldap_distproc_db_apply_t lca;
749 rc = avl_apply( lc->lc_lai.lai_tree,
750 ldap_distproc_db_apply, (void *)&lca,
751 1, AVL_INORDER ) != AVL_NOMORE;
760 ldap_distproc_db_open(
763 return ldap_distproc_db_func( be, db_open );
767 ldap_distproc_db_close(
770 return ldap_distproc_db_func( be, db_close );
774 ldap_distproc_db_destroy(
777 slap_overinst *on = (slap_overinst *) be->bd_info;
778 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
782 rc = ldap_distproc_db_func( be, db_destroy );
785 avl_free( lc->lc_lai.lai_tree, NULL );
786 ldap_pvt_thread_mutex_destroy( &lc->lc_lai.lai_mutex );
794 * inits one instance of the slapd-ldap backend, and stores
795 * the private info in be_private of the arg
798 ldap_distproc_db_init_common(
801 BackendInfo *bi = be->bd_info;
805 be->be_private = NULL;
806 t = lback->bi_db_init( be );
816 * inits one instance of the slapd-ldap backend, stores
817 * the private info in be_private of the arg and fills
818 * selected fields with data from the template.
820 * NOTE: add checks about the other fields of the template,
821 * which are ignored and SHOULD NOT be configured by the user.
824 ldap_distproc_db_init_one(
827 slap_overinst *on = (slap_overinst *)be->bd_info;
828 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
830 BackendInfo *bi = be->bd_info;
836 be->be_private = NULL;
837 t = lback->bi_db_init( be );
841 li = (ldapinfo_t *)be->be_private;
843 /* copy common data */
844 li->li_nretries = lc->lc_common_li->li_nretries;
845 li->li_flags = lc->lc_common_li->li_flags;
846 li->li_version = lc->lc_common_li->li_version;
847 for ( t = 0; t < LDAP_BACK_OP_LAST; t++ ) {
848 li->li_timeout[ t ] = lc->lc_common_li->li_timeout[ t ];
855 typedef struct ldap_distproc_conn_apply_t {
858 } ldap_distproc_conn_apply_t;
861 ldap_distproc_conn_apply( void *datum, void *arg )
863 ldapinfo_t *li = (ldapinfo_t *)datum;
864 ldap_distproc_conn_apply_t *lca = (ldap_distproc_conn_apply_t *)arg;
866 lca->be->be_private = (void *)li;
868 return lback->bi_connection_destroy( lca->be, lca->conn );
872 ldap_distproc_connection_destroy(
877 slap_overinst *on = (slap_overinst *) be->bd_info;
878 ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
879 void *private = be->be_private;
880 ldap_distproc_conn_apply_t lca;
883 be->be_private = NULL;
886 ldap_pvt_thread_mutex_lock( &lc->lc_lai.lai_mutex );
887 rc = avl_apply( lc->lc_lai.lai_tree, ldap_distproc_conn_apply,
888 (void *)&lca, 1, AVL_INORDER ) != AVL_NOMORE;
889 ldap_pvt_thread_mutex_unlock( &lc->lc_lai.lai_mutex );
890 be->be_private = private;
896 ldap_distproc_parse_returnContRef_ctrl(
901 if ( get_returnContRef( op ) != SLAP_CONTROL_NONE ) {
902 rs->sr_text = "returnContinuationReference control specified multiple times";
903 return LDAP_PROTOCOL_ERROR;
906 if ( op->o_pagedresults != SLAP_CONTROL_NONE ) {
907 rs->sr_text = "returnContinuationReference control specified with pagedResults control";
908 return LDAP_PROTOCOL_ERROR;
911 if ( !BER_BVISEMPTY( &ctrl->ldctl_value ) ) {
912 rs->sr_text = "returnContinuationReference control: value must be NULL";
913 return LDAP_PROTOCOL_ERROR;
916 op->o_returnContRef = ctrl->ldctl_iscritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
922 ldap_exop_chained_request(
926 Statslog( LDAP_DEBUG_STATS, "%s CHAINED REQUEST\n",
927 op->o_log_prefix, 0, 0, 0, 0 );
929 rs->sr_err = backend_check_restrictions( op, rs,
930 (struct berval *)&slap_EXOP_CHAINEDREQUEST );
931 if ( rs->sr_err != LDAP_SUCCESS ) {
935 /* by now, just reject requests */
936 rs->sr_text = "under development";
937 return LDAP_UNWILLING_TO_PERFORM;
941 static slap_overinst distproc;
944 distproc_initialize( void )
948 /* Make sure we don't exceed the bits reserved for userland */
949 config_check_userland( DP_LAST );
951 rc = load_extop( (struct berval *)&slap_EXOP_CHAINEDREQUEST,
952 SLAP_EXOP_HIDE, ldap_exop_chained_request );
953 if ( rc != LDAP_SUCCESS ) {
954 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
955 "unable to register chainedRequest exop: %d.\n",
960 rc = supported_feature_load( &slap_FEATURE_CANCHAINOPS );
961 if ( rc != LDAP_SUCCESS ) {
962 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
963 "unable to register canChainOperations supported feature: %d.\n",
968 rc = register_supported_control( LDAP_CONTROL_X_RETURNCONTREF,
969 SLAP_CTRL_GLOBAL|SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE, NULL,
970 ldap_distproc_parse_returnContRef_ctrl, &sc_returnContRef );
971 if ( rc != LDAP_SUCCESS ) {
972 Debug( LDAP_DEBUG_ANY, "slapd-distproc: "
973 "unable to register returnContinuationReference control: %d.\n",
978 distproc.on_bi.bi_type = "distproc";
979 distproc.on_bi.bi_db_init = ldap_distproc_db_init;
980 distproc.on_bi.bi_db_config = ldap_distproc_db_config;
981 distproc.on_bi.bi_db_open = ldap_distproc_db_open;
982 distproc.on_bi.bi_db_close = ldap_distproc_db_close;
983 distproc.on_bi.bi_db_destroy = ldap_distproc_db_destroy;
985 /* ... otherwise the underlying backend's function would be called,
986 * likely passing an invalid entry; on the contrary, the requested
987 * operational attributes should have been returned while chasing
988 * the referrals. This all in all is a bit messy, because part
989 * of the operational attributes are generated by the backend;
990 * part by the frontend; back-ldap should receive all the available
991 * ones from the remote server, but then, on its own, it strips those
992 * it assumes will be (re)generated by the frontend (e.g.
993 * subschemaSubentry, entryDN, ...) */
994 distproc.on_bi.bi_operational = ldap_distproc_operational;
996 distproc.on_bi.bi_connection_destroy = ldap_distproc_connection_destroy;
998 distproc.on_response = ldap_distproc_response;
1000 distproc.on_bi.bi_cf_ocs = distproc_ocs;
1002 rc = config_register_schema( distproc_cfg, distproc_ocs );
1007 return overlay_register( &distproc );
1010 #endif /* LDAP_DEVEL */