1 /* translucent.c - translucent proxy module */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2004-2007 The OpenLDAP Foundation.
6 * Portions Copyright 2005 Symas Corporation.
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 Symas Corp. for inclusion in
19 * OpenLDAP Software. This work was sponsored by Hewlett-Packard.
24 #ifdef SLAPD_OVER_TRANSLUCENT
28 #include <ac/string.h>
29 #include <ac/socket.h>
37 typedef struct translucent_info {
38 BackendDB db; /* captive backend */
44 static ConfigLDAPadd translucent_ldadd;
45 static ConfigCfAdd translucent_cfadd;
47 static ConfigTable translucentcfg[] = {
48 { "translucent_strict", "on|off", 1, 2, 0,
49 ARG_ON_OFF|ARG_OFFSET,
50 (void *)offsetof(translucent_info, strict),
51 "( OLcfgOvAt:14.1 NAME 'olcTranslucentStrict' "
52 "DESC 'Reveal attribute deletion constraint violations' "
53 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
54 { "translucent_no_glue", "on|off", 1, 2, 0,
55 ARG_ON_OFF|ARG_OFFSET,
56 (void *)offsetof(translucent_info, no_glue),
57 "( OLcfgOvAt:14.2 NAME 'olcTranslucentNoGlue' "
58 "DESC 'Disable automatic glue records for ADD and MODRDN' "
59 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
60 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
63 static ConfigTable transdummy[] = {
64 { "", "", 0, 0, 0, ARG_IGNORED,
65 NULL, "( OLcfgGlAt:13 NAME 'olcDatabase' "
66 "DESC 'The backend type for a database instance' "
67 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
68 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
71 static ConfigOCs translucentocs[] = {
73 "NAME 'olcTranslucentConfig' "
74 "DESC 'Translucent configuration' "
75 "SUP olcOverlayConfig "
76 "MAY ( olcTranslucentStrict $ olcTranslucentNoGlue ) )",
77 Cft_Overlay, translucentcfg, NULL, translucent_cfadd },
79 "NAME 'olcTranslucentDatabase' "
80 "DESC 'Translucent target database configuration' "
81 "AUXILIARY )", Cft_Misc, transdummy, translucent_ldadd },
84 /* for translucent_init() */
87 translucent_ldadd_cleanup( ConfigArgs *ca )
89 slap_overinst *on = ca->private;
90 translucent_info *ov = on->on_bi.bi_private;
92 ov->defer_db_open = 0;
93 return backend_startup_one( ca->be, &ca->reply );
97 translucent_ldadd( CfEntryInfo *cei, Entry *e, ConfigArgs *ca )
100 translucent_info *ov;
102 Debug(LDAP_DEBUG_TRACE, "==> translucent_ldadd\n", 0, 0, 0);
104 if ( cei->ce_type != Cft_Overlay || !cei->ce_bi ||
105 cei->ce_bi->bi_cf_ocs != translucentocs )
106 return LDAP_CONSTRAINT_VIOLATION;
108 on = (slap_overinst *)cei->ce_bi;
109 ov = on->on_bi.bi_private;
112 if ( CONFIG_ONLINE_ADD( ca ))
113 ca->cleanup = translucent_ldadd_cleanup;
115 ov->defer_db_open = 0;
121 translucent_cfadd( Operation *op, SlapReply *rs, Entry *e, ConfigArgs *ca )
123 CfEntryInfo *cei = e->e_private;
124 slap_overinst *on = (slap_overinst *)cei->ce_bi;
125 translucent_info *ov = on->on_bi.bi_private;
128 Debug(LDAP_DEBUG_TRACE, "==> translucent_cfadd\n", 0, 0, 0);
130 /* FIXME: should not hardcode "olcDatabase" here */
131 bv.bv_len = snprintf( ca->cr_msg, sizeof( ca->cr_msg ),
132 "olcDatabase=%s", ov->db.bd_info->bi_type );
133 if ( bv.bv_len < 0 || bv.bv_len >= sizeof( ca->cr_msg ) ) {
136 bv.bv_val = ca->cr_msg;
138 ov->defer_db_open = 0;
140 /* We can only create this entry if the database is table-driven
142 if ( ov->db.bd_info->bi_cf_ocs )
143 config_build_entry( op, rs, cei, ca, &bv,
144 ov->db.bd_info->bi_cf_ocs,
145 &translucentocs[1] );
150 static slap_overinst translucent;
154 ** call syncrepl_add_glue() with the parent suffix;
158 static struct berval glue[] = { BER_BVC("top"), BER_BVC("glue"), BER_BVNULL };
160 void glue_parent(Operation *op) {
162 slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
163 struct berval ndn = BER_BVNULL;
168 dnParent( &op->o_req_ndn, &pdn );
169 ber_dupbv_x( &ndn, &pdn, op->o_tmpmemctx );
171 Debug(LDAP_DEBUG_TRACE, "=> glue_parent: fabricating glue for <%s>\n", ndn.bv_val, 0, 0);
175 ber_dupbv(&e->e_name, &ndn);
176 ber_dupbv(&e->e_nname, &ndn);
178 a = attr_alloc( slap_schema.si_ad_objectClass );
180 a->a_vals = ch_malloc(sizeof(struct berval) * 3);
181 ber_dupbv(&a->a_vals[0], &glue[0]);
182 ber_dupbv(&a->a_vals[1], &glue[1]);
183 ber_dupbv(&a->a_vals[2], &glue[2]);
184 a->a_nvals = a->a_vals;
185 a->a_next = e->e_attrs;
188 a = attr_alloc( slap_schema.si_ad_structuralObjectClass );
190 a->a_vals = ch_malloc(sizeof(struct berval) * 2);
191 ber_dupbv(&a->a_vals[0], &glue[1]);
192 ber_dupbv(&a->a_vals[1], &glue[2]);
193 a->a_nvals = a->a_vals;
194 a->a_next = e->e_attrs;
201 nop.o_bd->bd_info = (BackendInfo *) on->on_info->oi_orig;
202 syncrepl_add_glue(&nop, e);
203 nop.o_bd->bd_info = (BackendInfo *) on;
205 op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx );
215 BerVarray dup_bervarray(BerVarray b) {
218 for(len = 0; b[len].bv_val; len++);
219 nb = ch_malloc((len+1) * sizeof(BerValue));
220 for(i = 0; i < len; i++) ber_dupbv(&nb[i], &b[i]);
221 nb[len].bv_val = NULL;
228 ** free only the Attribute*, not the contents;
231 void free_attr_chain(Attribute *b) {
233 for(a=b; a; a=a->a_next) {
243 ** if not bound as root, send ACCESS error;
244 ** if glue, glue_parent();
249 static int translucent_add(Operation *op, SlapReply *rs) {
250 slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
251 translucent_info *ov = on->on_bi.bi_private;
252 Debug(LDAP_DEBUG_TRACE, "==> translucent_add: %s\n",
253 op->o_req_dn.bv_val, 0, 0);
255 op->o_bd->bd_info = (BackendInfo *) on->on_info;
256 send_ldap_error(op, rs, LDAP_INSUFFICIENT_ACCESS,
257 "user modification of overlay database not permitted");
258 op->o_bd->bd_info = (BackendInfo *) on;
261 if(!ov->no_glue) glue_parent(op);
262 return(SLAP_CB_CONTINUE);
266 ** translucent_modrdn()
267 ** if not bound as root, send ACCESS error;
268 ** if !glue, glue_parent();
269 ** else return CONTINUE;
273 static int translucent_modrdn(Operation *op, SlapReply *rs) {
274 slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
275 translucent_info *ov = on->on_bi.bi_private;
276 Debug(LDAP_DEBUG_TRACE, "==> translucent_modrdn: %s -> %s\n",
277 op->o_req_dn.bv_val, op->orr_newrdn.bv_val, 0);
279 op->o_bd->bd_info = (BackendInfo *) on->on_info;
280 send_ldap_error(op, rs, LDAP_INSUFFICIENT_ACCESS,
281 "user modification of overlay database not permitted");
282 op->o_bd->bd_info = (BackendInfo *) on;
285 if(!ov->no_glue) glue_parent(op);
286 return(SLAP_CB_CONTINUE);
290 ** translucent_delete()
291 ** if not bound as root, send ACCESS error;
292 ** else return CONTINUE;
296 static int translucent_delete(Operation *op, SlapReply *rs) {
297 slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
298 Debug(LDAP_DEBUG_TRACE, "==> translucent_delete: %s\n",
299 op->o_req_dn.bv_val, 0, 0);
301 op->o_bd->bd_info = (BackendInfo *) on->on_info;
302 send_ldap_error(op, rs, LDAP_INSUFFICIENT_ACCESS,
303 "user modification of overlay database not permitted");
304 op->o_bd->bd_info = (BackendInfo *) on;
307 return(SLAP_CB_CONTINUE);
311 translucent_tag_cb( Operation *op, SlapReply *rs )
313 op->o_tag = LDAP_REQ_MODIFY;
314 op->orm_modlist = op->o_callback->sc_private;
315 rs->sr_tag = slap_req2res( op->o_tag );
317 return SLAP_CB_CONTINUE;
321 ** translucent_modify()
322 ** modify in local backend if exists in both;
323 ** otherwise, add to local backend;
324 ** fail if not defined in captive backend;
328 static int translucent_modify(Operation *op, SlapReply *rs) {
329 SlapReply nrs = { REP_RESULT };
332 slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
333 translucent_info *ov = on->on_bi.bi_private;
334 Entry *e = NULL, *re = NULL;
336 Modifications *m, **mm;
337 int del, rc, erc = 0;
338 slap_callback cb = { 0 };
340 Debug(LDAP_DEBUG_TRACE, "==> translucent_modify: %s\n",
341 op->o_req_dn.bv_val, 0, 0);
343 if(ov->defer_db_open) {
344 send_ldap_error(op, rs, LDAP_UNAVAILABLE,
345 "remote DB not available");
349 ** fetch entry from the captive backend;
350 ** if it did not exist, fail;
351 ** release it, if captive backend supports this;
356 rc = ov->db.bd_info->bi_entry_get_rw(&nop, &nop.o_req_ndn, NULL, NULL, 0, &re);
357 if(rc != LDAP_SUCCESS || re == NULL ) {
358 send_ldap_error((&nop), rs, LDAP_NO_SUCH_OBJECT,
359 "attempt to modify nonexistent local record");
364 ** fetch entry from local backend;
366 ** foreach Modification:
367 ** if attr not present in local:
368 ** if Mod == LDAP_MOD_DELETE:
369 ** if remote attr not present, return NO_SUCH;
370 ** if remote attr present, drop this Mod;
371 ** else force this Mod to LDAP_MOD_ADD;
376 op->o_bd->bd_info = (BackendInfo *) on->on_info;
377 rc = be_entry_get_rw(op, &op->o_req_ndn, NULL, NULL, 0, &e);
378 op->o_bd->bd_info = (BackendInfo *) on;
380 if(e && rc == LDAP_SUCCESS) {
381 Debug(LDAP_DEBUG_TRACE, "=> translucent_modify: found local entry\n", 0, 0, 0);
382 for(mm = &op->orm_modlist; *mm; ) {
384 for(a = e->e_attrs; a; a = a->a_next)
385 if(a->a_desc == m->sml_desc) break;
388 continue; /* found local attr */
390 if(m->sml_op == LDAP_MOD_DELETE) {
391 for(a = re->e_attrs; a; a = a->a_next)
392 if(a->a_desc == m->sml_desc) break;
393 /* not found remote attr */
395 erc = LDAP_NO_SUCH_ATTRIBUTE;
399 erc = LDAP_CONSTRAINT_VIOLATION;
402 Debug(LDAP_DEBUG_TRACE,
403 "=> translucent_modify: silently dropping delete: %s\n",
404 m->sml_desc->ad_cname.bv_val, 0, 0);
407 slap_mods_free(m, 1);
410 m->sml_op = LDAP_MOD_ADD;
413 erc = SLAP_CB_CONTINUE;
416 if(ov->db.bd_info->bi_entry_release_rw)
417 ov->db.bd_info->bi_entry_release_rw(&nop, re, 0);
421 op->o_bd->bd_info = (BackendInfo *) on->on_info;
422 be_entry_release_r(op, e);
423 op->o_bd->bd_info = (BackendInfo *) on;
424 if(erc == SLAP_CB_CONTINUE) {
427 send_ldap_error(op, rs, erc,
428 "attempt to delete nonexistent attribute");
433 /* don't leak remote entry copy */
435 if(ov->db.bd_info->bi_entry_release_rw)
436 ov->db.bd_info->bi_entry_release_rw(&nop, re, 0);
441 ** foreach Modification:
442 ** if MOD_ADD or MOD_REPLACE, add Attribute;
443 ** if no Modifications were suitable:
444 ** if strict, throw CONSTRAINT_VIOLATION;
445 ** else, return early SUCCESS;
446 ** fabricate Entry with new Attribute chain;
447 ** glue_parent() for this Entry;
448 ** call bi_op_add() in local backend;
452 Debug(LDAP_DEBUG_TRACE, "=> translucent_modify: fabricating local add\n", 0, 0, 0);
454 for(del = 0, ax = NULL, m = op->orm_modlist; m; m = m->sml_next) {
456 if(((m->sml_op & LDAP_MOD_OP) != LDAP_MOD_ADD) &&
457 ((m->sml_op & LDAP_MOD_OP) != LDAP_MOD_REPLACE)) {
458 Debug(LDAP_DEBUG_ANY,
459 "=> translucent_modify: silently dropped modification(%d): %s\n",
460 m->sml_op, m->sml_desc->ad_cname.bv_val, 0);
461 if((m->sml_op & LDAP_MOD_OP) == LDAP_MOD_DELETE) del++;
464 atmp.a_desc = m->sml_desc;
465 atmp.a_vals = m->sml_values;
466 atmp.a_nvals = m->sml_nvalues ? m->sml_nvalues : atmp.a_vals;
467 atmp.a_numvals = m->sml_numvals;
469 a = attr_dup( &atmp );
474 if(del && ov->strict) {
476 send_ldap_error(op, rs, LDAP_CONSTRAINT_VIOLATION,
477 "attempt to delete attributes from local database");
483 send_ldap_error(op, rs, LDAP_CONSTRAINT_VIOLATION,
484 "modification contained other than ADD or REPLACE");
487 /* rs->sr_text = "no valid modification found"; */
488 rs->sr_err = LDAP_SUCCESS;
489 send_ldap_result(op, rs);
494 ber_dupbv( &e->e_name, &op->o_req_dn );
495 ber_dupbv( &e->e_nname, &op->o_req_ndn );
498 nop.o_tag = LDAP_REQ_ADD;
503 cb.sc_response = translucent_tag_cb;
504 cb.sc_private = op->orm_modlist;
505 cb.sc_next = nop.o_callback;
506 nop.o_callback = &cb;
507 rc = on->on_info->oi_orig->bi_op_add(&nop, &nrs);
508 if ( nop.ora_e == e )
514 static int translucent_compare(Operation *op, SlapReply *rs) {
516 slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
517 translucent_info *ov = on->on_bi.bi_private;
518 AttributeAssertion *ava = op->orc_ava;
522 Debug(LDAP_DEBUG_TRACE, "==> translucent_compare: <%s> %s:%s\n",
523 op->o_req_dn.bv_val, ava->aa_desc->ad_cname.bv_val, ava->aa_value.bv_val);
526 ** if the local backend has an entry for this attribute:
527 ** CONTINUE and let it do the compare;
530 op->o_bd->bd_info = (BackendInfo *) on->on_info;
531 rc = be_entry_get_rw(op, &op->o_req_ndn, NULL, ava->aa_desc, 0, &e);
532 if(e && rc == LDAP_SUCCESS) {
533 be_entry_release_r(op, e);
534 op->o_bd->bd_info = (BackendInfo *) on;
535 return(SLAP_CB_CONTINUE);
537 op->o_bd->bd_info = (BackendInfo *) on;
539 if(ov->defer_db_open) {
540 send_ldap_error(op, rs, LDAP_UNAVAILABLE,
541 "remote DB not available");
545 ** call compare() in the captive backend;
546 ** return the result;
550 nop.o_callback = NULL;
551 rc = ov->db.bd_info->bi_op_compare(&nop, rs);
557 ** translucent_search_cb()
558 ** merge local data with the search result
562 static int translucent_search_cb(Operation *op, SlapReply *rs) {
564 Entry *e, *re = NULL;
565 Attribute *a, *ax, *an, *as = NULL;
566 Operation * original_op, local_op;
569 if(!op || !rs || rs->sr_type != REP_SEARCH || !rs->sr_entry)
570 return(SLAP_CB_CONTINUE);
572 Debug(LDAP_DEBUG_TRACE, "==> translucent_search_cb: %s\n",
573 rs->sr_entry->e_name.bv_val, 0, 0);
575 original_op = op->o_callback->sc_private;
576 on = (slap_overinst *) original_op->o_bd->bd_info;
577 local_op = *original_op;
579 local_op.o_bd->bd_info = (BackendInfo *) on->on_info->oi_orig;
580 rc = be_entry_get_rw(&local_op, &rs->sr_entry->e_nname, NULL, NULL, 0, &e);
581 local_op.o_bd->bd_info = (BackendInfo *) on;
584 ** if we got an entry from local backend:
585 ** make a copy of this search result;
586 ** foreach local attr:
587 ** foreach search result attr:
588 ** if match, result attr with local attr;
589 ** if new local, add to list;
590 ** append new local attrs to search result;
594 if(e && rc == LDAP_SUCCESS) {
595 re = entry_dup(rs->sr_entry);
596 for(ax = e->e_attrs; ax; ax = ax->a_next) {
598 if(is_at_operational(ax->a_desc->ad_type)) continue;
600 for(a = re->e_attrs; a; a = a->a_next) {
601 if(a->a_desc == ax->a_desc) {
602 if(a->a_vals != a->a_nvals)
603 ber_bvarray_free(a->a_nvals);
604 ber_bvarray_free(a->a_vals);
605 a->a_vals = dup_bervarray(ax->a_vals);
606 a->a_nvals = (ax->a_vals == ax->a_nvals) ?
607 a->a_vals : dup_bervarray(ax->a_nvals);
616 local_op.o_bd->bd_info = (BackendInfo *) on->on_info->oi_orig;
617 be_entry_release_r(&local_op, e);
618 local_op.o_bd->bd_info = (BackendInfo *) on;
620 /* literally append, so locals are always last */
623 for(ax = re->e_attrs; ax->a_next; ax = ax->a_next);
630 rs->sr_flags |= REP_ENTRY_MUSTBEFREED;
633 return(SLAP_CB_CONTINUE);
637 ** translucent_search()
638 ** search via captive backend;
639 ** override results with any local data;
643 static int translucent_search(Operation *op, SlapReply *rs) {
644 slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
646 translucent_info *ov = on->on_bi.bi_private;
647 slap_callback cb = { NULL, NULL, NULL, NULL };
649 Debug(LDAP_DEBUG_TRACE, "==> translucent_search: <%s> %s\n",
650 op->o_req_dn.bv_val, op->ors_filterstr.bv_val, 0);
652 if(ov->defer_db_open) {
653 send_ldap_error(op, rs, LDAP_UNAVAILABLE,
654 "remote DB not available");
657 cb.sc_response = (slap_response *) translucent_search_cb;
659 cb.sc_next = nop.o_callback;
661 nop.o_callback = &cb;
663 return (ov->db.bd_info->bi_op_search(&nop, rs));
668 ** translucent_bind()
669 ** pass bind request to captive backend;
673 static int translucent_bind(Operation *op, SlapReply *rs) {
674 slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
676 translucent_info *ov = on->on_bi.bi_private;
678 Debug(LDAP_DEBUG_TRACE, "translucent_bind: <%s> method %d\n",
679 op->o_req_dn.bv_val, op->orb_method, 0);
681 if(ov->defer_db_open) {
682 send_ldap_error(op, rs, LDAP_UNAVAILABLE,
683 "remote DB not available");
687 return (ov->db.bd_info->bi_op_bind(&nop, rs));
691 ** translucent_connection_destroy()
692 ** pass disconnect notification to captive backend;
696 static int translucent_connection_destroy(BackendDB *be, Connection *conn) {
697 slap_overinst *on = (slap_overinst *) be->bd_info;
698 translucent_info *ov = on->on_bi.bi_private;
701 Debug(LDAP_DEBUG_TRACE, "translucent_connection_destroy\n", 0, 0, 0);
703 rc = ov->db.bd_info->bi_connection_destroy(&ov->db, conn);
709 ** translucent_db_config()
710 ** pass config directives to captive backend;
711 ** parse unrecognized directives ourselves;
715 static int translucent_db_config(
723 slap_overinst *on = (slap_overinst *) be->bd_info;
724 translucent_info *ov = on->on_bi.bi_private;
726 Debug(LDAP_DEBUG_TRACE, "==> translucent_db_config: %s\n",
727 argc ? argv[0] : "", 0, 0);
729 /* Something for the captive database? */
730 if ( ov->db.bd_info && ov->db.bd_info->bi_db_config )
731 return ov->db.bd_info->bi_db_config( &ov->db, fname, lineno,
733 return SLAP_CONF_UNKNOWN;
737 ** translucent_db_init()
738 ** initialize the captive backend;
742 static int translucent_db_init(BackendDB *be, ConfigReply *cr) {
743 slap_overinst *on = (slap_overinst *) be->bd_info;
744 translucent_info *ov;
746 Debug(LDAP_DEBUG_TRACE, "==> translucent_db_init\n", 0, 0, 0);
748 ov = ch_calloc(1, sizeof(translucent_info));
749 on->on_bi.bi_private = ov;
751 ov->db.be_private = NULL;
752 ov->db.be_pcl_mutexp = &ov->db.be_pcl_mutex;
753 ov->defer_db_open = 1;
755 if ( !backend_db_init( "ldap", &ov->db, -1, NULL )) {
756 Debug( LDAP_DEBUG_CONFIG, "translucent: unable to open captive back-ldap\n", 0, 0, 0);
759 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
760 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NOLASTMOD;
766 ** translucent_db_open()
767 ** if the captive backend has an open() method, call it;
771 static int translucent_db_open(BackendDB *be, ConfigReply *cr) {
772 slap_overinst *on = (slap_overinst *) be->bd_info;
773 translucent_info *ov = on->on_bi.bi_private;
776 Debug(LDAP_DEBUG_TRACE, "==> translucent_db_open\n", 0, 0, 0);
778 /* need to inherit something from the original database... */
779 ov->db.be_def_limit = be->be_def_limit;
780 ov->db.be_limits = be->be_limits;
781 ov->db.be_acl = be->be_acl;
782 ov->db.be_dfltaccess = be->be_dfltaccess;
784 if ( ov->defer_db_open )
787 rc = backend_startup_one( &ov->db, NULL );
789 if(rc) Debug(LDAP_DEBUG_TRACE,
790 "translucent: bi_db_open() returned error %d\n", rc, 0, 0);
796 ** translucent_db_close()
797 ** if the captive backend has a close() method, call it;
798 ** free any config data;
803 translucent_db_close( BackendDB *be, ConfigReply *cr )
805 slap_overinst *on = (slap_overinst *) be->bd_info;
806 translucent_info *ov = on->on_bi.bi_private;
809 Debug(LDAP_DEBUG_TRACE, "==> translucent_db_close\n", 0, 0, 0);
811 if ( ov && ov->db.bd_info && ov->db.bd_info->bi_db_close ) {
812 rc = ov->db.bd_info->bi_db_close(&ov->db, NULL);
819 ** translucent_db_destroy()
820 ** if the captive backend has a db_destroy() method, call it
825 translucent_db_destroy( BackendDB *be, ConfigReply *cr )
827 slap_overinst *on = (slap_overinst *) be->bd_info;
828 translucent_info *ov = on->on_bi.bi_private;
831 Debug(LDAP_DEBUG_TRACE, "==> translucent_db_destroy\n", 0, 0, 0);
834 if ( ov->db.be_private != NULL ) {
835 backend_stopdown_one( &ov->db );
839 on->on_bi.bi_private = NULL;
846 ** translucent_initialize()
847 ** initialize the slap_overinst with our entry points;
851 int translucent_initialize() {
855 Debug(LDAP_DEBUG_TRACE, "==> translucent_initialize\n", 0, 0, 0);
857 translucent.on_bi.bi_type = "translucent";
858 translucent.on_bi.bi_db_init = translucent_db_init;
859 translucent.on_bi.bi_db_config = translucent_db_config;
860 translucent.on_bi.bi_db_open = translucent_db_open;
861 translucent.on_bi.bi_db_close = translucent_db_close;
862 translucent.on_bi.bi_db_destroy = translucent_db_destroy;
863 translucent.on_bi.bi_op_bind = translucent_bind;
864 translucent.on_bi.bi_op_add = translucent_add;
865 translucent.on_bi.bi_op_modify = translucent_modify;
866 translucent.on_bi.bi_op_modrdn = translucent_modrdn;
867 translucent.on_bi.bi_op_delete = translucent_delete;
868 translucent.on_bi.bi_op_search = translucent_search;
869 translucent.on_bi.bi_op_compare = translucent_compare;
870 translucent.on_bi.bi_connection_destroy = translucent_connection_destroy;
872 translucent.on_bi.bi_cf_ocs = translucentocs;
873 rc = config_register_schema ( translucentcfg, translucentocs );
876 return(overlay_register(&translucent));
879 #if SLAPD_OVER_TRANSLUCENT == SLAPD_MOD_DYNAMIC && defined(PIC)
880 int init_module(int argc, char *argv[]) {
881 return translucent_initialize();
885 #endif /* SLAPD_OVER_TRANSLUCENT */