summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-12-18 02:54:18 +0100
committerGünther Deschner <gd@samba.org>2007-12-21 15:29:10 +0100
commitdab660b9dc42b9e5817e59de4c97009796548b92 (patch)
tree6b69902c48c928c7352f2cc2aedbb12df1ee57eb /source3
parent62b3fd209d65caba36595dfbcde83fd74f4047b7 (diff)
downloadsamba-dab660b9dc42b9e5817e59de4c97009796548b92.tar.gz
samba-dab660b9dc42b9e5817e59de4c97009796548b92.tar.bz2
samba-dab660b9dc42b9e5817e59de4c97009796548b92.zip
Move NetJoinDomain and friends to NET_API_STATUS and the static libnetapi_ctx.
Guenther (This used to be commit e640c3a4a7695613e9e619516befbaf3d44ecb10)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/netapi/joindomain.c126
-rw-r--r--source3/lib/netapi/joindomain.h26
-rw-r--r--source3/utils/net_dom.c16
3 files changed, 127 insertions, 41 deletions
diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c
index 67e53d4391..a0d3319998 100644
--- a/source3/lib/netapi/joindomain.c
+++ b/source3/lib/netapi/joindomain.c
@@ -18,9 +18,11 @@
*/
#include "includes.h"
-#include "lib/netapi/joindomain.h"
-static WERROR NetJoinDomainLocal(TALLOC_CTX *mem_ctx,
+#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,
const char *account_ou,
@@ -65,7 +67,7 @@ static WERROR NetJoinDomainLocal(TALLOC_CTX *mem_ctx,
return libnet_Join(mem_ctx, r);
}
-static WERROR NetJoinDomainRemote(TALLOC_CTX *mem_ctx,
+static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain_name,
const char *account_ou,
@@ -105,7 +107,7 @@ static WERROR NetJoinDomainRemote(TALLOC_CTX *mem_ctx,
};
if (password) {
- encode_wkssvc_join_password_buffer(mem_ctx,
+ encode_wkssvc_join_password_buffer(ctx,
password,
&cli->user_session_key,
&encrypted_password);
@@ -113,7 +115,7 @@ static WERROR NetJoinDomainRemote(TALLOC_CTX *mem_ctx,
old_timeout = cli_set_timeout(cli, 60000);
- status = rpccli_wkssvc_NetrJoinDomain2(pipe_cli, mem_ctx,
+ status = rpccli_wkssvc_NetrJoinDomain2(pipe_cli, ctx,
server_name, domain_name,
account_ou, Account,
&encrypted_password,
@@ -132,12 +134,13 @@ static WERROR NetJoinDomainRemote(TALLOC_CTX *mem_ctx,
return werr;
}
-WERROR NetJoinDomain(const char *server_name,
- const char *domain_name,
- const char *account_ou,
- const char *Account,
- const char *password,
- uint32_t join_flags)
+static WERROR libnetapi_NetJoinDomain(struct libnetapi_ctx *ctx,
+ const char *server_name,
+ const char *domain_name,
+ const char *account_ou,
+ const char *Account,
+ const char *password,
+ uint32_t join_flags)
{
TALLOC_CTX *mem_ctx = NULL;
WERROR werr;
@@ -164,7 +167,7 @@ WERROR NetJoinDomain(const char *server_name,
dc = domain_name;
}
- werr = NetJoinDomainLocal(mem_ctx,
+ werr = NetJoinDomainLocal(ctx,
dc,
domain_name,
account_ou,
@@ -175,7 +178,7 @@ WERROR NetJoinDomain(const char *server_name,
goto done;
}
- werr = NetJoinDomainRemote(mem_ctx,
+ werr = NetJoinDomainRemote(ctx,
server_name,
domain_name,
account_ou,
@@ -188,10 +191,41 @@ done:
return werr;
}
-WERROR NetUnjoinDomain(const char *server_name,
- const char *account,
- const char *password,
- uint32_t unjoin_flags)
+NET_API_STATUS NetJoinDomain(const char *server_name,
+ const char *domain_name,
+ const char *account_ou,
+ const char *Account,
+ const char *password,
+ uint32_t join_flags)
+{
+ struct libnetapi_ctx *ctx = NULL;
+ NET_API_STATUS status;
+ WERROR werr;
+
+ status = libnetapi_getctx(&ctx);
+ if (status != 0) {
+ return status;
+ }
+
+ werr = libnetapi_NetJoinDomain(ctx,
+ server_name,
+ domain_name,
+ account_ou,
+ Account,
+ password,
+ join_flags);
+ if (!W_ERROR_IS_OK(werr)) {
+ return W_ERROR_V(werr);
+ }
+
+ return 0;
+}
+
+static WERROR libnetapi_NetUnjoinDomain(struct libnetapi_ctx *ctx,
+ const char *server_name,
+ const char *account,
+ const char *password,
+ uint32_t unjoin_flags)
{
TALLOC_CTX *mem_ctx = NULL;
struct cli_state *cli = NULL;
@@ -266,9 +300,37 @@ WERROR NetUnjoinDomain(const char *server_name,
return werr;
}
-WERROR NetGetJoinInformation(const char *server_name,
- const char **name_buffer,
- uint16_t *name_type)
+NET_API_STATUS NetUnjoinDomain(const char *server_name,
+ const char *account,
+ const char *password,
+ uint32_t unjoin_flags)
+{
+ struct libnetapi_ctx *ctx = NULL;
+ NET_API_STATUS status;
+ WERROR werr;
+
+ status = libnetapi_getctx(&ctx);
+ if (status != 0) {
+ return status;
+ }
+
+ werr = libnetapi_NetUnjoinDomain(ctx,
+ server_name,
+ account,
+ password,
+ unjoin_flags);
+ if (!W_ERROR_IS_OK(werr)) {
+ return W_ERROR_V(werr);
+ }
+
+ return 0;
+}
+
+
+WERROR libnetapi_NetGetJoinInformation(struct libnetapi_ctx *ctx,
+ const char *server_name,
+ const char **name_buffer,
+ uint16_t *name_type)
{
TALLOC_CTX *mem_ctx = NULL;
struct cli_state *cli = NULL;
@@ -346,3 +408,27 @@ WERROR NetGetJoinInformation(const char *server_name,
return werr;
}
+
+NET_API_STATUS NetGetJoinInformation(const char *server_name,
+ const char **name_buffer,
+ uint16_t *name_type)
+{
+ struct libnetapi_ctx *ctx = NULL;
+ NET_API_STATUS status;
+ WERROR werr;
+
+ status = libnetapi_getctx(&ctx);
+ if (status != 0) {
+ return status;
+ }
+
+ werr = libnetapi_NetGetJoinInformation(ctx,
+ server_name,
+ name_buffer,
+ name_type);
+ if (!W_ERROR_IS_OK(werr)) {
+ return W_ERROR_V(werr);
+ }
+
+ return 0;
+}
diff --git a/source3/lib/netapi/joindomain.h b/source3/lib/netapi/joindomain.h
index 73d2ec3d32..b72bc9aecb 100644
--- a/source3/lib/netapi/joindomain.h
+++ b/source3/lib/netapi/joindomain.h
@@ -20,18 +20,18 @@
#ifndef __LIB_NETAPI_JOINDOMAIN_H__
#define __LIB_NETAPI_JOINDOMAIN_H__
-WERROR NetJoinDomain(const char *server,
- const char *domain,
- const char *account_ou,
- const char *account,
- const char *password,
- uint32_t join_options);
-WERROR NetUnjoinDomain(const char *server_name,
- const char *account,
- const char *password,
- uint32_t unjoin_flags);
-WERROR NetGetJoinInformation(const char *server_name,
- const char **name_buffer,
- uint16_t *name_type);
+NET_API_STATUS NetJoinDomain(const char *server,
+ const char *domain,
+ const char *account_ou,
+ const char *account,
+ const char *password,
+ uint32_t join_options);
+NET_API_STATUS NetUnjoinDomain(const char *server_name,
+ const char *account,
+ const char *password,
+ uint32_t unjoin_flags);
+NET_API_STATUS NetGetJoinInformation(const char *server_name,
+ const char **name_buffer,
+ uint16_t *name_type);
#endif
diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c
index fd386c95a8..7b5f562727 100644
--- a/source3/utils/net_dom.c
+++ b/source3/utils/net_dom.c
@@ -19,7 +19,7 @@
#include "includes.h"
#include "utils/net.h"
-#include "lib/netapi/joindomain.h"
+#include "lib/netapi/netapi.h"
static int net_dom_usage(int argc, const char **argv)
{
@@ -51,7 +51,7 @@ static int net_dom_unjoin(int argc, const char **argv)
struct cli_state *cli = NULL;
bool reboot = false;
NTSTATUS status;
- WERROR werr;
+ NET_API_STATUS werr;
int ret = -1;
int i;
@@ -90,9 +90,9 @@ static int net_dom_unjoin(int argc, const char **argv)
}
werr = NetUnjoinDomain(server_name, account, password, unjoin_flags);
- if (!W_ERROR_IS_OK(werr)) {
+ if (werr != 0) {
printf("Failed to unjoin domain: %s\n",
- get_friendly_nt_error_msg(werror_to_ntstatus(werr)));
+ get_friendly_nt_error_msg(werror_to_ntstatus(W_ERROR(werr))));
goto done;
}
@@ -136,7 +136,7 @@ static int net_dom_join(int argc, const char **argv)
struct cli_state *cli = NULL;
bool reboot = false;
NTSTATUS status;
- WERROR werr;
+ NET_API_STATUS werr;
int ret = -1;
int i;
@@ -194,10 +194,10 @@ static int net_dom_join(int argc, const char **argv)
werr = NetJoinDomain(server_name, domain_name, account_ou,
Account, password, join_flags);
- if (!W_ERROR_IS_OK(werr)) {
+ if (werr != 0) {
printf("Failed to join domain: %s (WERROR: %s)\n",
- get_friendly_nt_error_msg(werror_to_ntstatus(werr)),
- dos_errstr(werr));
+ get_friendly_nt_error_msg(werror_to_ntstatus(W_ERROR(werr))),
+ dos_errstr(W_ERROR(werr)));
goto done;
}