s3:lib/netapi: add libnetapi_get_creds()
authorStefan Metzmacher <metze@samba.org>
Tue, 5 Mar 2024 16:38:25 +0000 (17:38 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 14 May 2024 10:18:31 +0000 (10:18 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/lib/netapi/netapi.c
source3/lib/netapi/netapi.h

index 9c049a841114fb2ee545b7409c12db121620bb80..0d8f0f35da018d924c0475e3c5e7bd45983f5bfc 100644 (file)
@@ -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;
+}
+
 /****************************************************************
 ****************************************************************/
 
index 660a7766bd67a9628b231ecd585882d62549d543..b9bf4a09804093f187900a43632386a055ef805c 100644 (file)
@@ -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);