summaryrefslogtreecommitdiff
path: root/source3/lib/netapi
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2021-03-18 09:59:08 +0100
committerGünther Deschner <gd@samba.org>2021-03-24 00:55:32 +0000
commitc9222ab838844bca698a64b2125a19244ee6f008 (patch)
tree65bdb948dd9a5d0503e9cd0196e465b6306201dc /source3/lib/netapi
parent17283de8fd967fbfe68f64b0cacb1e7aadf559fc (diff)
downloadsamba-c9222ab838844bca698a64b2125a19244ee6f008.tar.gz
s3:netapi: Implement public libnetapi_get_(username|password) functions
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.c46
-rw-r--r--source3/lib/netapi/netapi.h6
-rw-r--r--source3/lib/netapi/netapi_private.h2
3 files changed, 52 insertions, 2 deletions
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c
index fb8b4bc6113..820dd8ac6e0 100644
--- a/source3/lib/netapi/netapi.c
+++ b/source3/lib/netapi/netapi.c
@@ -227,6 +227,52 @@ NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx,
/****************************************************************
****************************************************************/
+/**
+ * @brief Get the username of the libnet context
+ *
+ * @param[in] ctx The netapi context
+ *
+ * @param[in] username A pointer to hold the username.
+ *
+ * @return 0 on success, an werror code otherwise.
+ */
+NET_API_STATUS libnetapi_get_username(struct libnetapi_ctx *ctx,
+ const char **username)
+{
+ if (ctx == NULL) {
+ return W_ERROR_V(WERR_INVALID_PARAMETER);
+ }
+
+ if (username != NULL) {
+ *username = ctx->username;
+ }
+
+ return NET_API_STATUS_SUCCESS;
+}
+
+/**
+ * @brief Get the password of the libnet context
+ *
+ * @param[in] ctx The netapi context
+ *
+ * @param[in] password A pointer to hold the password.
+ *
+ * @return 0 on success, an werror code otherwise.
+ */
+NET_API_STATUS libnetapi_get_password(struct libnetapi_ctx *ctx,
+ const char **password)
+{
+ if (ctx == NULL) {
+ return W_ERROR_V(WERR_INVALID_PARAMETER);
+ }
+
+ if (password != NULL) {
+ *password = ctx->password;
+ }
+
+ return NET_API_STATUS_SUCCESS;
+}
+
NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
const char *username)
{
diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h
index 6fc539c8f6f..b7fdb752a79 100644
--- a/source3/lib/netapi/netapi.h
+++ b/source3/lib/netapi/netapi.h
@@ -1391,6 +1391,12 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
+NET_API_STATUS libnetapi_get_username(struct libnetapi_ctx *ctx,
+ const char **username);
+
+NET_API_STATUS libnetapi_get_password(struct libnetapi_ctx *ctx,
+ const char **password);
+
/****************************************************************
****************************************************************/
diff --git a/source3/lib/netapi/netapi_private.h b/source3/lib/netapi/netapi_private.h
index 4d028251c43..998d2b2b634 100644
--- a/source3/lib/netapi/netapi_private.h
+++ b/source3/lib/netapi/netapi_private.h
@@ -53,8 +53,6 @@ struct libnetapi_private_ctx {
struct messaging_context *msg_ctx;
};
-NET_API_STATUS libnetapi_get_password(struct libnetapi_ctx *ctx, char **password);
-NET_API_STATUS libnetapi_get_username(struct libnetapi_ctx *ctx, char **username);
NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx,
const char *format, ...)
PRINTF_ATTRIBUTE(2,3);