From 75438e0ed54ae35b68fde8c6b4781b79084ce24d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 7 Mar 2024 14:55:09 +0100 Subject: [PATCH] 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 --- source3/utils/net_ads.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 176438bb9f25..0500174dd5f4 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -3149,6 +3149,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; @@ -3175,10 +3176,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, @@ -3340,6 +3346,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) { @@ -3351,9 +3358,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, -- 2.34.1