s4-dbcheck: support the 'none' option for prompts
[metze/samba-autobuild/.git] / lib / ldb / tests / sample_module.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Samba utility functions
4    Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
5
6      ** NOTE! The following LGPL license applies to the ldb
7      ** library. This does NOT imply that all of Samba is released
8      ** under the LGPL
9    
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Lesser General Public
12    License as published by the Free Software Foundation; either
13    version 3 of the License, or (at your option) any later version.
14
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Lesser General Public License for more details.
19
20    You should have received a copy of the GNU Lesser General Public
21    License along with this library; if not, see <http://www.gnu.org/licenses/>.
22 */
23
24 #include "replace.h"
25 #include "system/filesys.h"
26 #include "system/time.h"
27 #include "ldb_module.h"
28
29 static int sample_add(struct ldb_module *mod, struct ldb_request *req)
30 {
31         struct ldb_control *control;
32
33         ldb_msg_add_fmt(req->op.add.message, "touchedBy", "sample");
34
35         /* check if there's a relax control */
36         control = ldb_request_get_control(req, LDB_CONTROL_RELAX_OID);
37         if (control == NULL) {
38                 /* not found go on */
39                 return ldb_next_request(mod, req);
40         } else {
41                 return LDB_ERR_UNWILLING_TO_PERFORM;
42         }
43 }
44
45 static int sample_modify(struct ldb_module *mod, struct ldb_request *req)
46 {
47         struct ldb_control *control;
48
49         /* check if there's a relax control */
50         control = ldb_request_get_control(req, LDB_CONTROL_RELAX_OID);
51         if (control == NULL) {
52                 /* not found go on */
53                 return ldb_next_request(mod, req);
54         } else {
55                 return LDB_ERR_UNWILLING_TO_PERFORM;
56         }
57 }
58
59
60 static struct ldb_module_ops ldb_sample_module_ops = {
61         .name              = "sample",
62         .add               = sample_add,
63         .del               = sample_modify,
64         .modify            = sample_modify,
65 };
66
67 int ldb_sample_init(const char *version)
68 {
69         LDB_MODULE_CHECK_VERSION(version);
70         return ldb_register_module(&ldb_sample_module_ops);
71 }