From 4369c14a66060021259308d1c42372e75455953f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 31 Mar 2008 20:43:18 +0200 Subject: Re-add support for the samr parameters string. (dialin settings, terminal server settings, etc.) Guenther (This used to be commit c4f248df8e34c6a028bf8d789fe9763b0ea063fe) --- source3/rpc_client/init_samr.c | 10 ++++---- source3/rpc_server/srv_samr_nt.c | 51 ++++++++++++++++---------------------- source3/rpc_server/srv_samr_util.c | 17 ++++++------- source3/rpcclient/cmd_samr.c | 16 +++++++++++- 4 files changed, 50 insertions(+), 44 deletions(-) (limited to 'source3') diff --git a/source3/rpc_client/init_samr.c b/source3/rpc_client/init_samr.c index 1275fc834b..3b62e7effb 100644 --- a/source3/rpc_client/init_samr.c +++ b/source3/rpc_client/init_samr.c @@ -308,9 +308,9 @@ void init_samr_user_info18(struct samr_UserInfo18 *r, ********************************************************************/ void init_samr_user_info20(struct samr_UserInfo20 *r, - const char *munged_dial) + struct lsa_BinaryString *parameters) { - init_lsa_String(&r->parameters, munged_dial); + r->parameters = *parameters; } /************************************************************************* @@ -333,7 +333,7 @@ void init_samr_user_info21(struct samr_UserInfo21 *r, const char *description, const char *workstations, const char *comment, - const char *parameters, + struct lsa_BinaryString *parameters, uint32_t rid, uint32_t primary_gid, uint32_t acct_flags, @@ -362,7 +362,7 @@ void init_samr_user_info21(struct samr_UserInfo21 *r, init_lsa_String(&r->description, description); init_lsa_String(&r->workstations, workstations); init_lsa_String(&r->comment, comment); - init_lsa_String(&r->parameters, parameters); + r->parameters = *parameters; r->rid = rid; r->primary_gid = primary_gid; r->acct_flags = acct_flags; @@ -397,7 +397,7 @@ void init_samr_user_info23(struct samr_UserInfo23 *r, const char *description, const char *workstations, const char *comment, - const char *parameters, + struct lsa_BinaryString *parameters, uint32_t rid, uint32_t primary_gid, uint32_t acct_flags, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 034392ed21..0f4a5b9ae1 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2368,8 +2368,9 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, struct samu *sampass=NULL; bool ret; const char *munged_dial = NULL; - const char *munged_dial_decoded = NULL; DATA_BLOB blob; + NTSTATUS status; + struct lsa_BinaryString *parameters = NULL; ZERO_STRUCTP(r); @@ -2391,28 +2392,23 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, samr_clear_sam_passwd(sampass); - DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); + DEBUG(3,("User:[%s] has [%s] (length: %d)\n", pdb_get_username(sampass), + munged_dial, strlen(munged_dial))); if (munged_dial) { blob = base64_decode_data_blob(munged_dial); - munged_dial_decoded = talloc_strndup(mem_ctx, - (const char *)blob.data, - blob.length); - data_blob_free(&blob); - if (!munged_dial_decoded) { - TALLOC_FREE(sampass); - return NT_STATUS_NO_MEMORY; - } + } else { + blob = data_blob_string_const(""); } -#if 0 - init_unistr2_from_datablob(&usr->uni_munged_dial, &blob); - init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); + status = init_samr_parameters_string(mem_ctx, &blob, ¶meters); data_blob_free(&blob); -#endif - init_samr_user_info20(r, munged_dial_decoded); - TALLOC_FREE(sampass); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + init_samr_user_info20(r, parameters); return NT_STATUS_OK; } @@ -2427,6 +2423,7 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, DOM_SID *user_sid, DOM_SID *domain_sid) { + NTSTATUS status; struct samu *pw = NULL; bool ret; const DOM_SID *sid_user, *sid_group; @@ -2437,8 +2434,9 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, uint8_t password_expired; const char *account_name, *full_name, *home_directory, *home_drive, *logon_script, *profile_path, *description, - *workstations, *comment, *parameters; + *workstations, *comment; struct samr_LogonHours logon_hours; + struct lsa_BinaryString *parameters = NULL; const char *munged_dial = NULL; DATA_BLOB blob; @@ -2508,16 +2506,16 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, munged_dial = pdb_get_munged_dial(pw); if (munged_dial) { blob = base64_decode_data_blob(munged_dial); - parameters = talloc_strndup(mem_ctx, (const char *)blob.data, blob.length); - data_blob_free(&blob); - if (!parameters) { - TALLOC_FREE(pw); - return NT_STATUS_NO_MEMORY; - } } else { - parameters = NULL; + blob = data_blob_string_const(""); } + status = init_samr_parameters_string(mem_ctx, &blob, ¶meters); + data_blob_free(&blob); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(pw); + return status; + } account_name = talloc_strdup(mem_ctx, pdb_get_username(pw)); full_name = talloc_strdup(mem_ctx, pdb_get_fullname(pw)); @@ -2542,11 +2540,6 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, -- Volker */ -#if 0 - init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob); - init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); - data_blob_free(&munged_dial_blob); -#endif #endif init_samr_user_info21(r, diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 688d72064f..74daf46e84 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -50,11 +50,10 @@ void copy_id20_to_sam_passwd(struct samu *to, return; } - if (from->parameters.string) { + if (from->parameters.array) { old_string = pdb_get_munged_dial(to); - mung.length = from->parameters.length; - mung.data = (uint8_t *)from->parameters.string; - mung.free = NULL; + mung = data_blob_const(from->parameters.array, + from->parameters.length); new_string = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); DEBUG(10,("INFO_20 PARAMETERS: %s -> %s\n", @@ -77,7 +76,6 @@ void copy_id21_to_sam_passwd(const char *log_prefix, { time_t unix_time, stored_time; const char *old_string, *new_string; - DATA_BLOB mung; const char *l; if (from == NULL || to == NULL) { @@ -234,12 +232,13 @@ void copy_id21_to_sam_passwd(const char *log_prefix, } if ((from->fields_present & SAMR_FIELD_PARAMETERS) && - (from->parameters.string)) { + (from->parameters.array)) { char *newstr; + DATA_BLOB mung; old_string = pdb_get_munged_dial(to); - mung.length = from->parameters.length; - mung.data = (uint8_t *)from->parameters.string; - mung.free = NULL; + + mung = data_blob_const(from->parameters.array, + from->parameters.length); newstr = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); DEBUG(10,("%s SAMR_FIELD_PARAMETERS: %s -> %s\n", l, diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 2d20afeb13..9cc47d121a 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -51,6 +51,16 @@ static void display_samr_user_info_16(struct samr_UserInfo16 *r) printf("\tAcct Flags :\tox%x\n", r->acct_flags); } +/**************************************************************************** + display samr_user_info_20 structure + ****************************************************************************/ +static void display_samr_user_info_20(struct samr_UserInfo20 *r) +{ + printf("\tRemote Dial :\n"); + dump_data(0, (uint8_t *)r->parameters.array, r->parameters.length*2); +} + + /**************************************************************************** display samr_user_info_21 structure ****************************************************************************/ @@ -65,7 +75,8 @@ static void display_samr_user_info_21(struct samr_UserInfo21 *r) printf("\tDescription :\t%s\n", r->description.string); printf("\tWorkstations:\t%s\n", r->workstations.string); printf("\tComment :\t%s\n", r->comment.string); - printf("\tRemote Dial :\t%s\n", r->parameters.string); + printf("\tRemote Dial :\n"); + dump_data(0, (uint8_t *)r->parameters.array, r->parameters.length*2); printf("\tLogon Time :\t%s\n", http_timestring(nt_time_to_unix(r->last_logon))); @@ -374,6 +385,9 @@ static NTSTATUS cmd_samr_query_user(struct rpc_pipe_client *cli, case 16: display_samr_user_info_16(&info->info16); break; + case 20: + display_samr_user_info_20(&info->info20); + break; case 21: display_samr_user_info_21(&info->info21); break; -- cgit