From fe69c589e8f3196f2f478adf611bc78a0ea66f50 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 16 Nov 2011 13:06:19 +0100 Subject: s4:libnet: make it possible to join with a given machine password metze --- source4/libnet/libnet_join.c | 18 ++++++++++++++---- source4/libnet/libnet_join.h | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'source4/libnet') diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c index 0ed14a54e8..09774038fb 100644 --- a/source4/libnet/libnet_join.c +++ b/source4/libnet/libnet_join.c @@ -821,10 +821,19 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru if (NT_STATUS_IS_OK(status)) { policy_min_pw_len = pwp.out.info->min_password_length; } - - /* Grab a password of that minimum length */ - - password_str = generate_random_password(tmp_ctx, MAX(8, policy_min_pw_len), 255); + + if (r->in.account_pass != NULL) { + password_str = talloc_strdup(tmp_ctx, r->in.account_pass); + } else { + /* Grab a password of that minimum length */ + password_str = generate_random_password(tmp_ctx, + MAX(8, policy_min_pw_len), 255); + } + if (!password_str) { + r->out.error_string = NULL; + talloc_free(tmp_ctx); + return NT_STATUS_NO_MEMORY; + } /* set full_name and reset flags */ ZERO_STRUCT(u_info21); @@ -945,6 +954,7 @@ NTSTATUS libnet_Join_member(struct libnet_context *ctx, r2->in.level = LIBNET_JOINDOMAIN_AUTOMATIC; r2->in.acct_type = acct_type; r2->in.recreate_account = false; + r2->in.account_pass = r->in.account_pass; status = libnet_JoinDomain(ctx, r2, r2); if (!NT_STATUS_IS_OK(status)) { r->out.error_string = talloc_steal(mem_ctx, r2->out.error_string); diff --git a/source4/libnet/libnet_join.h b/source4/libnet/libnet_join.h index 6acf374b38..89f4d291c7 100644 --- a/source4/libnet/libnet_join.h +++ b/source4/libnet/libnet_join.h @@ -43,6 +43,7 @@ struct libnet_JoinDomain { enum libnet_JoinDomain_level level; uint32_t acct_type; bool recreate_account; + const char *account_pass; } in; struct { @@ -68,6 +69,7 @@ struct libnet_Join_member { const char *domain_name; const char *netbios_name; enum libnet_Join_level level; + const char *account_pass; } in; struct { -- cgit