diff options
author | Andreas Schneider <asn@samba.org> | 2021-03-18 10:57:10 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2021-03-24 00:55:32 +0000 |
commit | 9285e64a623c1a9a65e6d74ef26bf48d25d2be6b (patch) | |
tree | d4acb7d6500619ede5d831173fb2dec44e849bae /source3/lib/netapi | |
parent | 7bb70f701e49e11d41583369737522f3db9b9382 (diff) | |
download | samba-9285e64a623c1a9a65e6d74ef26bf48d25d2be6b.tar.gz |
s3:netapi: Fill also cli_credentials with netapi setters
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r-- | source3/lib/netapi/netapi.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 591523edfe0..ea67ecdec5a 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -25,6 +25,7 @@ #include "krb5_env.h" #include "source3/param/loadparm.h" #include "lib/param/param.h" +#include "auth/gensec/gensec.h" struct libnetapi_ctx *stat_ctx = NULL; static bool libnetapi_initialized = false; @@ -286,34 +287,61 @@ NET_API_STATUS libnetapi_get_password(struct libnetapi_ctx *ctx, NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *username) { + if (ctx == NULL || username == NULL) { + return W_ERROR_V(WERR_INVALID_PARAMETER); + } + TALLOC_FREE(ctx->username); ctx->username = talloc_strdup(ctx, username ? username : ""); if (!ctx->username) { return W_ERROR_V(WERR_NOT_ENOUGH_MEMORY); } + + cli_credentials_parse_string(ctx->creds, username, CRED_SPECIFIED); + return NET_API_STATUS_SUCCESS; } NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx, const char *password) { + bool ok; + + if (ctx == NULL || password == NULL) { + return W_ERROR_V(WERR_INVALID_PARAMETER); + } + TALLOC_FREE(ctx->password); ctx->password = talloc_strdup(ctx, password); if (!ctx->password) { return W_ERROR_V(WERR_NOT_ENOUGH_MEMORY); } + + ok = cli_credentials_set_password(ctx->creds, password, CRED_SPECIFIED); + if (!ok) { + return W_ERROR_V(WERR_INTERNAL_ERROR); + } + return NET_API_STATUS_SUCCESS; } NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, const char *workgroup) { + bool ok; + TALLOC_FREE(ctx->workgroup); ctx->workgroup = talloc_strdup(ctx, workgroup); if (!ctx->workgroup) { return W_ERROR_V(WERR_NOT_ENOUGH_MEMORY); } + + ok = cli_credentials_set_domain(ctx->creds, workgroup, CRED_SPECIFIED); + if (!ok) { + return W_ERROR_V(WERR_INTERNAL_ERROR); + } + return NET_API_STATUS_SUCCESS; } @@ -323,6 +351,10 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx) { ctx->use_kerberos = true; + + cli_credentials_set_kerberos_state(ctx->creds, + CRED_USE_KERBEROS_REQUIRED); + return NET_API_STATUS_SUCCESS; } @@ -331,7 +363,14 @@ NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx) NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx) { + uint32_t gensec_features; + ctx->use_ccache = true; + + gensec_features = cli_credentials_get_gensec_features(ctx->creds); + gensec_features |= GENSEC_FEATURE_NTLM_CCACHE; + cli_credentials_set_gensec_features(ctx->creds, gensec_features); + return NET_API_STATUS_SUCCESS; } |