From f40e69da2633771a42ec2b74fca63bd0b0a37e4a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 18 Jun 2005 09:01:09 +0000 Subject: r7714: enable samba credentials handling in ldb tools. So you can now do a encrypted ldbedit against w2k3 (This used to be commit 6277c3923e7d9c26753424b1e77ac62f8e0729a4) --- source4/lib/ldb/tools/cmdline.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/lib/ldb/tools/cmdline.c') diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index a7bfac8bb4..1f4a7544a5 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -26,6 +26,9 @@ #include "ldb/include/ldb.h" #include "ldb/include/ldb_private.h" #include "ldb/tools/cmdline.h" +#ifdef _SAMBA_BUILD_ +#include "lib/cmdline/popt_common.h" +#endif /* process command line options @@ -50,10 +53,20 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const { "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 }, { "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" }, { NULL, 'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" }, +#ifdef _SAMBA_BUILD_ + POPT_COMMON_SAMBA + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION +#endif POPT_TABLEEND }; +#ifdef _SAMBA_BUILD_ + ldbsearch_init_subsystems; +#endif + ret = talloc_zero(ldb, struct ldb_cmdline); if (ret == NULL) { ldb_oom(ldb); @@ -74,6 +87,8 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const options.editor = "vi"; } + options.scope = LDB_SCOPE_DEFAULT; + pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST); @@ -133,6 +148,12 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const goto failed; } + if (ldb_connect(ldb, ret->url, 0, ret->options) != 0) { + fprintf(stderr, "Failed to connect to %s - %s\n", + ret->url, ldb_errstring(ldb)); + goto failed; + } + return ret; failed: -- cgit