s3-rpc_client: return info3 in rpccli_netlogon_password_logon().
authorGünther Deschner <gd@samba.org>
Tue, 15 Jul 2014 06:28:42 +0000 (08:28 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 15 Jul 2014 14:00:40 +0000 (16:00 +0200)
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/rpc_client/cli_netlogon.c
source3/rpc_client/cli_netlogon.h
source3/rpcclient/cmd_netlogon.c

index 746c7b6480f30d4765e9374401f532c9e3bdb061..7063351ef8a5600c4d5b17a1d798bba8c8c2f2f9 100644 (file)
@@ -193,16 +193,65 @@ NTSTATUS rpccli_setup_netlogon_creds(struct cli_state *cli,
        return NT_STATUS_OK;
 }
 
+static NTSTATUS map_validation_to_info3(TALLOC_CTX *mem_ctx,
+                                       uint16_t validation_level,
+                                       union netr_Validation *validation,
+                                       struct netr_SamInfo3 **info3_p)
+{
+       struct netr_SamInfo3 *info3;
+       NTSTATUS status;
+
+       if (validation == NULL) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       switch (validation_level) {
+       case 3:
+               if (validation->sam3 == NULL) {
+                       return NT_STATUS_INVALID_PARAMETER;
+               }
+
+               info3 = talloc_move(mem_ctx, &validation->sam3);
+               break;
+       case 6:
+               if (validation->sam6 == NULL) {
+                       return NT_STATUS_INVALID_PARAMETER;
+               }
+
+               info3 = talloc_zero(mem_ctx, struct netr_SamInfo3);
+               if (info3 == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+               status = copy_netr_SamBaseInfo(info3, &validation->sam6->base, &info3->base);
+               if (!NT_STATUS_IS_OK(status)) {
+                       TALLOC_FREE(info3);
+                       return status;
+               }
+
+               info3->sidcount = validation->sam6->sidcount;
+               info3->sids = talloc_move(info3, &validation->sam6->sids);
+               break;
+       default:
+               return NT_STATUS_BAD_VALIDATION_CLASS;
+       }
+
+       *info3_p = info3;
+
+       return NT_STATUS_OK;
+}
+
 /* Logon domain user */
 
 NTSTATUS rpccli_netlogon_password_logon(struct netlogon_creds_cli_context *creds,
                                        struct dcerpc_binding_handle *binding_handle,
+                                       TALLOC_CTX *mem_ctx,
                                        uint32_t logon_parameters,
                                        const char *domain,
                                        const char *username,
                                        const char *password,
                                        const char *workstation,
-                                       enum netr_LogonInfoClass logon_type)
+                                       enum netr_LogonInfoClass logon_type,
+                                       struct netr_SamInfo3 **info3)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        NTSTATUS status;
@@ -320,57 +369,19 @@ NTSTATUS rpccli_netlogon_password_logon(struct netlogon_creds_cli_context *creds
                                                  &validation,
                                                  &authoritative,
                                                  &flags);
-       TALLOC_FREE(frame);
        if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(frame);
                return status;
        }
 
-       return NT_STATUS_OK;
-}
-
-static NTSTATUS map_validation_to_info3(TALLOC_CTX *mem_ctx,
-                                       uint16_t validation_level,
-                                       union netr_Validation *validation,
-                                       struct netr_SamInfo3 **info3_p)
-{
-       struct netr_SamInfo3 *info3;
-       NTSTATUS status;
-
-       if (validation == NULL) {
-               return NT_STATUS_INVALID_PARAMETER;
-       }
-
-       switch (validation_level) {
-       case 3:
-               if (validation->sam3 == NULL) {
-                       return NT_STATUS_INVALID_PARAMETER;
-               }
-
-               info3 = talloc_move(mem_ctx, &validation->sam3);
-               break;
-       case 6:
-               if (validation->sam6 == NULL) {
-                       return NT_STATUS_INVALID_PARAMETER;
-               }
-
-               info3 = talloc_zero(mem_ctx, struct netr_SamInfo3);
-               if (info3 == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
-               status = copy_netr_SamBaseInfo(info3, &validation->sam6->base, &info3->base);
-               if (!NT_STATUS_IS_OK(status)) {
-                       TALLOC_FREE(info3);
-                       return status;
-               }
-
-               info3->sidcount = validation->sam6->sidcount;
-               info3->sids = talloc_move(info3, &validation->sam6->sids);
-               break;
-       default:
-               return NT_STATUS_BAD_VALIDATION_CLASS;
+       status = map_validation_to_info3(mem_ctx,
+                                        validation_level, validation,
+                                        info3);
+       TALLOC_FREE(frame);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
 
-       *info3_p = info3;
 
        return NT_STATUS_OK;
 }
index 61fed4acdd6a23c75e963de2728b68d2f1977f64..fee08016d5d7b18758785ba6508547a1f091dd39 100644 (file)
@@ -45,12 +45,14 @@ NTSTATUS rpccli_setup_netlogon_creds(struct cli_state *cli,
                                     const struct samr_Password *previous_nt_hash);
 NTSTATUS rpccli_netlogon_password_logon(struct netlogon_creds_cli_context *creds,
                                        struct dcerpc_binding_handle *binding_handle,
+                                       TALLOC_CTX *mem_ctx,
                                        uint32_t logon_parameters,
                                        const char *domain,
                                        const char *username,
                                        const char *password,
                                        const char *workstation,
-                                       enum netr_LogonInfoClass logon_type);
+                                       enum netr_LogonInfoClass logon_type,
+                                       struct netr_SamInfo3 **info3);
 NTSTATUS rpccli_netlogon_network_logon(struct netlogon_creds_cli_context *creds,
                                       struct dcerpc_binding_handle *binding_handle,
                                       TALLOC_CTX *mem_ctx,
index b637b3e68c6f215958b36de304a7a861ba762946..2d1c35168cea0f28b068decbe933a5ac528267a6 100644 (file)
@@ -778,6 +778,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli,
        const char *username, *password;
        uint32 logon_param = 0;
        const char *workstation = NULL;
+       struct netr_SamInfo3 *info3 = NULL;
 
        /* Check arguments */
 
@@ -803,12 +804,14 @@ static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli,
 
        result = rpccli_netlogon_password_logon(rpcclient_netlogon_creds,
                                                cli->binding_handle,
+                                               mem_ctx,
                                                logon_param,
                                                lp_workgroup(),
                                                username,
                                                password,
                                                workstation,
-                                               logon_type);
+                                               logon_type,
+                                               &info3);
        if (!NT_STATUS_IS_OK(result))
                goto done;