diff options
Diffstat (limited to 'source4/lib/ldb/tools')
-rw-r--r-- | source4/lib/ldb/tools/ldbedit.c | 17 | ||||
-rw-r--r-- | source4/lib/ldb/tools/ldbsearch.c | 19 |
2 files changed, 18 insertions, 18 deletions
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index e8497ba18f..12bf12bfff 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -278,28 +278,23 @@ static void usage(void) struct ldb_context *ldb; struct ldb_message **msgs; int ret; - const char *expression = NULL; + const char *expression = "(|(objectclass=*)(dn=*))"; const char * const * attrs = NULL; ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); - if (options->all_records) { - expression = "(|(objectclass=*)(dn=*))"; - } - - if (!expression) { - if (options->argc == 0) { - usage(); - } + /* the check for '=' is for compatibility with ldapsearch */ + if (options->argc > 0 && + strchr(options->argv[0], '=')) { expression = options->argv[0]; - options->argc--; options->argv++; + options->argc--; } if (options->argc > 0) { - attrs = (const char * const *)options->argv; + attrs = (const char * const *)(options->argv); } ret = ldb_search(ldb, options->basedn, options->scope, expression, attrs, &msgs); diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index 0e81da5de3..396bb7797a 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -120,18 +120,23 @@ static int do_search(struct ldb_context *ldb, const char * const * attrs = NULL; struct ldb_cmdline *options; int ret = -1; + const char *expression = "(|(objectclass=*)(dn=*))"; ldb = ldb_init(NULL); options = ldb_cmdline_process(ldb, argc, argv, usage); - - if (options->argc < 1 && !options->interactive) { - usage(); - exit(1); + + /* the check for '=' is for compatibility with ldapsearch */ + if (!options->interactive && + options->argc > 0 && + strchr(options->argv[0], '=')) { + expression = options->argv[0]; + options->argv++; + options->argc--; } - if (options->argc > 1) { - attrs = (const char * const *)(options->argv+1); + if (options->argc > 0) { + attrs = (const char * const *)(options->argv); } if (options->interactive) { @@ -144,7 +149,7 @@ static int do_search(struct ldb_context *ldb, } } else { ret = do_search(ldb, options->basedn, options->scope, options->sorted, - options->argv[0], attrs); + expression, attrs); } talloc_free(ldb); |