s4:libnet: make it possible to join with a given machine password
authorStefan Metzmacher <metze@samba.org>
Wed, 16 Nov 2011 12:06:19 +0000 (13:06 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 29 Nov 2011 08:21:25 +0000 (09:21 +0100)
metze

source4/libnet/libnet_join.c
source4/libnet/libnet_join.h

index 0ed14a54e8ea58fa8ef5b4952663072bced85932..09774038fb3d3131e9ed3389df7f7947e03c5f70 100644 (file)
@@ -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);
index 6acf374b3838c46384eaece8355e0e4ed118507c..89f4d291c7fc850c568df96fdae0dc6d065016b0 100644 (file)
@@ -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 {