From: Andreas Schneider Date: Thu, 18 Mar 2021 12:34:15 +0000 (+0100) Subject: s3:netapi: Add libnetapi_set_creds() X-Git-Tag: tevent-0.11.0~1406 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c871c224611296ee922a508129913aca93a38a16;p=thirdparty%2Fsamba.git s3:netapi: Add libnetapi_set_creds() This will be used by the 'net' command in future! Signed-off-by: Andreas Schneider Reviewed-by: Guenther Deschner Autobuild-User(master): Günther Deschner Autobuild-Date(master): Wed Mar 24 02:07:20 UTC 2021 on sn-devel-184 --- diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index dfb11fdc951..a56651d100f 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -315,6 +315,27 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, return NET_API_STATUS_SUCCESS; } +/** + * @brief Set the cli_credentials to be used in the netapi context + * + * @param[in] ctx The netapi context + * + * @param[in] creds The cli_credentials which should be used by netapi. + * + * @return 0 on success, an werror code otherwise. + */ +NET_API_STATUS libnetapi_set_creds(struct libnetapi_ctx *ctx, + struct cli_credentials *creds) +{ + if (ctx == NULL || creds == NULL) { + return W_ERROR_V(WERR_INVALID_PARAMETER); + } + + ctx->creds = creds; + + return NET_API_STATUS_SUCCESS; +} + /**************************************************************** ****************************************************************/ diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index b0560e1af1d..af2e4aaf961 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -24,6 +24,8 @@ extern "C" { #endif /* __cplusplus */ +struct cli_credentials; + /**************************************************************** NET_API_STATUS ****************************************************************/ @@ -1394,6 +1396,10 @@ 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_set_username(struct libnetapi_ctx *ctx, const char *username);