From cda99a202dd2b9fbf230d35a32e2bc7a6b1d1f6d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 26 Aug 2009 11:01:27 +1000 Subject: s4:dsdb Use helper function to add 'show deleted' control This revises tridge's commit 61ca4c491e1c13eb7d97847f743b0f540f1117c4 to use ldb_request_add_control() instead of a manual construction. Andrew Bartlett --- source4/dsdb/samdb/ldb_modules/objectclass.c | 30 ++++++++++------------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index eb35ad052e..6dbafac965 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -997,7 +997,6 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req struct oc_context *ac; struct ldb_dn *parent_dn; int ret; - struct ldb_control **ctrl; ldb = ldb_module_get_ctx(module); @@ -1026,36 +1025,27 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req return LDB_ERR_OPERATIONS_ERROR; } - /* we have to add the show deleted control, as otherwise DRS - deletes will be refused as we will think the target parent - does not exist */ - ctrl = talloc_array(req, struct ldb_control, 2); - if (!ctrl) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - ctrl[0] = talloc(ctrl, struct ldb_control); - if (!ctrl[0]) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - ctrl[0]->oid = LDB_CONTROL_SHOW_DELETED_OID; - ctrl[0]->critical = 0; - ctrl[0]->data = NULL; - ctrl[1] = NULL; - /* note that the results of this search are kept and used to update the parentGUID in objectclass_rename_callback() */ ret = ldb_build_search_req(&search_req, ldb, ac, parent_dn, LDB_SCOPE_BASE, "(objectClass=*)", - attrs, ctrl, + attrs, NULL, ac, get_search_callback, req); if (ret != LDB_SUCCESS) { return ret; } + /* we have to add the show deleted control, as otherwise DRS + deletes will be refused as we will think the target parent + does not exist */ + ret = ldb_request_add_control(search_req, LDB_CONTROL_SHOW_DELETED_OID, false, NULL); + + if (ret != LDB_SUCCESS) { + return ret; + } + ac->step_fn = objectclass_do_rename; return ldb_next_request(ac->module, search_req); -- cgit