diff options
author | Jim McDonough <jmcd@samba.org> | 2002-01-25 22:07:46 +0000 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2002-01-25 22:07:46 +0000 |
commit | de260eadf956cae8aeaebc2a84f46a57c0671741 (patch) | |
tree | e501595e49162ed81b27bad864a58df29c5a84e4 /source3/utils/net_ads.c | |
parent | 9d8ed7220fed8a3b7ff9d45b9c5902c3255956ac (diff) | |
download | samba-de260eadf956cae8aeaebc2a84f46a57c0671741.tar.gz samba-de260eadf956cae8aeaebc2a84f46a57c0671741.tar.xz samba-de260eadf956cae8aeaebc2a84f46a57c0671741.zip |
Enable net ads commands to use existing tickets if the user doesn't specify a username on the commandline. Also don't continue past the kinit if a password is entered and fails because existing tickets would be used, which may not be desired if the username was specified.
(This used to be commit 7e5d7dfa834c0161460bde8a2f0d4824c0a0d1fe)
Diffstat (limited to 'source3/utils/net_ads.c')
-rw-r--r-- | source3/utils/net_ads.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index fec31c6ea3f..ae7bf5d4467 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -75,8 +75,12 @@ static ADS_STRUCT *ads_startup(void) { ADS_STRUCT *ads; ADS_STATUS status; + BOOL need_password = False; + BOOL second_time = False; extern char *opt_password; extern char *opt_user_name; + extern BOOL opt_user_specified; + ads = ads_init(NULL, NULL, NULL, NULL); @@ -84,19 +88,30 @@ static ADS_STRUCT *ads_startup(void) opt_user_name = "administrator"; } - if (!opt_password) { + if (opt_user_specified) + need_password = True; + +retry: + if (!opt_password && need_password) { char *prompt; asprintf(&prompt,"%s password: ", opt_user_name); opt_password = getpass(prompt); free(prompt); + ads->password = strdup(opt_password); } - ads->password = strdup(opt_password); + ads->user_name = strdup(opt_user_name); status = ads_connect(ads); if (!ADS_ERR_OK(status)) { - d_printf("ads_connect: %s\n", ads_errstr(status)); - return NULL; + if (!need_password && !second_time) { + need_password = True; + second_time = True; + goto retry; + } else { + d_printf("ads_connect: %s\n", ads_errstr(status)); + return NULL; + } } return ads; } |