summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/netapi/netapi.c21
-rw-r--r--source3/lib/netapi/netapi.h5
2 files changed, 20 insertions, 6 deletions
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c
index d4cb3a9fe2..ce00054e6e 100644
--- a/source3/lib/netapi/netapi.c
+++ b/source3/lib/netapi/netapi.c
@@ -192,8 +192,7 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
/****************************************************************
****************************************************************/
-const char *libnetapi_errstr(struct libnetapi_ctx *ctx,
- NET_API_STATUS status)
+const char *libnetapi_errstr(NET_API_STATUS status)
{
if (status & 0xc0000000) {
return get_friendly_nt_error_msg(NT_STATUS(status));
@@ -220,9 +219,23 @@ NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx,
/****************************************************************
****************************************************************/
-const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx)
+const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
+ NET_API_STATUS status)
{
- return ctx->error_string;
+ struct libnetapi_ctx *tmp_ctx = ctx;
+
+ if (!tmp_ctx) {
+ status = libnetapi_getctx(&tmp_ctx);
+ if (status != 0) {
+ return NULL;
+ }
+ }
+
+ if (tmp_ctx->error_string) {
+ return tmp_ctx->error_string;
+ }
+
+ return libnetapi_errstr(status);
}
/****************************************************************
diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h
index 4a40b32fc9..61cece119f 100644
--- a/source3/lib/netapi/netapi.h
+++ b/source3/lib/netapi/netapi.h
@@ -46,9 +46,10 @@ NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, char **debugl
NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *username);
NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx, const char *password);
NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, const char *workgroup);
-const char *libnetapi_errstr(struct libnetapi_ctx *ctx, NET_API_STATUS status);
+const char *libnetapi_errstr(NET_API_STATUS status);
NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *error_string);
-const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx);
+const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx, NET_API_STATUS status);
+
/****************************************************************
****************************************************************/