summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-11-16 18:32:17 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-11-17 10:38:01 +1100
commit41ce3dc0c3cbfdf06f0ffd3738c34ff8c22f450e (patch)
treec2b99329d1dc42e05443bb7b3b3949390debcf93
parenta2a8dc515cca833c442cc3bb4cf90682e8ba147d (diff)
downloadsamba-41ce3dc0c3cbfdf06f0ffd3738c34ff8c22f450e.tar.gz
samba-41ce3dc0c3cbfdf06f0ffd3738c34ff8c22f450e.tar.bz2
samba-41ce3dc0c3cbfdf06f0ffd3738c34ff8c22f450e.zip
s4:dsdb Add 'dsdb_flags' to dsdb_module_search() to enable often-used features
These flags, also on dsdb_module_search_dn() allow us to add commonly set controls to this pre-packaged blocking search, without rebuilding the whole function in each caller. Andrew Bartlett
-rw-r--r--source4/dsdb/samdb/ldb_modules/extended_dn_store.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/naming_fsmo.c4
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition_init.c6
-rw-r--r--source4/dsdb/samdb/ldb_modules/pdc_fsmo.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/util.c71
-rw-r--r--source4/dsdb/samdb/ldb_modules/util.h5
-rw-r--r--source4/setup/provision_configuration_references.ldif (renamed from source4/setup/provision_configuration_basedn_modify.ldif)0
7 files changed, 84 insertions, 11 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_store.c b/source4/dsdb/samdb/ldb_modules/extended_dn_store.c
index 557acf2d82..3a531c00a5 100644
--- a/source4/dsdb/samdb/ldb_modules/extended_dn_store.c
+++ b/source4/dsdb/samdb/ldb_modules/extended_dn_store.c
@@ -42,7 +42,7 @@
#include "librpc/gen_ndr/ndr_misc.h"
#include "dsdb/samdb/samdb.h"
#include "libcli/security/security.h"
-
+#include "dsdb/samdb/ldb_modules/util.h"
#include <time.h>
struct extended_dn_replace_list {
@@ -275,9 +275,8 @@ static int extended_store_replace(struct extended_dn_context *ac,
return ret;
}
- ret = ldb_request_add_control(os->search_req,
- DSDB_CONTROL_DN_STORAGE_FORMAT_OID,
- true, NULL);
+ ret = dsdb_module_search_handle_flags(ac->module, os->search_req,
+ DSDB_SEARCH_SHOW_DELETED|DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT);
if (ret != LDB_SUCCESS) {
talloc_free(os);
return ret;
diff --git a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
index 15cad259ce..3a10a604ec 100644
--- a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
@@ -67,8 +67,8 @@ static int naming_fsmo_init(struct ldb_module *module)
ldb_module_set_private(module, naming_fsmo);
ret = dsdb_module_search_dn(module, mem_ctx, &naming_res,
- naming_dn,
- naming_attrs);
+ naming_dn,
+ naming_attrs, 0);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
ldb_debug(ldb, LDB_DEBUG_WARNING,
"naming_fsmo_init: no partitions dn present: (skip loading of naming contexts details)\n");
diff --git a/source4/dsdb/samdb/ldb_modules/partition_init.c b/source4/dsdb/samdb/ldb_modules/partition_init.c
index db99b75817..416648c0ac 100644
--- a/source4/dsdb/samdb/ldb_modules/partition_init.c
+++ b/source4/dsdb/samdb/ldb_modules/partition_init.c
@@ -136,7 +136,7 @@ static int partition_reload_metadata(struct ldb_module *module, struct partition
/* perform search for @PARTITION, looking for module, replicateEntries and ldapBackend */
ret = dsdb_module_search_dn(module, mem_ctx, &res,
ldb_dn_new(mem_ctx, ldb, DSDB_PARTITION_DN),
- attrs);
+ attrs, 0);
if (ret != LDB_SUCCESS) {
return ret;
}
@@ -493,7 +493,7 @@ int partition_reload_if_required(struct ldb_module *module,
/* Get the 'correct' case of the partition DNs from the database */
ret = dsdb_module_search_dn(partition->module, data, &dn_res,
- dn, no_attrs);
+ dn, no_attrs, 0);
if (ret == LDB_SUCCESS) {
talloc_free(partition->ctrl->dn);
partition->ctrl->dn = talloc_steal(partition->ctrl, dn_res->msgs[0]->dn);
@@ -533,7 +533,7 @@ static int new_partition_set_replicated_metadata(struct ldb_context *ldb,
struct ldb_request *add_req;
ret = dsdb_module_search_dn(module, last_req, &replicate_res,
data->replicate[i],
- NULL);
+ NULL, 0);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
continue;
}
diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
index 6d814f9334..796ecaf7bc 100644
--- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
@@ -67,7 +67,7 @@ static int pdc_fsmo_init(struct ldb_module *module)
ret = dsdb_module_search_dn(module, mem_ctx, &pdc_res,
pdc_dn,
- pdc_attrs);
+ pdc_attrs, 0);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
ldb_debug(ldb, LDB_DEBUG_WARNING,
"pdc_fsmo_init: no domain object present: (skip loading of domain details)\n");
diff --git a/source4/dsdb/samdb/ldb_modules/util.c b/source4/dsdb/samdb/ldb_modules/util.c
index 372cad62e2..b0f22de255 100644
--- a/source4/dsdb/samdb/ldb_modules/util.c
+++ b/source4/dsdb/samdb/ldb_modules/util.c
@@ -19,8 +19,63 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "includes.h"
#include "ldb.h"
#include "ldb_module.h"
+#include "dsdb/samdb/ldb_modules/util.h"
+#include "dsdb/samdb/samdb.h"
+
+int dsdb_module_search_handle_flags(struct ldb_module *module, struct ldb_request *req, int dsdb_flags)
+{
+ int ret;
+ if (dsdb_flags & DSDB_SEARCH_SEARCH_ALL_PARTITIONS) {
+ struct ldb_search_options_control *options;
+ /* Using the phantom root control allows us to search all partitions */
+ options = talloc(req, struct ldb_search_options_control);
+ if (options == NULL) {
+ ldb_module_oom(module);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ options->search_options = LDB_SEARCH_OPTION_PHANTOM_ROOT;
+
+ ret = ldb_request_add_control(req,
+ LDB_CONTROL_SEARCH_OPTIONS_OID,
+ true, options);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+
+ if (dsdb_flags & DSDB_SEARCH_SHOW_DELETED) {
+ ret = ldb_request_add_control(req, LDB_CONTROL_SHOW_DELETED_OID, true, NULL);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+
+ if (dsdb_flags & DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT) {
+ ret = ldb_request_add_control(req, DSDB_CONTROL_DN_STORAGE_FORMAT_OID, true, NULL);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+
+ if (dsdb_flags & DSDB_SEARCH_SHOW_EXTENDED_DN) {
+ struct ldb_extended_dn_control *extended_ctrl = talloc(req, struct ldb_extended_dn_control);
+ if (!extended_ctrl) {
+ ldb_module_oom(module);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ extended_ctrl->type = 1;
+
+ ret = ldb_request_add_control(req, LDB_CONTROL_EXTENDED_DN_OID, true, extended_ctrl);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+
+ return LDB_SUCCESS;
+}
/*
search for attrs on one DN, in the modules below
@@ -29,7 +84,8 @@ int dsdb_module_search_dn(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct ldb_result **_res,
struct ldb_dn *basedn,
- const char * const *attrs)
+ const char * const *attrs,
+ int dsdb_flags)
{
int ret;
struct ldb_request *req;
@@ -57,6 +113,12 @@ int dsdb_module_search_dn(struct ldb_module *module,
return ret;
}
+ ret = dsdb_module_search_handle_flags(module, req, dsdb_flags);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ return ret;
+ }
+
ret = ldb_next_request(module, req);
if (ret == LDB_SUCCESS) {
ret = ldb_wait(req->handle, LDB_WAIT_ALL);
@@ -88,6 +150,7 @@ int dsdb_module_search(struct ldb_module *module,
struct ldb_result **_res,
struct ldb_dn *basedn, enum ldb_scope scope,
const char * const *attrs,
+ int dsdb_flags,
const char *expression)
{
int ret;
@@ -116,6 +179,12 @@ int dsdb_module_search(struct ldb_module *module,
return ret;
}
+ ret = dsdb_module_search_handle_flags(module, req, dsdb_flags);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ return ret;
+ }
+
ret = ldb_next_request(module, req);
if (ret == LDB_SUCCESS) {
ret = ldb_wait(req->handle, LDB_WAIT_ALL);
diff --git a/source4/dsdb/samdb/ldb_modules/util.h b/source4/dsdb/samdb/ldb_modules/util.h
index 0a1ab83c6d..b612c64acc 100644
--- a/source4/dsdb/samdb/ldb_modules/util.h
+++ b/source4/dsdb/samdb/ldb_modules/util.h
@@ -20,3 +20,8 @@
*/
#include "dsdb/samdb/ldb_modules/util_proto.h"
+
+#define DSDB_SEARCH_SEARCH_ALL_PARTITIONS 0x0001
+#define DSDB_SEARCH_SHOW_DELETED 0x0002
+#define DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT 0x0004
+#define DSDB_SEARCH_SHOW_EXTENDED_DN 0x0010
diff --git a/source4/setup/provision_configuration_basedn_modify.ldif b/source4/setup/provision_configuration_references.ldif
index 6e31fb79fe..6e31fb79fe 100644
--- a/source4/setup/provision_configuration_basedn_modify.ldif
+++ b/source4/setup/provision_configuration_references.ldif