return rc;
}
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+static int
+ldap_chain_db_open(
+ BackendDB *be
+)
+{
+ return overlay_register_control( be, LDAP_CONTROL_X_CHAINING_BEHAVIOR );
+}
+#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
+
static int
ldap_chain_db_destroy(
BackendDB *be
int rc;
rc = register_supported_control( LDAP_CONTROL_X_CHAINING_BEHAVIOR,
- SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE, NULL,
+ SLAP_CTRL_FRONTEND|SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE, NULL,
ldap_chain_parse_ctrl, &sc_chainingBehavior );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "Failed to register chaining behavior control: %d\n", rc );
ldapchain.on_bi.bi_type = "chain";
ldapchain.on_bi.bi_db_init = ldap_chain_db_init;
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+ ldapchain.on_bi.bi_db_open = ldap_chain_db_open;
+#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
ldapchain.on_bi.bi_db_config = ldap_chain_db_config;
ldapchain.on_bi.bi_db_destroy = ldap_chain_db_destroy;
free( bd->be_rootpw.bv_val );
}
acl_destroy( bd->be_acl, frontendDB->be_acl );
+ if ( bd->be_controls ) {
+ ldap_charray_free( bd->be_controls );
+ }
}
free( backendDB );
be = &backends[nbackends++];
be->bd_info = bi;
+
+ if ( bi->bi_controls ) {
+ be->be_controls = ldap_charray_dup( bi->bi_controls );
+ }
+
be->be_def_limit = frontendDB->be_def_limit;
be->be_dfltaccess = frontendDB->be_dfltaccess;
return 0;
}
+#if 0
+int
+overlay_is_global( BackendDB *be )
+{
+ BackendInfo *frontendBI;
+
+ if ( !overlay_is_over( be ) ) {
+ return 0;
+ }
+
+ frontendBI = frontendDB->bd_info;
+ if ( overlay_is_over( frontendDB ) ) {
+ frontendBI = ((slap_overinfo *)frontendBI->bi_private)->oi_orig;
+ }
+
+ return ((slap_overinfo *)be->bd_info->bi_private)->oi_orig == frontendBI;
+}
+#endif
+
+int
+overlay_register_control( BackendDB *be, const char *oid )
+{
+ int rc = 0;
+ int gotit = 0;
+
+#if 0
+ if ( overlay_is_global( be ) ) {
+ int i;
+
+ /* add to all backends... */
+ for ( i = 0; i < nBackendDB; i++ ) {
+ BackendDB *bd = &backendDB[i];
+
+ if ( be == bd ) {
+ gotit = 1;
+ }
+
+ if ( bd->be_controls == NULL ||
+ !ldap_charray_inlist( bd->be_controls, oid ) )
+ {
+ rc = ldap_charray_add( &be->be_controls, oid );
+ if ( rc ) {
+ break;
+ }
+ }
+ }
+
+ }
+#endif
+
+ if ( rc == 0 && !gotit && !ldap_charray_inlist( be->be_controls, oid ) ) {
+ rc = ldap_charray_add( &be->be_controls, oid );
+ if ( rc ) {
+ return rc;
+ }
+ }
+
+ return rc;
+}
+
/* add an overlay to a particular backend. */
int
overlay_config( BackendDB *be, const char *ov )
#include "slapi/slapi.h"
#endif
-BackendInfo slap_frontendInfo;
-BackendDB slap_frontendDB;
+static BackendInfo slap_frontendInfo;
+static BackendDB slap_frontendDB;
BackendDB *frontendDB;
int
/* known controls */
frontendDB->bd_info->bi_controls = slap_known_controls;
+ frontendDB->be_controls = ldap_charray_dup( slap_known_controls );
/* calls */
frontendDB->bd_info->bi_op_abandon = fe_op_abandon;
return 0;
}
+static int
+ppolicy_db_open(
+ BackendDB *be
+)
+{
+ return overlay_register_control( be, LDAP_CONTROL_PASSWORDPOLICYREQUEST );
+}
+
static int
ppolicy_close(
BackendDB *be
ppolicy.on_bi.bi_type = "ppolicy";
ppolicy.on_bi.bi_db_init = ppolicy_db_init;
+ ppolicy.on_bi.bi_db_open = ppolicy_db_open;
ppolicy.on_bi.bi_db_config = ppolicy_config;
ppolicy.on_bi.bi_db_close = ppolicy_close;
Attribute *a;
int rc;
+ rc = overlay_register_control( be, LDAP_CONTROL_SYNC );
+ if ( rc ) {
+ return rc;
+ }
+
connection_fake_init( &conn, op, thrctx );
op->o_bd = be;
op->o_dn = be->be_rootdn;
LDAP_SLAPD_F (slap_overinst *) overlay_find LDAP_P(( const char *name ));
LDAP_SLAPD_F (int) overlay_is_over LDAP_P(( BackendDB *be ));
LDAP_SLAPD_F (int) overlay_is_inst LDAP_P(( BackendDB *be, const char *name ));
+LDAP_SLAPD_F (int) overlay_register_control LDAP_P((
+ BackendDB *be,
+ const char *oid ));
/*
* ch_malloc.c
*/
#define be_has_subordinates bd_info->bi_has_subordinates
-#define be_controls bd_info->bi_controls
+ /* supported controls */
+ /* NOTE: this stores a duplicate of the control OIDs as listed
+ * in bd_info->bi_controls at database startup; later on,
+ * controls may be added run-time, e.g. by overlays */
+ char **be_controls;
#define be_connection_init bd_info->bi_connection_init
#define be_connection_destroy bd_info->bi_connection_destroy