From 7448b93a2e7a21fe2233706fc7b7ced1e98a41d3 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Dec 2005 09:58:51 +0000 Subject: r12430: Clarify libnet_join code. Add/fix comments. Andrew Bartlett (This used to be commit a3372935eee12c99d8c4a29eda45e8d0f1039896) --- source4/libnet/libnet_join.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/libnet') diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c index 62feb8b544..28d12247c9 100644 --- a/source4/libnet/libnet_join.c +++ b/source4/libnet/libnet_join.c @@ -834,7 +834,7 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru od.in.sid = domain_sid; od.out.domain_handle = &d_handle; - /* 4. do a samr_OpenDomain to get a domain handle */ + /* do a samr_OpenDomain to get a domain handle */ status = dcerpc_samr_OpenDomain(samr_pipe, tmp_ctx, &od); if (!NT_STATUS_IS_OK(status)) { r->out.error_string = talloc_asprintf(mem_ctx, @@ -856,17 +856,10 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru cu.out.rid = &rid; cu.out.access_granted = &access_granted; - /* 4. do a samr_CreateUser2 to get an account handle, or an error */ + /* do a samr_CreateUser2 to get an account handle, or an error */ cu_status = dcerpc_samr_CreateUser2(samr_pipe, tmp_ctx, &cu); status = cu_status; - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { - r->out.error_string = talloc_asprintf(mem_ctx, - "samr_CreateUser2 for [%s] failed: %s\n", - r->in.domain_name, nt_errstr(status)); - talloc_free(tmp_ctx); - return status; - - } else if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { /* prepare samr_LookupNames */ ln.in.domain_handle = &d_handle; ln.in.num_names = 1; @@ -943,6 +936,12 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru return status; } } + } else if (!NT_STATUS_IS_OK(status)) { + r->out.error_string = talloc_asprintf(mem_ctx, + "samr_CreateUser2 for [%s] failed: %s\n", + r->in.domain_name, nt_errstr(status)); + talloc_free(tmp_ctx); + return status; } /* prepare samr_QueryUserInfo (get flags) */ @@ -1078,6 +1077,7 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru return NT_STATUS_NO_MEMORY; } + /* Finish out by pushing various bits of status data out for the caller to use */ r->out.join_password = password_str; talloc_steal(mem_ctx, password_str); -- cgit