From 36d73b0e71eb3fbbe8d660b7609806b0355bd09c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Oct 2005 11:00:16 +0000 Subject: r10894: make the handling of dn/distinguishedName much closer to real ldap. Also ensure we put a objectclass on our private ldb's, so they have some chance of being stored in ldap if you want to (This used to be commit 1af2cc067f70f6654d08387fc28def67229bb06a) --- source4/lib/gendb.c | 2 +- source4/lib/ldb/common/ldb_match.c | 7 ++++++- source4/lib/ldb/common/ldb_parse.c | 2 +- source4/lib/ldb/tools/cmdline.c | 2 +- source4/lib/ldb/tools/ldbdel.c | 4 ++-- source4/lib/ldb/tools/ldbedit.c | 2 +- source4/lib/ldb/tools/ldbsearch.c | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/gendb.c b/source4/lib/gendb.c index a5fe7c3bce..e0fb9662bb 100644 --- a/source4/lib/gendb.c +++ b/source4/lib/gendb.c @@ -90,7 +90,7 @@ int gendb_search_dn(struct ldb_context *ldb, struct ldb_message ***res, const char * const *attrs) { - return gendb_search(ldb, mem_ctx, dn, res, attrs, "dn=%s", ldb_dn_linearize(mem_ctx, dn)); + return gendb_search(ldb, mem_ctx, dn, res, attrs, NULL); } /* diff --git a/source4/lib/ldb/common/ldb_match.c b/source4/lib/ldb/common/ldb_match.c index 1269d99a0f..78e4304f6c 100644 --- a/source4/lib/ldb/common/ldb_match.c +++ b/source4/lib/ldb/common/ldb_match.c @@ -88,7 +88,7 @@ static int ldb_match_present(struct ldb_context *ldb, enum ldb_scope scope) { - if (ldb_attr_cmp(tree->u.present.attr, "dn") == 0) { + if (ldb_attr_cmp(tree->u.present.attr, "distinguishedName") == 0) { return 1; } @@ -151,8 +151,13 @@ static int ldb_match_equality(struct ldb_context *ldb, struct ldb_dn *valuedn; int ret; + /* catch the old method of dn matching */ if (ldb_attr_cmp(tree->u.equality.attr, "dn") == 0) { + ldb_debug(ldb, LDB_DEBUG_FATAL, "attempt to match on 'dn' - should use distinguishedName"); + return 0; + } + if (ldb_attr_cmp(tree->u.equality.attr, "distinguishedName") == 0) { valuedn = ldb_dn_explode_casefold(ldb, tree->u.equality.value.data); if (valuedn == NULL) { return 0; diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c index 27f9e1ec25..e61511ebec 100644 --- a/source4/lib/ldb/common/ldb_parse.c +++ b/source4/lib/ldb/common/ldb_parse.c @@ -621,7 +621,7 @@ static struct ldb_parse_tree *ldb_parse_filter(void *mem_ctx, const char **s) struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s) { if (s == NULL || *s == 0) { - s = "(|(objectClass=*)(dn=*))"; + s = "(|(objectClass=*)(distinguishedName=*))"; } while (isspace((unsigned char)*s)) s++; diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 2428306f39..ca9d3847e8 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -54,7 +54,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "recursive", 'r', POPT_ARG_NONE, &options.recursive, 0, "recursive delete", NULL }, { "num-searches", 0, POPT_ARG_INT, &options.num_searches, 0, "number of test searches", NULL }, { "num-records", 0, POPT_ARG_INT, &options.num_records, 0, "number of test records", NULL }, - { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "dn=*", NULL }, + { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "objectClass=*", NULL }, { "nosync", 0, POPT_ARG_NONE, &options.nosync, 0, "non-synchronous transactions", NULL }, { "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL }, { "sasl-mechanism", 0, POPT_ARG_STRING, &options.sasl_mechanism, 0, "choose SASL mechanism", "MECHANISM" }, diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 6082931e22..bd40fccbdb 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -44,10 +44,10 @@ static int ldb_delete_recursive(struct ldb_context *ldb, const struct ldb_dn *dn) { int ret, i, total=0; - const char *attrs[] = { "dn", NULL }; + const char *attrs[] = { NULL }; struct ldb_message **res; - ret = ldb_search(ldb, dn, LDB_SCOPE_SUBTREE, "dn=*", attrs, &res); + ret = ldb_search(ldb, dn, LDB_SCOPE_SUBTREE, "distinguishedName=*", attrs, &res); if (ret <= 0) return -1; for (i=0;i