From 80c575923f40def2770b7ed2b95f458c605c6ece Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 13 Sep 2009 18:12:05 +1000 Subject: s4-sam: allow a search to specify a partition You can now attach a partition control to searches to search within a specific partition. This is used to get at the per-partition @REPLCHANGED object --- source4/dsdb/samdb/ldb_modules/partition.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'source4/dsdb') diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c index d4a69952e8..79d11fd958 100644 --- a/source4/dsdb/samdb/ldb_modules/partition.c +++ b/source4/dsdb/samdb/ldb_modules/partition.c @@ -161,6 +161,10 @@ static struct dsdb_partition *find_partition(struct partition_private_data *data } } + if (dn == NULL) { + return NULL; + } + /* Look at base DN */ /* Figure out which partition it is under */ /* Skip the lot if 'data' isn't here yet (initialisation) */ @@ -470,10 +474,10 @@ static int partition_replicate(struct ldb_module *module, struct ldb_request *re static int partition_search(struct ldb_module *module, struct ldb_request *req) { struct ldb_control **saved_controls; - /* Find backend */ struct partition_private_data *data = talloc_get_type(module->private_data, struct partition_private_data); + /* issue request */ /* (later) consider if we should be searching multiple @@ -483,6 +487,17 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req) struct ldb_control *domain_scope_control = ldb_request_get_control(req, LDB_CONTROL_DOMAIN_SCOPE_OID); struct ldb_search_options_control *search_options = NULL; + struct dsdb_partition *p; + + p = find_partition(data, NULL, req); + if (p != NULL) { + /* the caller specified what partition they want the + * search - just pass it on + */ + return ldb_next_request(p->module, req); + } + + if (search_control) { search_options = talloc_get_type(search_control->data, struct ldb_search_options_control); } @@ -765,7 +780,7 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque struct ldb_result *res; struct dsdb_partition *p; - p = find_partition(NULL, NULL, req); + p = find_partition(data, NULL, req); if (p != NULL) { /* the caller specified what partition they want the * sequence number operation on - just pass it on -- cgit