s3:libnet_join: make use of trust_pw_new_value()
authorStefan Metzmacher <metze@samba.org>
Tue, 23 Aug 2016 10:09:57 +0000 (12:09 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 21 Feb 2017 15:09:22 +0000 (16:09 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12262

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/libnet/libnet_join.c

index 8275a7cc566fa4a727592bd0579ad8f6b26721bf..4d00ef654132823f77a9135e54d7b0ffdc0d98e5 100644 (file)
@@ -1138,9 +1138,11 @@ static NTSTATUS libnet_join_joindomain_rpc_unsecure(TALLOC_CTX *mem_ctx,
        }
 
        if (!r->in.machine_password) {
-               r->in.machine_password = generate_random_password(mem_ctx,
-                               DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH,
-                               DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
+               int security = r->in.ads ? SEC_ADS : SEC_DOMAIN;
+
+               r->in.machine_password = trust_pw_new_value(mem_ctx,
+                                               r->in.secure_channel_type,
+                                               security);
                if (r->in.machine_password == NULL) {
                        TALLOC_FREE(frame);
                        return NT_STATUS_NO_MEMORY;
@@ -1233,9 +1235,11 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
        }
 
        if (!r->in.machine_password) {
-               r->in.machine_password = generate_random_password(mem_ctx,
-                               DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH,
-                               DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
+               int security = r->in.ads ? SEC_ADS : SEC_DOMAIN;
+
+               r->in.machine_password = trust_pw_new_value(mem_ctx,
+                                               r->in.secure_channel_type,
+                                               security);
                NT_STATUS_HAVE_NO_MEMORY(r->in.machine_password);
        }