diff options
-rw-r--r-- | source3/lib/netapi/getdc.c | 30 | ||||
-rw-r--r-- | source3/lib/netapi/joindomain.c | 57 | ||||
-rw-r--r-- | source3/lib/netapi/serverinfo.c | 43 |
3 files changed, 114 insertions, 16 deletions
diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index 484af04a55..1084ddc3c8 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -22,6 +22,9 @@ #include "lib/netapi/netapi.h" #include "libnet/libnet.h" +/******************************************************************** +********************************************************************/ + static WERROR NetGetDCNameLocal(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -30,6 +33,9 @@ static WERROR NetGetDCNameLocal(struct libnetapi_ctx *ctx, return WERR_NOT_SUPPORTED; } +/******************************************************************** +********************************************************************/ + static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -73,6 +79,9 @@ static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx, return werr; } +/******************************************************************** +********************************************************************/ + static WERROR libnetapi_NetGetDCName(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -91,6 +100,10 @@ static WERROR libnetapi_NetGetDCName(struct libnetapi_ctx *ctx, buffer); } +/**************************************************************** + NetGetDCName +****************************************************************/ + NET_API_STATUS NetGetDCName(const char *server_name, const char *domain_name, uint8_t **buffer) @@ -112,9 +125,12 @@ NET_API_STATUS NetGetDCName(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } +/******************************************************************** +********************************************************************/ + static WERROR NetGetAnyDCNameLocal(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -123,6 +139,9 @@ static WERROR NetGetAnyDCNameLocal(struct libnetapi_ctx *ctx, return WERR_NOT_SUPPORTED; } +/******************************************************************** +********************************************************************/ + static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -170,6 +189,9 @@ static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx *ctx, } +/******************************************************************** +********************************************************************/ + static WERROR libnetapi_NetGetAnyDCName(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -188,6 +210,10 @@ static WERROR libnetapi_NetGetAnyDCName(struct libnetapi_ctx *ctx, buffer); } +/**************************************************************** + NetGetAnyDCName +****************************************************************/ + NET_API_STATUS NetGetAnyDCName(const char *server_name, const char *domain_name, uint8_t **buffer) @@ -209,5 +235,5 @@ NET_API_STATUS NetGetAnyDCName(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index b268e41a2a..43662b3ffa 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -22,6 +22,9 @@ #include "lib/netapi/netapi.h" #include "libnet/libnet.h" +/**************************************************************** +****************************************************************/ + static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, const char *server_name, const char *domain_name, @@ -52,6 +55,8 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, status = dsgetdcname(mem_ctx, NULL, domain_name, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { + libnetapi_set_error_string(mem_ctx, + "%s", get_friendly_nt_error_msg(status)); return ntstatus_to_werror(status); } r->in.dc_name = talloc_strdup(mem_ctx, @@ -79,13 +84,16 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, werr = libnet_Join(mem_ctx, r); if (!W_ERROR_IS_OK(werr) && r->out.error_string) { - libnetapi_set_error_string(mem_ctx, r->out.error_string); + libnetapi_set_error_string(mem_ctx, "%s", r->out.error_string); } TALLOC_FREE(r); return werr; } +/**************************************************************** +****************************************************************/ + static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -149,6 +157,9 @@ static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx, return werr; } +/**************************************************************** +****************************************************************/ + static WERROR libnetapi_NetJoinDomain(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -181,6 +192,10 @@ static WERROR libnetapi_NetJoinDomain(struct libnetapi_ctx *ctx, join_flags); } +/**************************************************************** + NetJoinDomain +****************************************************************/ + NET_API_STATUS NetJoinDomain(const char *server_name, const char *domain_name, const char *account_ou, @@ -208,9 +223,12 @@ NET_API_STATUS NetJoinDomain(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, const char *server_name, const char *account, @@ -232,7 +250,6 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, r->in.dc_name = talloc_strdup(mem_ctx, server_name); W_ERROR_HAVE_NO_MEMORY(r->in.dc_name); } else { - NTSTATUS status; const char *domain = NULL; struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; @@ -247,6 +264,8 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, status = dsgetdcname(mem_ctx, NULL, domain, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { + libnetapi_set_error_string(mem_ctx, + "%s", get_friendly_nt_error_msg(status)); return ntstatus_to_werror(status); } r->in.dc_name = talloc_strdup(mem_ctx, @@ -266,13 +285,22 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, r->in.unjoin_flags = unjoin_flags; r->in.modify_config = true; + r->in.debug = true; r->in.domain_sid = &domain_sid; - return libnet_Unjoin(mem_ctx, r); + werr = libnet_Unjoin(mem_ctx, r); + if (!W_ERROR_IS_OK(werr) && r->out.error_string) { + libnetapi_set_error_string(mem_ctx, "%s", r->out.error_string); + } + TALLOC_FREE(r); + return werr; } +/**************************************************************** +****************************************************************/ + static WERROR NetUnjoinDomainRemote(struct libnetapi_ctx *ctx, const char *server_name, const char *account, @@ -335,6 +363,9 @@ static WERROR NetUnjoinDomainRemote(struct libnetapi_ctx *ctx, return werr; } +/**************************************************************** +****************************************************************/ + static WERROR libnetapi_NetUnjoinDomain(struct libnetapi_ctx *ctx, const char *server_name, const char *account, @@ -357,6 +388,10 @@ static WERROR libnetapi_NetUnjoinDomain(struct libnetapi_ctx *ctx, unjoin_flags); } +/**************************************************************** + NetUnjoinDomain +****************************************************************/ + NET_API_STATUS NetUnjoinDomain(const char *server_name, const char *account, const char *password, @@ -380,9 +415,12 @@ NET_API_STATUS NetUnjoinDomain(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + static WERROR NetGetJoinInformationRemote(struct libnetapi_ctx *ctx, const char *server_name, const char **name_buffer, @@ -431,6 +469,9 @@ static WERROR NetGetJoinInformationRemote(struct libnetapi_ctx *ctx, return werr; } +/**************************************************************** +****************************************************************/ + static WERROR NetGetJoinInformationLocal(struct libnetapi_ctx *ctx, const char *server_name, const char **name_buffer, @@ -478,6 +519,10 @@ static WERROR libnetapi_NetGetJoinInformation(struct libnetapi_ctx *ctx, name_type); } +/**************************************************************** + NetGetJoinInformation +****************************************************************/ + NET_API_STATUS NetGetJoinInformation(const char *server_name, const char **name_buffer, uint16_t *name_type) @@ -499,5 +544,5 @@ NET_API_STATUS NetGetJoinInformation(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index 6cd074615b..7fa166e411 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -22,6 +22,9 @@ #include "lib/netapi/netapi.h" #include "libnet/libnet.h" +/**************************************************************** +****************************************************************/ + static WERROR NetServerGetInfoLocal_1005(struct libnetapi_ctx *ctx, uint8_t **buffer) { @@ -36,6 +39,9 @@ static WERROR NetServerGetInfoLocal_1005(struct libnetapi_ctx *ctx, return WERR_OK; } +/**************************************************************** +****************************************************************/ + static WERROR NetServerGetInfoLocal(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -51,6 +57,9 @@ static WERROR NetServerGetInfoLocal(struct libnetapi_ctx *ctx, return WERR_UNKNOWN_LEVEL; } +/**************************************************************** +****************************************************************/ + static WERROR NetServerGetInfoRemote(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -102,6 +111,9 @@ static WERROR NetServerGetInfoRemote(struct libnetapi_ctx *ctx, return werr; } +/**************************************************************** +****************************************************************/ + static WERROR libnetapi_NetServerGetInfo(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -121,6 +133,10 @@ static WERROR libnetapi_NetServerGetInfo(struct libnetapi_ctx *ctx, } +/**************************************************************** + NetServerGetInfo +****************************************************************/ + NET_API_STATUS NetServerGetInfo(const char *server_name, uint32_t level, uint8_t **buffer) @@ -142,17 +158,18 @@ NET_API_STATUS NetServerGetInfo(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx, uint8_t *buffer, uint32_t *parm_error) { WERROR werr; struct libnet_conf_ctx *conf_ctx; - TALLOC_CTX *mem_ctx; - struct srvsvc_NetSrvInfo1005 *info1005; if (!buffer) { @@ -171,8 +188,7 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx, return WERR_NOT_SUPPORTED; } - mem_ctx = talloc_stackframe(); - werr = libnet_conf_open(mem_ctx, &conf_ctx); + werr = libnet_conf_open(ctx, &conf_ctx); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -181,12 +197,14 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx, "server string", info1005->comment); -done: + done: libnet_conf_close(conf_ctx); - TALLOC_FREE(mem_ctx); return werr; } +/**************************************************************** +****************************************************************/ + static WERROR NetServerSetInfoLocal(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -203,6 +221,9 @@ static WERROR NetServerSetInfoLocal(struct libnetapi_ctx *ctx, return WERR_UNKNOWN_LEVEL; } +/**************************************************************** +****************************************************************/ + static WERROR NetServerSetInfoRemote(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -263,6 +284,9 @@ static WERROR NetServerSetInfoRemote(struct libnetapi_ctx *ctx, return werr; } +/**************************************************************** +****************************************************************/ + static WERROR libnetapi_NetServerSetInfo(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -284,6 +308,9 @@ static WERROR libnetapi_NetServerSetInfo(struct libnetapi_ctx *ctx, parm_error); } +/**************************************************************** + NetServerSetInfo +****************************************************************/ NET_API_STATUS NetServerSetInfo(const char *server_name, uint32_t level, @@ -308,5 +335,5 @@ NET_API_STATUS NetServerSetInfo(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } |