summaryrefslogtreecommitdiff
path: root/lib/ldb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-08-31 16:17:54 +1000
committerAndrew Tridgell <tridge@samba.org>2011-09-01 15:23:09 +1000
commit4d6c120fb7a9aef80e83f00b155ff93e96034897 (patch)
tree5c744ed121b4b6218fc94ba99551bdaa32991045 /lib/ldb
parent8ab3c843b1bf0f60a7d6b68411931d204b6f882b (diff)
downloadsamba-4d6c120fb7a9aef80e83f00b155ff93e96034897.tar.gz
samba-4d6c120fb7a9aef80e83f00b155ff93e96034897.tar.bz2
samba-4d6c120fb7a9aef80e83f00b155ff93e96034897.zip
ldb: fixed ldbsearch when no baseDN specified and cross-ncs is used
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib/ldb')
-rw-r--r--lib/ldb/tools/ldbsearch.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/ldb/tools/ldbsearch.c b/lib/ldb/tools/ldbsearch.c
index d10b9650da..2da7072fa6 100644
--- a/lib/ldb/tools/ldbsearch.c
+++ b/lib/ldb/tools/ldbsearch.c
@@ -204,10 +204,6 @@ static int do_search(struct ldb_context *ldb,
return LDB_ERR_OPERATIONS_ERROR;
}
- if (basedn == NULL) {
- basedn = ldb_get_default_basedn(ldb);
- }
-
again:
/* free any previous requests */
if (req) talloc_free(req);
@@ -224,6 +220,30 @@ again:
return ret;
}
+ if (basedn == NULL) {
+ /*
+ we need to use a NULL base DN when doing a cross-ncs
+ search so we find results on all partitions in a
+ forest. When doing a domain-local search, default to
+ the default basedn
+ */
+ struct ldb_control *ctrl;
+ struct ldb_search_options_control *search_options = NULL;
+
+ ctrl = ldb_request_get_control(req, LDB_CONTROL_SEARCH_OPTIONS_OID);
+ if (ctrl) {
+ search_options = talloc_get_type(ctrl->data, struct ldb_search_options_control);
+ }
+
+ if (ctrl == NULL || search_options == NULL ||
+ !(search_options->search_options & LDB_SEARCH_OPTION_PHANTOM_ROOT)) {
+ struct ldb_dn *base = ldb_get_default_basedn(ldb);
+ if (base != NULL) {
+ req->op.search.base = base;
+ }
+ }
+ }
+
sctx->pending = 0;
ret = ldb_request(ldb, req);