1 /* null.c - the null backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2002-2006 The OpenLDAP Foundation.
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 originally developed by Hallvard Furuseth for inclusion
18 * in OpenLDAP Software.
24 #include <ac/string.h>
37 null_back_bind( Operation *op, SlapReply *rs )
39 struct null_info *ni = (struct null_info *) op->o_bd->be_private;
41 if ( ni->ni_bind_allowed || be_isroot_pw( op ) ) {
42 /* front end will send result on success (0) */
46 rs->sr_err = LDAP_INVALID_CREDENTIALS;
47 send_ldap_result( op, rs );
52 /* add, delete, modify, modrdn, search */
54 null_back_success( Operation *op, SlapReply *rs )
56 rs->sr_err = LDAP_SUCCESS;
57 send_ldap_result( op, rs );
63 null_back_false( Operation *op, SlapReply *rs )
65 rs->sr_err = LDAP_COMPARE_FALSE;
66 send_ldap_result( op, rs );
74 null_tool_entry_open( BackendDB *be, int mode )
80 null_tool_entry_close( BackendDB *be )
87 null_tool_entry_next( BackendDB *be )
93 null_tool_entry_get( BackendDB *be, ID id )
95 assert( slapMode & SLAP_TOOL_MODE );
100 null_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
102 assert( slapMode & SLAP_TOOL_MODE );
103 assert( text != NULL );
104 assert( text->bv_val != NULL );
105 assert( text->bv_val[0] == '\0' ); /* overconservative? */
107 e->e_id = ((struct null_info *) be->be_private)->ni_nextid++;
122 struct null_info *ni = (struct null_info *) be->be_private;
125 fprintf( stderr, "%s: line %d: null database info is null!\n",
130 /* bind requests allowed */
131 if ( strcasecmp( argv[0], "bind" ) == 0 ) {
134 "%s: line %d: missing <on/off> in \"bind <on/off>\" line\n",
138 ni->ni_bind_allowed = strcasecmp( argv[1], "off" );
142 return SLAP_CONF_UNKNOWN;
149 null_back_db_init( BackendDB *be )
151 struct null_info *ni = ch_calloc( 1, sizeof(struct null_info) );
152 ni->ni_bind_allowed = 0;
159 null_back_db_destroy( Backend *be )
161 free( be->be_private );
167 null_back_initialize( BackendInfo *bi )
174 bi->bi_db_init = null_back_db_init;
175 bi->bi_db_config = null_back_db_config;
178 bi->bi_db_destroy = null_back_db_destroy;
180 bi->bi_op_bind = null_back_bind;
181 bi->bi_op_unbind = 0;
182 bi->bi_op_search = null_back_success;
183 bi->bi_op_compare = null_back_false;
184 bi->bi_op_modify = null_back_success;
185 bi->bi_op_modrdn = null_back_success;
186 bi->bi_op_add = null_back_success;
187 bi->bi_op_delete = null_back_success;
188 bi->bi_op_abandon = 0;
192 bi->bi_chk_referrals = 0;
194 bi->bi_connection_init = 0;
195 bi->bi_connection_destroy = 0;
197 bi->bi_tool_entry_open = null_tool_entry_open;
198 bi->bi_tool_entry_close = null_tool_entry_close;
199 bi->bi_tool_entry_first = null_tool_entry_next;
200 bi->bi_tool_entry_next = null_tool_entry_next;
201 bi->bi_tool_entry_get = null_tool_entry_get;
202 bi->bi_tool_entry_put = null_tool_entry_put;
207 #if SLAPD_NULL == SLAPD_MOD_DYNAMIC
209 /* conditionally define the init_module() function */
210 SLAP_BACKEND_INIT_MODULE( null )
212 #endif /* SLAPD_NULL == SLAPD_MOD_DYNAMIC */