1 /* null.c - the null backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2002-2004 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 Howard Chu for inclusion
18 * in OpenLDAP Software.
24 #include <ac/string.h>
33 extern BI_db_init null_back_db_init;
34 extern BI_db_destroy null_back_db_destroy;
35 extern BI_db_config null_back_db_config;
37 extern BI_op_bind null_back_bind;
38 extern BI_op_search null_back_search;
39 extern BI_op_compare null_back_compare;
40 extern BI_op_modify null_back_modify;
41 extern BI_op_modrdn null_back_modrdn;
42 extern BI_op_add null_back_add;
43 extern BI_op_delete null_back_delete;
50 null_back_bind( Operation *op, SlapReply *rs )
52 struct null_info *ni = (struct null_info *) op->o_bd->be_private;
54 if ( ni->bind_allowed ) {
55 /* front end will send result on success (0) */
59 rs->sr_err = LDAP_INVALID_CREDENTIALS;
60 send_ldap_result( op, rs );
65 /* add, delete, modify, modrdn, search */
67 null_back_success( Operation *op, SlapReply *rs )
69 rs->sr_err = LDAP_SUCCESS;
70 send_ldap_result( op, rs );
76 null_back_false( Operation *op, SlapReply *rs )
78 rs->sr_err = LDAP_COMPARE_FALSE;
79 send_ldap_result( op, rs );
91 struct null_info *ni = (struct null_info *) be->be_private;
94 fprintf( stderr, "%s: line %d: null database info is null!\n",
99 /* bind requests allowed */
100 if ( strcasecmp( argv[0], "bind" ) == 0 ) {
103 "%s: line %d: missing <on/off> in \"bind <on/off>\" line\n",
107 ni->bind_allowed = strcasecmp( argv[1], "off" );
111 return SLAP_CONF_UNKNOWN;
119 null_back_db_init( BackendDB *be )
121 struct null_info *ni;
123 ni = ch_calloc( 1, sizeof(struct null_info) );
124 ni->bind_allowed = 0;
130 null_back_db_destroy(
134 free( be->be_private );
140 null_back_initialize(
149 bi->bi_db_init = null_back_db_init;
150 bi->bi_db_config = null_back_db_config;
153 bi->bi_db_destroy = null_back_db_destroy;
155 bi->bi_op_bind = null_back_bind;
156 bi->bi_op_unbind = 0;
157 bi->bi_op_search = null_back_success;
158 bi->bi_op_compare = null_back_false;
159 bi->bi_op_modify = null_back_success;
160 bi->bi_op_modrdn = null_back_success;
161 bi->bi_op_add = null_back_success;
162 bi->bi_op_delete = null_back_success;
163 bi->bi_op_abandon = 0;
167 bi->bi_chk_referrals = 0;
169 bi->bi_connection_init = 0;
170 bi->bi_connection_destroy = 0;
175 #if SLAPD_NULL == SLAPD_MOD_DYNAMIC
182 memset( &bi, '\0', sizeof(bi) );
184 bi.bi_init = null_back_initialize;
189 #endif /* SLAPD_NULL */