diff options
Diffstat (limited to 'source3/torture/cmd_sam.c')
-rw-r--r-- | source3/torture/cmd_sam.c | 98 |
1 files changed, 28 insertions, 70 deletions
diff --git a/source3/torture/cmd_sam.c b/source3/torture/cmd_sam.c index eb8c17f2f9..3d4725c8a8 100644 --- a/source3/torture/cmd_sam.c +++ b/source3/torture/cmd_sam.c @@ -22,11 +22,6 @@ #include "includes.h" #include "samtest.h" -static void print_account(SAM_ACCOUNT_HANDLE *a) -{ - /* FIXME */ -} - static NTSTATUS cmd_context(struct samtest_state *st, TALLOC_CTX *mem_ctx, int argc, char **argv) { NTSTATUS status; @@ -56,12 +51,12 @@ static NTSTATUS cmd_load_module(struct samtest_state *st, TALLOC_CTX *mem_ctx, i char *plugin_arg[2]; NTSTATUS status; if (argc != 2 && argc != 3) { - printf("Usage: load <module path> [domain-name]\n"); + printf("Usage: load <module path> [domain-sid]\n"); return NT_STATUS_OK; } if (argc == 3) - asprintf(&plugin_arg[0], "plugin:%s|%s", argv[1], argv[2]); + asprintf(&plugin_arg[0], "%s|plugin:%s", argv[2], argv[1]); else asprintf(&plugin_arg[0], "plugin:%s", argv[1]); @@ -104,8 +99,8 @@ static NTSTATUS cmd_lookup_sid(struct samtest_state *st, TALLOC_CTX *mem_ctx, in return NT_STATUS_INVALID_PARAMETER; } - if (!NT_STATUS_IS_OK(status = sam_lookup_sid(st->context, st->token, mem_ctx, &sid, &name, &type))) { - printf("sam_lookup_sid failed!\n"); + if (!NT_STATUS_IS_OK(status = context_sam_lookup_sid(st->context, st->token, &sid, &name, &type))) { + printf("context_sam_lookup_sid failed!\n"); return status; } @@ -117,7 +112,7 @@ static NTSTATUS cmd_lookup_sid(struct samtest_state *st, TALLOC_CTX *mem_ctx, in static NTSTATUS cmd_lookup_name(struct samtest_state *st, TALLOC_CTX *mem_ctx, int argc, char **argv) { - DOM_SID sid; + DOM_SID *sid; uint32 type; NTSTATUS status; if (argc != 3) { @@ -125,12 +120,12 @@ static NTSTATUS cmd_lookup_name(struct samtest_state *st, TALLOC_CTX *mem_ctx, i return NT_STATUS_INVALID_PARAMETER; } - if (!NT_STATUS_IS_OK(status = sam_lookup_name(st->context, st->token, argv[1], argv[2], &sid, &type))) { - printf("sam_lookup_name failed!\n"); + if (!NT_STATUS_IS_OK(status = context_sam_lookup_name(st->context, st->token, argv[1], argv[2], &sid, &type))) { + printf("context_sam_lookup_name failed!\n"); return status; } - printf("SID: %s\n", sid_string_static(&sid)); + printf("SID: %s\n", sid_string_static(sid)); printf("Type: %d\n", type); return NT_STATUS_OK; @@ -155,8 +150,8 @@ static NTSTATUS cmd_lookup_domain(struct samtest_state *st, TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } - if (!NT_STATUS_IS_OK(status = sam_lookup_domain(st->context, st->token, argv[1], &sid))) { - printf("sam_lookup_name failed!\n"); + if (!NT_STATUS_IS_OK(status = context_sam_lookup_domain(st->context, st->token, argv[1], &sid))) { + printf("context_sam_lookup_name failed!\n"); return status; } @@ -172,8 +167,8 @@ static NTSTATUS cmd_enum_domains(struct samtest_state *st, TALLOC_CTX *mem_ctx, char **domain_names; NTSTATUS status; - if (!NT_STATUS_IS_OK(status = sam_enum_domains(st->context, st->token, &domain_count, &domain_sids, &domain_names))) { - printf("sam_enum_domains failed!\n"); + if (!NT_STATUS_IS_OK(status = context_sam_enum_domains(st->context, st->token, &domain_count, &domain_sids, &domain_names))) { + printf("context_sam_enum_domains failed!\n"); return status; } @@ -218,8 +213,8 @@ static NTSTATUS cmd_show_domain(struct samtest_state *st, TALLOC_CTX *mem_ctx, i return NT_STATUS_INVALID_PARAMETER; } - if (!NT_STATUS_IS_OK(status = sam_get_domain_by_sid(st->context, st->token, DOMAIN_ALL_ACCESS, &sid, &domain))) { - printf("sam_get_domain_by_sid failed\n"); + if (!NT_STATUS_IS_OK(status = context_sam_get_domain_by_sid(st->context, st->token, DOMAIN_ALL_ACCESS, &sid, &domain))) { + printf("context_sam_get_domain_by_sid failed\n"); return status; } @@ -232,13 +227,13 @@ static NTSTATUS cmd_show_domain(struct samtest_state *st, TALLOC_CTX *mem_ctx, i if (!NT_STATUS_IS_OK(status = sam_get_domain_num_groups(domain, &tmp_uint32))) { printf("sam_get_domain_num_groups failed: %s\n", nt_errstr(status)); } else { - printf("Number of groups: %u\n", tmp_uint32); + printf("Number of groups: %d\n", tmp_uint32); } if (!NT_STATUS_IS_OK(status = sam_get_domain_num_aliases(domain, &tmp_uint32))) { printf("sam_get_domain_num_aliases failed: %s\n", nt_errstr(status)); } else { - printf("Number of aliases: %u\n", tmp_uint32); + printf("Number of aliases: %d\n", tmp_uint32); } if (!NT_STATUS_IS_OK(status = sam_get_domain_name(domain, &tmp_string))) { @@ -250,7 +245,7 @@ static NTSTATUS cmd_show_domain(struct samtest_state *st, TALLOC_CTX *mem_ctx, i if (!NT_STATUS_IS_OK(status = sam_get_domain_lockout_count(domain, &tmp_uint16))) { printf("sam_get_domain_lockout_count failed: %s\n", nt_errstr(status)); } else { - printf("Lockout Count: %u\n", tmp_uint16); + printf("Lockout Count: %d\n", tmp_uint16); } if (!NT_STATUS_IS_OK(status = sam_get_domain_force_logoff(domain, &tmp_bool))) { @@ -262,7 +257,7 @@ static NTSTATUS cmd_show_domain(struct samtest_state *st, TALLOC_CTX *mem_ctx, i if (!NT_STATUS_IS_OK(status = sam_get_domain_lockout_duration(domain, &tmp_nttime))) { printf("sam_get_domain_lockout_duration failed: %s\n", nt_errstr(status)); } else { - printf("Lockout duration: %u\n", tmp_nttime.low); + printf("Lockout duration: %d\n", tmp_nttime.low); } if (!NT_STATUS_IS_OK(status = sam_get_domain_login_pwdchange(domain, &tmp_bool))) { @@ -274,31 +269,31 @@ static NTSTATUS cmd_show_domain(struct samtest_state *st, TALLOC_CTX *mem_ctx, i if (!NT_STATUS_IS_OK(status = sam_get_domain_max_pwdage(domain, &tmp_nttime))) { printf("sam_get_domain_max_pwdage failed: %s\n", nt_errstr(status)); } else { - printf("Maximum password age: %u\n", tmp_nttime.low); + printf("Maximum password age: %d\n", tmp_nttime.low); } if (!NT_STATUS_IS_OK(status = sam_get_domain_min_pwdage(domain, &tmp_nttime))) { printf("sam_get_domain_min_pwdage failed: %s\n", nt_errstr(status)); } else { - printf("Minimal password age: %u\n", tmp_nttime.low); + printf("Minimal password age: %d\n", tmp_nttime.low); } if (!NT_STATUS_IS_OK(status = sam_get_domain_min_pwdlength(domain, &tmp_uint16))) { printf("sam_get_domain_min_pwdlength: %s\n", nt_errstr(status)); } else { - printf("Minimal Password Length: %u\n", tmp_uint16); + printf("Minimal Password Length: %d\n", tmp_uint16); } if (!NT_STATUS_IS_OK(status = sam_get_domain_pwd_history(domain, &tmp_uint16))) { printf("sam_get_domain_pwd_history failed: %s\n", nt_errstr(status)); } else { - printf("Password history: %u\n", tmp_uint16); + printf("Password history: %d\n", tmp_uint16); } if (!NT_STATUS_IS_OK(status = sam_get_domain_reset_count(domain, &tmp_nttime))) { printf("sam_get_domain_reset_count failed: %s\n", nt_errstr(status)); } else { - printf("Reset count: %u\n", tmp_nttime.low); + printf("Reset count: %d\n", tmp_nttime.low); } if (!NT_STATUS_IS_OK(status = sam_get_domain_server(domain, &tmp_string))) { @@ -342,8 +337,8 @@ static NTSTATUS cmd_enum_accounts(struct samtest_state *st, TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } - if (!NT_STATUS_IS_OK(status = sam_enum_accounts(st->context, st->token, &sid, 0, &account_count, &accounts))) { - printf("sam_enum_accounts failed: %s\n", nt_errstr(status)); + if (!NT_STATUS_IS_OK(status = context_sam_enum_accounts(st->context, st->token, &sid, 0, &account_count, &accounts))) { + printf("context_sam_enum_accounts failed: %s\n", nt_errstr(status)); return status; } @@ -353,7 +348,7 @@ static NTSTATUS cmd_enum_accounts(struct samtest_state *st, TALLOC_CTX *mem_ctx, } for (i = 0; i < account_count; i++) - printf("SID: %s\nName: %s\nFullname: %s\nDescription: %s\nACB_BITS: %08X\n\n", + printf("%s\t%s\t%s\t%s\t%d\n", sid_string_static(&accounts[i].sid), accounts[i].account_name, accounts[i].full_name, accounts[i].account_desc, accounts[i].acct_ctrl); @@ -365,49 +360,12 @@ static NTSTATUS cmd_enum_accounts(struct samtest_state *st, TALLOC_CTX *mem_ctx, static NTSTATUS cmd_lookup_account_sid(struct samtest_state *st, TALLOC_CTX *mem_ctx, int argc, char **argv) { - NTSTATUS status; - DOM_SID sid; - SAM_ACCOUNT_HANDLE *account; - - if (argc != 2) { - printf("Usage: lookup_account_sid <account-sid>\n"); - return NT_STATUS_INVALID_PARAMETER; - } - - if (!string_to_sid(&sid, argv[1])){ - printf("Unparseable SID specified!\n"); - return NT_STATUS_INVALID_PARAMETER; - } - - if (!NT_STATUS_IS_OK(status = sam_get_account_by_sid(st->context, st->token, USER_ALL_ACCESS, &sid, &account))) { - printf("context_sam_get_account_by_sid failed: %s\n", nt_errstr(status)); - return status; - } - - print_account(account); - - return NT_STATUS_OK; + return NT_STATUS_NOT_IMPLEMENTED; } static NTSTATUS cmd_lookup_account_name(struct samtest_state *st, TALLOC_CTX *mem_ctx, int argc, char **argv) { - NTSTATUS status; - SAM_ACCOUNT_HANDLE *account; - - if (argc != 3) { - printf("Usage: lookup_account_name <domain-name> <account-name>\n"); - return NT_STATUS_INVALID_PARAMETER; - } - - - if (!NT_STATUS_IS_OK(status = sam_get_account_by_name(st->context, st->token, USER_ALL_ACCESS, argv[1], argv[2], &account))) { - printf("context_sam_get_account_by_sid failed: %s\n", nt_errstr(status)); - return status; - } - - print_account(account); - - return NT_STATUS_OK; + return NT_STATUS_NOT_IMPLEMENTED; } static NTSTATUS cmd_create_group(struct samtest_state *st, TALLOC_CTX *mem_ctx, int argc, char **argv) |