From: Stefan Metzmacher Date: Tue, 5 Mar 2024 16:38:25 +0000 (+0100) Subject: s3:lib/netapi: add libnetapi_get_creds() X-Git-Tag: tdb-1.4.11~749 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0470cc385d935d6898afd6cf993fef3b9881f8ac;p=thirdparty%2Fsamba.git s3:lib/netapi: add libnetapi_get_creds() Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 9c049a84111..0d8f0f35da0 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -372,6 +372,29 @@ NET_API_STATUS libnetapi_set_creds(struct libnetapi_ctx *ctx, return NET_API_STATUS_SUCCESS; } +/** + * @brief Get the credentials of the libnet context + * + * @param[in] ctx The netapi context + * + * @param[in] creds A pointer to hold the creds. + * + * @return 0 on success, an werror code otherwise. + */ +NET_API_STATUS libnetapi_get_creds(struct libnetapi_ctx *ctx, + struct cli_credentials **creds) +{ + if (ctx == NULL) { + return W_ERROR_V(WERR_INVALID_PARAMETER); + } + + if (creds != NULL) { + *creds = ctx->creds; + } + + return NET_API_STATUS_SUCCESS; +} + /**************************************************************** ****************************************************************/ diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 660a7766bd6..b9bf4a09804 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -1416,6 +1416,8 @@ NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, NET_API_STATUS libnetapi_set_creds(struct libnetapi_ctx *ctx, struct cli_credentials *creds); +NET_API_STATUS libnetapi_get_creds(struct libnetapi_ctx *ctx, + struct cli_credentials **creds); NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *username);