diff options
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r-- | source3/lib/netapi/examples/getdc/getdc.c | 2 | ||||
-rw-r--r-- | source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c | 8 | ||||
-rw-r--r-- | source3/lib/netapi/examples/netdomjoin/netdomjoin.c | 4 | ||||
-rw-r--r-- | source3/lib/netapi/joindomain.c | 4 | ||||
-rw-r--r-- | source3/lib/netapi/netapi.c | 21 | ||||
-rw-r--r-- | source3/lib/netapi/netapi.h | 15 |
6 files changed, 39 insertions, 15 deletions
diff --git a/source3/lib/netapi/examples/getdc/getdc.c b/source3/lib/netapi/examples/getdc/getdc.c index 4f5c5332d5..cdd4d0b3b4 100644 --- a/source3/lib/netapi/examples/getdc/getdc.c +++ b/source3/lib/netapi/examples/getdc/getdc.c @@ -46,7 +46,7 @@ int main(int argc, char **argv) status = NetGetDCName(argv[1], argv[2], &buffer); if (status != 0) { - printf("GetDcName failed with: %s\n", libnetapi_errstr(ctx, status)); + printf("GetDcName failed with: %s\n", libnetapi_errstr(status)); } else { printf("%s\n", (char *)buffer); } diff --git a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c index 4a3588e9ab..9dc2a18138 100644 --- a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c +++ b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c @@ -147,13 +147,13 @@ static void callback_apply_description_change(GtkWidget *widget, status = NetServerSetInfo(NULL, 1005, (uint8_t *)&info1005, &parm_err); if (status) { debug("NetServerSetInfo failed with: %s\n", - libnetapi_errstr(state->ctx, status)); + libnetapi_errstr(status)); dialog = gtk_message_dialog_new(GTK_WINDOW(state->window_main), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Failed to change computer description: %s.", - libnetapi_errstr(state->ctx, status)); + libnetapi_errstr(status)); g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog); @@ -439,7 +439,7 @@ static void callback_do_join(GtkWidget *widget, state->password, unjoin_flags); if (status != 0) { - err_str = libnetapi_errstr(state->ctx, status); + err_str = libnetapi_errstr(status); g_print("callback_do_join: failed to unjoin (%s)\n", err_str); @@ -463,7 +463,7 @@ static void callback_do_join(GtkWidget *widget, state->password, join_flags); if (status != 0) { - err_str = libnetapi_errstr(state->ctx, status); + err_str = libnetapi_errstr(status); g_print("callback_do_join: failed to join (%s)\n", err_str); dialog = gtk_message_dialog_new(GTK_WINDOW(state->window_parent), diff --git a/source3/lib/netapi/examples/netdomjoin/netdomjoin.c b/source3/lib/netapi/examples/netdomjoin/netdomjoin.c index a0ac0b1e56..29f66a17a2 100644 --- a/source3/lib/netapi/examples/netdomjoin/netdomjoin.c +++ b/source3/lib/netapi/examples/netdomjoin/netdomjoin.c @@ -105,9 +105,9 @@ int main(int argc, char **argv) join_flags); if (status != 0) { const char *errstr = NULL; - errstr = libnetapi_get_error_string(ctx); + errstr = libnetapi_get_error_string(ctx, status); if (!errstr) { - errstr = libnetapi_errstr(ctx, status); + errstr = libnetapi_errstr(status); } printf("Join failed with: %s\n", errstr); } else { diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index e4fb63eebb..b268e41a2a 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -49,7 +49,7 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED | DS_WRITABLE_REQUIRED | DS_RETURN_DNS_NAME; - status = DsGetDcName(mem_ctx, NULL, domain_name, + status = dsgetdcname(mem_ctx, NULL, domain_name, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { return ntstatus_to_werror(status); @@ -244,7 +244,7 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, } else { domain = lp_workgroup(); } - status = DsGetDcName(mem_ctx, NULL, domain, + status = dsgetdcname(mem_ctx, NULL, domain, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { return ntstatus_to_werror(status); 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..274a167d53 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -20,6 +20,16 @@ #ifndef __LIB_NETAPI_H__ #define __LIB_NETAPI_H__ +/**************************************************************** + include some basic headers +****************************************************************/ + +#include <inttypes.h> + +/**************************************************************** + NET_API_STATUS +****************************************************************/ + #define NET_API_STATUS uint32_t #define NET_API_STATUS_SUCCESS 0 @@ -46,9 +56,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); + /**************************************************************** ****************************************************************/ |