summaryrefslogtreecommitdiff
path: root/source/lib/cmdline
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-12-18 21:44:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:28 -0500
commit5fec784d4795af0cf82d36766586ded134f62165 (patch)
tree553052f4a14b4514ae7a953f70ff07397f624280 /source/lib/cmdline
parentf34ede763e7f80507d06224d114cf6b5ac7c8f7d (diff)
downloadsamba-5fec784d4795af0cf82d36766586ded134f62165.tar.gz
r12320: Add command-line processing hooks for simple bind DN, and password callback.
We may change this in future. Andrew Bartlett
Diffstat (limited to 'source/lib/cmdline')
-rw-r--r--source/lib/cmdline/credentials.c19
-rw-r--r--source/lib/cmdline/popt_common.c6
2 files changed, 18 insertions, 7 deletions
diff --git a/source/lib/cmdline/credentials.c b/source/lib/cmdline/credentials.c
index a3d4920e6d2..cb1ba5c963d 100644
--- a/source/lib/cmdline/credentials.c
+++ b/source/lib/cmdline/credentials.c
@@ -32,13 +32,20 @@ static const char *cmdline_get_userpassword(struct cli_credentials *credentials)
const char *username;
TALLOC_CTX *mem_ctx = talloc_new(NULL);
- cli_credentials_get_ntlm_username_domain(credentials, mem_ctx, &username, &domain);
- if (domain && domain[0]) {
- prompt = talloc_asprintf(mem_ctx, "Password for [%s\\%s]:",
- domain, username);
- } else {
+ const char *bind_dn = cli_credentials_get_bind_dn(credentials);
+
+ if (bind_dn) {
prompt = talloc_asprintf(mem_ctx, "Password for [%s]:",
- username);
+ bind_dn);
+ } else {
+ cli_credentials_get_ntlm_username_domain(credentials, mem_ctx, &username, &domain);
+ if (domain && domain[0]) {
+ prompt = talloc_asprintf(mem_ctx, "Password for [%s\\%s]:",
+ domain, username);
+ } else {
+ prompt = talloc_asprintf(mem_ctx, "Password for [%s]:",
+ username);
+ }
}
ret = getpass(prompt);
diff --git a/source/lib/cmdline/popt_common.c b/source/lib/cmdline/popt_common.c
index 43ea203b78b..0aa4a634fc8 100644
--- a/source/lib/cmdline/popt_common.c
+++ b/source/lib/cmdline/popt_common.c
@@ -37,7 +37,7 @@
* -i,--scope
*/
-enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL, OPT_DEBUG_STDERR};
+enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL, OPT_DEBUG_STDERR, OPT_SIMPLE_BIND_DN};
struct cli_credentials *cmdline_credentials = NULL;
@@ -242,6 +242,9 @@ static void popt_common_credentials_callback(poptContext con,
/* machine accounts only work with kerberos (fall though)*/
break;
+ case OPT_SIMPLE_BIND_DN:
+ cli_credentials_set_bind_dn(cmdline_credentials, arg);
+ break;
}
}
@@ -254,5 +257,6 @@ struct poptOption popt_common_credentials[] = {
{ "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" },
{ "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" },
{ "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password (implies -k)" },
+ { "simple-bind-dn", 0, POPT_ARG_STRING, NULL, OPT_SIMPLE_BIND_DN, "DN to use for a simple bind" },
POPT_TABLEEND
};