diff options
-rw-r--r-- | source3/libnet/libnet_join.c | 40 | ||||
-rw-r--r-- | source3/utils/net_domain.c | 40 | ||||
-rw-r--r-- | source3/utils/net_rpc.c | 39 | ||||
-rw-r--r-- | source3/utils/net_rpc_join.c | 14 |
4 files changed, 56 insertions, 77 deletions
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 996b9e64f9..4b8826ac97 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -598,11 +598,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, struct lsa_String lsa_acct_name; uint32 user_rid; uint32 acb_info = ACB_WSTRUST; - uint32 fields_present; uchar pwbuf[532]; - SAM_USERINFO_CTR ctr; - SAM_USER_INFO_25 p25; - const int infolevel = 25; struct MD5Context md5ctx; uchar md5buffer[16]; DATA_BLOB digested_session_key; @@ -610,6 +606,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, union lsa_PolicyInformation *info = NULL; struct samr_Ids user_rids; struct samr_Ids name_types; + union samr_UserInfo user_info; if (!r->in.machine_password) { r->in.machine_password = talloc_strdup(mem_ctx, generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH)); @@ -773,19 +770,18 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, ;; } - ZERO_STRUCT(ctr); - ZERO_STRUCT(p25); + ZERO_STRUCT(user_info.info25); - fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | - SAMR_FIELD_ACCT_FLAGS; - init_sam_user_info25P(&p25, fields_present, acb_info, (char *)pwbuf); + user_info.info25.info.fields_present = ACCT_NT_PWD_SET | + ACCT_LM_PWD_SET | + SAMR_FIELD_ACCT_FLAGS; + user_info.info25.info.acct_flags = acb_info; + memcpy(&user_info.info25.password.data, pwbuf, sizeof(pwbuf)); - ctr.switch_value = infolevel; - ctr.info.id25 = &p25; - - status = rpccli_samr_set_userinfo2(pipe_hnd, mem_ctx, &user_pol, - infolevel, &cli->user_session_key, - &ctr); + status = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, + &user_pol, + 25, + &user_info); if (!NT_STATUS_IS_OK(status)) { goto done; } @@ -831,8 +827,6 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx, NTSTATUS status = NT_STATUS_UNSUCCESSFUL; char *acct_name; uint32 user_rid; - SAM_USERINFO_CTR ctr; - SAM_USER_INFO_16 p16; struct lsa_String lsa_acct_name; struct samr_Ids user_rids; struct samr_Ids name_types; @@ -914,14 +908,12 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx, goto done; } - ZERO_STRUCT(ctr); - ctr.switch_value = 16; - ctr.info.id16 = &p16; - - p16.acb_info = info->info16.acct_flags | ACB_DISABLED; + info->info16.acct_flags |= ACB_DISABLED; - status = rpccli_samr_set_userinfo2(pipe_hnd, mem_ctx, &user_pol, 16, - &cli->user_session_key, &ctr); + status = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, + &user_pol, + 16, + info); rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); diff --git a/source3/utils/net_domain.c b/source3/utils/net_domain.c index 820b3ae792..69994b53df 100644 --- a/source3/utils/net_domain.c +++ b/source3/utils/net_domain.c @@ -57,8 +57,6 @@ NTSTATUS netdom_leave_domain( TALLOC_CTX *mem_ctx, struct cli_state *cli, NTSTATUS status = NT_STATUS_UNSUCCESSFUL; char *acct_name; uint32 user_rid; - SAM_USERINFO_CTR ctr; - SAM_USER_INFO_16 p16; struct lsa_String lsa_acct_name; struct samr_Ids user_rids; struct samr_Ids name_types; @@ -134,15 +132,13 @@ NTSTATUS netdom_leave_domain( TALLOC_CTX *mem_ctx, struct cli_state *cli, } /* now disable and setuser info */ - - ZERO_STRUCT(ctr); - ctr.switch_value = 16; - ctr.info.id16 = &p16; - p16.acb_info = info->info16.acct_flags | ACB_DISABLED; + info->info16.acct_flags |= ACB_DISABLED; - status = rpccli_samr_set_userinfo2(pipe_hnd, mem_ctx, &user_pol, 16, - &cli->user_session_key, &ctr); + status = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, + &user_pol, + 16, + info); rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); @@ -234,11 +230,7 @@ NTSTATUS netdom_join_domain( TALLOC_CTX *mem_ctx, struct cli_state *cli, uint32 user_rid; uint32 acb_info = ACB_WSTRUST; uint32 acct_flags; - uint32 fields_present; uchar pwbuf[532]; - SAM_USERINFO_CTR ctr; - SAM_USER_INFO_25 p25; - const int infolevel = 25; struct MD5Context md5ctx; uchar md5buffer[16]; DATA_BLOB digested_session_key; @@ -246,6 +238,7 @@ NTSTATUS netdom_join_domain( TALLOC_CTX *mem_ctx, struct cli_state *cli, uint32_t access_granted = 0; struct samr_Ids user_rids; struct samr_Ids name_types; + union samr_UserInfo info; /* Open the domain */ @@ -371,19 +364,18 @@ NTSTATUS netdom_join_domain( TALLOC_CTX *mem_ctx, struct cli_state *cli, } /* Set password and account flags on machine account */ + ZERO_STRUCT(info.info25); + info.info25.info.fields_present = ACCT_NT_PWD_SET | + ACCT_LM_PWD_SET | + SAMR_FIELD_ACCT_FLAGS; + info.info25.info.acct_flags = acb_info; + memcpy(&info.info25.password.data, pwbuf, sizeof(pwbuf)); - ZERO_STRUCT(ctr); - ZERO_STRUCT(p25); - - fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | - SAMR_FIELD_ACCT_FLAGS; - init_sam_user_info25P(&p25, fields_present, acb_info, (char *)pwbuf); - ctr.switch_value = infolevel; - ctr.info.id25 = &p25; - - status = rpccli_samr_set_userinfo2(pipe_hnd, mem_ctx, &user_pol, - infolevel, &cli->user_session_key, &ctr); + status = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, + &user_pol, + 25, + &info); if ( !NT_STATUS_IS_OK(status) ) { d_fprintf( stderr, "Failed to set password for machine account (%s)\n", diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 700e98b94f..4e3eedc681 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -1548,9 +1548,8 @@ do { if (strequal(ctx->thiscmd, name)) { \ #define SETSTR(name, rec, flag) \ do { if (strequal(ctx->thiscmd, name)) { \ - init_unistr2(&usr->uni_##rec, argv[0], UNI_STR_TERMINATE); \ - init_uni_hdr(&usr->hdr_##rec, &usr->uni_##rec); \ - usr->fields_present |= SAMR_FIELD_##flag; } \ + init_lsa_String(&(info->info21.rec), argv[0]); \ + info->info21.fields_present |= SAMR_FIELD_##flag; } \ } while (0); static NTSTATUS rpc_sh_user_str_edit_internals(TALLOC_CTX *mem_ctx, @@ -1560,8 +1559,6 @@ static NTSTATUS rpc_sh_user_str_edit_internals(TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result; - SAM_USERINFO_CTR *ctr; - SAM_USER_INFO_21 *usr; const char *username; const char *oldval = ""; union samr_UserInfo *info = NULL; @@ -1594,22 +1591,23 @@ static NTSTATUS rpc_sh_user_str_edit_internals(TALLOC_CTX *mem_ctx, goto done; } - ZERO_STRUCTP(usr); - if (strcmp(argv[0], "NULL") == 0) { argv[0] = ""; } + ZERO_STRUCT(info->info21); + SETSTR("fullname", full_name, FULL_NAME); - SETSTR("homedir", home_dir, HOME_DIRECTORY); - SETSTR("homedrive", dir_drive, HOME_DRIVE); + SETSTR("homedir", home_directory, HOME_DIRECTORY); + SETSTR("homedrive", home_drive, HOME_DRIVE); SETSTR("logonscript", logon_script, LOGON_SCRIPT); SETSTR("profilepath", profile_path, PROFILE_PATH); - SETSTR("description", acct_desc, DESCRIPTION); + SETSTR("description", description, DESCRIPTION); - result = rpccli_samr_set_userinfo2( - pipe_hnd, mem_ctx, user_hnd, 21, - &pipe_hnd->cli->user_session_key, ctr); + result = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, + CONST_DISCARD(struct policy_handle *, user_hnd), + 21, + info); d_printf("Set %s's %s from [%s] to [%s]\n", username, ctx->thiscmd, oldval, argv[0]); @@ -1644,8 +1642,6 @@ static NTSTATUS rpc_sh_user_flag_edit_internals(TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result; - SAM_USERINFO_CTR *ctr; - SAM_USER_INFO_21 *usr; const char *username; const char *oldval = "unknown"; uint32 oldflags, newflags; @@ -1684,14 +1680,15 @@ static NTSTATUS rpc_sh_user_flag_edit_internals(TALLOC_CTX *mem_ctx, goto done; } - ZERO_STRUCTP(usr); + ZERO_STRUCT(info->info21); - usr->acb_info = newflags; - usr->fields_present = SAMR_FIELD_ACCT_FLAGS; + info->info21.acct_flags = newflags; + info->info21.fields_present = SAMR_FIELD_ACCT_FLAGS; - result = rpccli_samr_set_userinfo2( - pipe_hnd, mem_ctx, user_hnd, 21, - &pipe_hnd->cli->user_session_key, ctr); + result = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, + CONST_DISCARD(struct policy_handle *, user_hnd), + 21, + info); if (NT_STATUS_IS_OK(result)) { d_printf("Set %s's %s flag from [%s] to [%s]\n", username, diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index 0e9e603e23..f94e08edef 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -154,8 +154,8 @@ int net_rpc_join_newstyle(int argc, const char **argv) uchar pwbuf[516]; SAM_USERINFO_CTR ctr; SAM_USER_INFO_24 p24; - SAM_USER_INFO_16 p16; uchar md4_trust_password[16]; + union samr_UserInfo set_info; /* Misc */ @@ -365,17 +365,15 @@ int net_rpc_join_newstyle(int argc, const char **argv) seems to cope with either value so don't bomb out if the set userinfo2 level 0x10 fails. -tpot */ - ZERO_STRUCT(ctr); - ctr.switch_value = 16; - ctr.info.id16 = &p16; - - init_sam_user_info16(&p16, acb_info); + set_info.info16.acct_flags = acb_info; /* Ignoring the return value is necessary for joining a domain as a normal user with "Add workstation to domain" privilege. */ - result = rpccli_samr_set_userinfo2(pipe_hnd, mem_ctx, &user_pol, 16, - &cli->user_session_key, &ctr); + result = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, + &user_pol, + 16, + &set_info); rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */ |