summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-12-11 21:23:40 +0100
committerGünther Deschner <gd@samba.org>2007-12-21 15:29:09 +0100
commit67aa44e7a230cb3cf35c184692bf5249d6d424cf (patch)
tree31030bd512b9523ca8ec2a7fb6367952cc293c78
parent1b5c1ae7424ba2fad857adf3701a5809ba3b27fe (diff)
downloadsamba-67aa44e7a230cb3cf35c184692bf5249d6d424cf.tar.gz
samba-67aa44e7a230cb3cf35c184692bf5249d6d424cf.tar.bz2
samba-67aa44e7a230cb3cf35c184692bf5249d6d424cf.zip
Split NetJoinDomain() into NetJoinDomainRemote() and the unsupported
NetJoinDomainLocal(). Guenther (This used to be commit d2f21ce6727ec9e4df67989db07b48470d0790a4)
-rw-r--r--source3/lib/netapi/joindomain.c96
1 files changed, 73 insertions, 23 deletions
diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c
index 6da4548f05..1b951d7a5c 100644
--- a/source3/lib/netapi/joindomain.c
+++ b/source3/lib/netapi/joindomain.c
@@ -24,14 +24,25 @@ extern const char *opt_user_name;
extern const char *opt_workgroup;
extern const char *opt_password;
-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 NetJoinDomainLocal(TALLOC_CTX *mem_ctx,
+ const char *server_name,
+ const char *domain_name,
+ const char *account_ou,
+ const char *Account,
+ const char *password,
+ uint32_t join_flags)
+{
+ return WERR_NOT_SUPPORTED;
+}
+
+static WERROR NetJoinDomainRemote(TALLOC_CTX *mem_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;
struct cli_state *cli = NULL;
struct rpc_pipe_client *pipe_cli = NULL;
struct wkssvc_PasswordBuffer encrypted_password;
@@ -41,22 +52,6 @@ WERROR NetJoinDomain(const char *server_name,
ZERO_STRUCT(encrypted_password);
- mem_ctx = talloc_init("NetJoinDomain");
- if (!mem_ctx) {
- werr = WERR_NOMEM;
- goto done;
- }
-
- if (!server_name || is_myname_or_ipaddr(server_name)) {
- werr = WERR_NOT_SUPPORTED;
- goto done;
- }
-
- if (!domain_name) {
- werr = WERR_INVALID_PARAM;
- goto done;
- }
-
status = cli_full_connection(&cli, NULL, server_name,
NULL, 0,
"IPC$", "IPC",
@@ -101,6 +96,61 @@ WERROR NetJoinDomain(const char *server_name,
cli_set_timeout(cli, old_timeout);
cli_shutdown(cli);
}
+
+ 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)
+{
+ TALLOC_CTX *mem_ctx = NULL;
+ WERROR werr;
+
+ mem_ctx = talloc_init("NetJoinDomain");
+ if (!mem_ctx) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
+
+ if (!domain_name) {
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+
+ if (!server_name || is_myname_or_ipaddr(server_name)) {
+
+ const char *dc = NULL;
+
+ /* FIXME: DsGetDcName */
+ if (server_name == NULL) {
+ dc = domain_name;
+ } else {
+ dc = domain_name;
+ }
+
+ werr = NetJoinDomainLocal(mem_ctx,
+ dc,
+ domain_name,
+ account_ou,
+ Account,
+ password,
+ join_flags);
+
+ goto done;
+ }
+
+ werr = NetJoinDomainRemote(mem_ctx,
+ server_name,
+ domain_name,
+ account_ou,
+ Account,
+ password,
+ join_flags);
+done:
TALLOC_FREE(mem_ctx);
return werr;