summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-11-16 13:06:19 +0100
committerStefan Metzmacher <metze@samba.org>2011-11-29 09:21:25 +0100
commitfe69c589e8f3196f2f478adf611bc78a0ea66f50 (patch)
tree74248c74ee21cf985d9d7d6d4b753285ca8e6e63
parent677f5246f16c7c2dd4b0006202b2c7ec9f8c3520 (diff)
downloadsamba-fe69c589e8f3196f2f478adf611bc78a0ea66f50.tar.gz
samba-fe69c589e8f3196f2f478adf611bc78a0ea66f50.tar.bz2
samba-fe69c589e8f3196f2f478adf611bc78a0ea66f50.zip
s4:libnet: make it possible to join with a given machine password
metze
-rw-r--r--source4/libnet/libnet_join.c18
-rw-r--r--source4/libnet/libnet_join.h2
2 files changed, 16 insertions, 4 deletions
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 {