summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2008-09-11 18:36:28 -0400
committerStefan Metzmacher <metze@samba.org>2008-09-29 04:22:20 +0200
commit51baa8deec00244cc0a6e3d29c53932427800610 (patch)
treee4a63113b3e39120259c5ac3dc80ed2199d749fe /source4/dsdb/samdb/ldb_modules/schema_fsmo.c
parent4f40ee2b86007f7dc631e93e59f24f970bc25ea2 (diff)
downloadsamba-51baa8deec00244cc0a6e3d29c53932427800610.tar.gz
samba-51baa8deec00244cc0a6e3d29c53932427800610.tar.bz2
samba-51baa8deec00244cc0a6e3d29c53932427800610.zip
LDB ASYNC: samba4 modules
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules/schema_fsmo.c')
-rw-r--r--source4/dsdb/samdb/ldb_modules/schema_fsmo.c100
1 files changed, 56 insertions, 44 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
index 4b6e9e1d47..56d24a2962 100644
--- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
@@ -62,8 +62,10 @@ struct schema_fsmo_private_data {
};
struct schema_fsmo_search_data {
- struct schema_fsmo_private_data *module_context;
- struct ldb_request *orig_req;
+ struct ldb_module *module;
+ struct ldb_request *req;
+
+ const struct dsdb_schema *schema;
};
static int schema_fsmo_init(struct ldb_module *module)
@@ -325,41 +327,54 @@ static int generate_dITContentRules(struct ldb_context *ldb, struct ldb_message
/* Add objectClasses, attributeTypes and dITContentRules from the
schema object (they are not stored in the database)
*/
-static int schema_fsmo_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
+static int schema_fsmo_search_callback(struct ldb_request *req, struct ldb_reply *ares)
{
- const struct dsdb_schema *schema = dsdb_get_schema(ldb);
- struct schema_fsmo_search_data *search_data = talloc_get_type(context, struct schema_fsmo_search_data);
- struct ldb_request *orig_req = search_data->orig_req;
- TALLOC_CTX *mem_ctx;
+ struct schema_fsmo_search_data *ac;
+ struct schema_fsmo_private_data *mc;
int i, ret;
- /* Only entries are interesting, and we handle the case of the parent seperatly */
- if (ares->type != LDB_REPLY_ENTRY) {
- return orig_req->callback(ldb, orig_req->context, ares);
- }
+ ac = talloc_get_type(req->context, struct schema_fsmo_search_data);
+ mc = talloc_get_type(ac->module->private_data, struct schema_fsmo_private_data);
- if (ldb_dn_compare(ares->message->dn, search_data->module_context->aggregate_dn) != 0) {
- talloc_free(mem_ctx);
- return orig_req->callback(ldb, orig_req->context, ares);
+ if (!ares) {
+ return ldb_module_done(ac->req, NULL, NULL,
+ LDB_ERR_OPERATIONS_ERROR);
}
-
- mem_ctx = talloc_new(ares);
- if (!mem_ctx) {
- ldb_oom(ldb);
- return LDB_ERR_OPERATIONS_ERROR;
+ if (ares->error != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
}
+ /* Only entries are interesting, and we handle the case of the parent seperatly */
- for (i=0; i < ARRAY_SIZE(generated_attrs); i++) {
- if (ldb_attr_in_list(orig_req->op.search.attrs, generated_attrs[i].attr)) {
- ret = generated_attrs[i].fn(ldb, ares->message, schema);
- if (ret != LDB_SUCCESS) {
- return ret;
+ switch (ares->type) {
+ case LDB_REPLY_ENTRY:
+
+ if (ldb_dn_compare(ares->message->dn, mc->aggregate_dn) != 0) {
+ return ldb_module_send_entry(ac->req, ares->message);
+ }
+
+ for (i=0; i < ARRAY_SIZE(generated_attrs); i++) {
+ if (ldb_attr_in_list(ac->req->op.search.attrs, generated_attrs[i].attr)) {
+ ret = generated_attrs[i].fn(ac->module->ldb, ares->message, ac->schema);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
}
}
+
+ return ldb_module_send_entry(ac->req, ares->message);
+
+ case LDB_REPLY_REFERRAL:
+
+ return ldb_module_send_referral(ac->req, ares->referral);
+
+ case LDB_REPLY_DONE:
+
+ return ldb_module_done(ac->req, ares->controls,
+ ares->response, ares->error);
}
- talloc_free(mem_ctx);
- return orig_req->callback(ldb, orig_req->context, ares);
+ return LDB_SUCCESS;
}
/* search */
@@ -390,27 +405,24 @@ static int schema_fsmo_search(struct ldb_module *module, struct ldb_request *req
ldb_oom(module->ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- down_req = talloc(req, struct ldb_request);
- if (!down_req) {
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- *down_req = *req;
- search_context->orig_req = req;
- search_context->module_context = talloc_get_type(module->private_data, struct schema_fsmo_private_data);
- down_req->context = search_context;
-
- down_req->callback = schema_fsmo_search_callback;
- ret = ldb_next_request(module, down_req);
+ search_context->module = module;
+ search_context->req = req;
+ search_context->schema = schema;
- /* do not free down_req as the call results may be linked to it,
- * it will be freed when the upper level request get freed */
- if (ret == LDB_SUCCESS) {
- req->handle = down_req->handle;
+ ret = ldb_build_search_req_ex(&down_req, module->ldb, search_context,
+ req->op.search.base,
+ req->op.search.scope,
+ req->op.search.tree,
+ req->op.search.attrs,
+ req->controls,
+ search_context, schema_fsmo_search_callback,
+ req);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- return ret;
+
+ return ldb_next_request(module, down_req);
}