4 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2009
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * Component: ldb lazy_commit module
25 * Description: module to pretend to support the 'lazy commit' control
27 * Author: Andrew Bartlett
31 #include "ldb_module.h"
32 #include "dsdb/samdb/ldb_modules/util.h"
34 static int unlazy_op(struct ldb_module
*module
, struct ldb_request
*req
)
37 struct ldb_request
*new_req
;
38 struct ldb_control
*control
= ldb_request_get_control(req
, LDB_CONTROL_SERVER_LAZY_COMMIT
);
40 return ldb_next_request(module
, req
);
43 switch (req
->operation
) {
45 ret
= ldb_build_search_req_ex(&new_req
, ldb_module_get_ctx(module
),
52 req
, dsdb_next_callback
,
54 LDB_REQ_SET_LOCATION(new_req
);
57 ret
= ldb_build_add_req(&new_req
, ldb_module_get_ctx(module
), req
,
60 req
, dsdb_next_callback
,
62 LDB_REQ_SET_LOCATION(new_req
);
65 ret
= ldb_build_mod_req(&new_req
, ldb_module_get_ctx(module
), req
,
68 req
, dsdb_next_callback
,
70 LDB_REQ_SET_LOCATION(new_req
);
73 ret
= ldb_build_del_req(&new_req
, ldb_module_get_ctx(module
), req
,
76 req
, dsdb_next_callback
,
78 LDB_REQ_SET_LOCATION(new_req
);
81 ret
= ldb_build_rename_req(&new_req
, ldb_module_get_ctx(module
), req
,
85 req
, dsdb_next_callback
,
87 LDB_REQ_SET_LOCATION(new_req
);
90 ret
= ldb_build_extended_req(&new_req
, ldb_module_get_ctx(module
),
93 req
->op
.extended
.data
,
95 req
, dsdb_next_callback
,
97 LDB_REQ_SET_LOCATION(new_req
);
100 ldb_set_errstring(ldb_module_get_ctx(module
),
101 "Unsupported request type!");
102 ret
= LDB_ERR_UNWILLING_TO_PERFORM
;
105 if (ret
!= LDB_SUCCESS
) {
109 control
->critical
= 0;
110 return ldb_next_request(module
, new_req
);
113 static const struct ldb_module_ops ldb_lazy_commit_module_ops
= {
114 .name
= "lazy_commit",
120 .request
= unlazy_op
,
121 .extended
= unlazy_op
,
124 int ldb_lazy_commit_module_init(const char *version
)
126 LDB_MODULE_CHECK_VERSION(version
);
127 return ldb_register_module(&ldb_lazy_commit_module_ops
);