From: Stefan Metzmacher Date: Thu, 7 Mar 2024 13:55:09 +0000 (+0100) Subject: s3:net_ads: use cli_credentials_get_principal() in order to call kerberos functions X-Git-Tag: tdb-1.4.11~740 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=612af29cef19b6b3722aa94adff34542ac519236;p=thirdparty%2Fsamba.git s3:net_ads: use cli_credentials_get_principal() in order to call kerberos functions This is better than the value from cli_credentials_get_username()... Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index f368724215b..e8e6ea2ac92 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -3254,6 +3254,7 @@ static int net_ads_kerberos_pac_common(struct net_context *c, int argc, const ch int ret = -1; const char *impersonate_princ_s = NULL; const char *local_service = NULL; + const char *principal = NULL; const char *password = NULL; int i; @@ -3280,10 +3281,15 @@ static int net_ads_kerberos_pac_common(struct net_context *c, int argc, const ch } } + principal = cli_credentials_get_principal(c->creds, c); + if (principal == NULL) { + d_printf("cli_credentials_get_principal() failed\n"); + goto out; + } password = cli_credentials_get_password(c->creds); status = kerberos_return_pac(c, - c->opt_user_name, + principal, password, 0, NULL, @@ -3445,6 +3451,7 @@ static int net_ads_kerberos_kinit(struct net_context *c, int argc, const char ** { int ret = -1; NTSTATUS status; + const char *principal = NULL; const char *password = NULL; if (c->display_usage) { @@ -3456,9 +3463,14 @@ static int net_ads_kerberos_kinit(struct net_context *c, int argc, const char ** return -1; } + principal = cli_credentials_get_principal(c->creds, c); + if (principal == NULL) { + d_printf("cli_credentials_get_principal() failed\n"); + return -1; + } password = cli_credentials_get_password(c->creds); - ret = kerberos_kinit_password_ext(c->opt_user_name, + ret = kerberos_kinit_password_ext(principal, password, 0, NULL,