diff options
author | Andrew Bartlett <abartlet@samba.org> | 2006-05-03 20:23:19 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:05:35 -0500 |
commit | 1789976c172085569026e62bc563ff0ea017fe9d (patch) | |
tree | d58a52341eb7d75a42fa86a930ec158b8a22798d /source4/auth | |
parent | 5d689a5de2d6ddfbab1753ff219d9d55cb009cac (diff) | |
download | samba-1789976c172085569026e62bc563ff0ea017fe9d.tar.gz samba-1789976c172085569026e62bc563ff0ea017fe9d.tar.bz2 samba-1789976c172085569026e62bc563ff0ea017fe9d.zip |
r15420: Add a new function to print a the 'unparsed' string format for usernames.
This is used in the password prompt, and should be reversable by the
parse string function.
Also, don't look at the ccache, even for the guess code, if kerberos
is disabled.
Andrew Bartlett
(This used to be commit 4c4b8e4b396ca44270a0456c732d3b9c3c34d69d)
Diffstat (limited to 'source4/auth')
-rw-r--r-- | source4/auth/credentials/credentials.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/source4/auth/credentials/credentials.c b/source4/auth/credentials/credentials.c index cf54bfe3b5..e00251d69f 100644 --- a/source4/auth/credentials/credentials.c +++ b/source4/auth/credentials/credentials.c @@ -514,6 +514,38 @@ void cli_credentials_parse_string(struct cli_credentials *credentials, const cha } /** + * Given a string, typically obtained from a -U argument, parse it into domain, username, realm and password fields + * + * The format accepted is [domain\\]user[%password] or user[@realm][%password] + * + * @param credentials Credentials structure on which to set the password + * @param data the string containing the username, password etc + * @param obtained This enum describes how 'specified' this password is + */ + +const char *cli_credentials_get_unparsed_name(struct cli_credentials *credentials, TALLOC_CTX *mem_ctx) +{ + const char *bind_dn = cli_credentials_get_bind_dn(credentials); + const char *domain; + const char *username; + const char *name; + + if (bind_dn) { + name = talloc_reference(mem_ctx, bind_dn); + } else { + cli_credentials_get_ntlm_username_domain(credentials, mem_ctx, &username, &domain); + if (domain && domain[0]) { + name = talloc_asprintf(mem_ctx, "%s\\%s", + domain, username); + } else { + name = talloc_asprintf(mem_ctx, "%s", + username); + } + } + return name; +} + +/** * Specifies default values for domain, workstation and realm * from the smb.conf configuration file * @@ -565,8 +597,10 @@ void cli_credentials_guess(struct cli_credentials *cred) if (getenv("PASSWD_FILE")) { cli_credentials_parse_password_file(cred, getenv("PASSWD_FILE"), CRED_GUESS_FILE); } - - cli_credentials_set_ccache(cred, NULL, CRED_GUESS_FILE); + + if (cli_credentials_get_kerberos_state(cred) != CRED_DONT_USE_KERBEROS) { + cli_credentials_set_ccache(cred, NULL, CRED_GUESS_FILE); + } } /** @@ -646,7 +680,7 @@ BOOL cli_credentials_is_anonymous(struct cli_credentials *cred) * Mark the current password for a credentials struct as wrong. This will * cause the password to be prompted again (if a callback is set). * - * This will decremebt the number of times the password can be tried. + * This will decrement the number of times the password can be tried. * * @retval whether the credentials struct is finished */ |