diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-08-29 08:00:15 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-08-29 08:00:15 +0000 |
commit | d5a4242d8880aca23210d7c2c019eda5b3e52eb3 (patch) | |
tree | 073ba019d4eb230f679923b767e73805e8f626a8 /source3 | |
parent | d03116a44795326bc58742e218826608b077d96b (diff) | |
download | samba-d5a4242d8880aca23210d7c2c019eda5b3e52eb3.tar.gz samba-d5a4242d8880aca23210d7c2c019eda5b3e52eb3.tar.bz2 samba-d5a4242d8880aca23210d7c2c019eda5b3e52eb3.zip |
show builtin groups in samdump
(This used to be commit c1e00f5f160985323f5a9ade42f2ebb2a798b17c)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/net_rpc_samsync.c | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 44c3fdb26a..f9afb76875 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -43,7 +43,7 @@ static void display_alias_mem(uint32 rid, SAM_ALIAS_MEM_INFO *a) { int i; d_printf("Alias rid %u: ", rid); - for (i=0;i<a->num_sids;i++) { + for (i=0;i<a->num_members;i++) { d_printf("%s ", sid_string_static(&a->sids[i].sid)); } d_printf("\n"); @@ -88,19 +88,49 @@ static void display_sam_entry(SAM_DELTA_HDR *hdr_delta, SAM_DELTA_CTR *delta) } } -/* dump sam database via samsync rpc calls */ -int rpc_samdump(int argc, const char **argv) + +static void dump_database(struct cli_state *cli, unsigned db_type, DOM_CRED *ret_creds) { - TALLOC_CTX *mem_ctx = NULL; + unsigned last_rid = 0; + NTSTATUS result; + int i; + TALLOC_CTX *mem_ctx; SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; uint32 num_deltas; + + if (!(mem_ctx = talloc_init())) { + return; + } + + d_printf("Dumping database %u\n", db_type); + + do { + result = cli_netlogon_sam_sync(cli, mem_ctx, ret_creds, db_type, last_rid+1, + &num_deltas, &hdr_deltas, &deltas); + clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), ret_creds); + last_rid = 0; + for (i = 0; i < num_deltas; i++) { + display_sam_entry(&hdr_deltas[i], &deltas[i]); + last_rid = hdr_deltas[i].target_rid; + if (last_rid == 0) { + break; + } + } + } while (last_rid && NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); + + talloc_destroy(mem_ctx); +} + +/* dump sam database via samsync rpc calls */ +int rpc_samdump(int argc, const char **argv) +{ NTSTATUS result; - int i; - unsigned last_rid=0; - DOM_CRED ret_creds; struct cli_state *cli = NULL; uchar trust_password[16]; + DOM_CRED ret_creds; + + ZERO_STRUCT(ret_creds); /* Connect to remote machine */ if (!(cli = net_make_ipc_connection(NET_FLAGS_ANONYMOUS | NET_FLAGS_PDC))) { @@ -123,31 +153,11 @@ int rpc_samdump(int argc, const char **argv) goto fail; } - if (!(mem_ctx = talloc_init())) { - DEBUG(0,("talloc_init failed\n")); - goto fail; - } - - /* on first call the returnAuthenticator is empty */ - memset(&ret_creds, 0, sizeof(ret_creds)); - - /* Do sam synchronisation on the SAM database*/ - do { - result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, SAM_DATABASE_DOMAIN, last_rid+1, - &num_deltas, &hdr_deltas, &deltas); - clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds); - last_rid = 0; - for (i = 0; i < num_deltas; i++) { - display_sam_entry(&hdr_deltas[i], &deltas[i]); - last_rid = hdr_deltas[i].target_rid; - if (last_rid == 0) { - break; - } - } - } while (last_rid && NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); + dump_database(cli, SAM_DATABASE_DOMAIN, &ret_creds); + dump_database(cli, SAM_DATABASE_BUILTIN, &ret_creds); + dump_database(cli, SAM_DATABASE_PRIVS, &ret_creds); cli_nt_session_close(cli); - talloc_destroy(mem_ctx); return 0; @@ -155,8 +165,5 @@ fail: if (cli) { cli_nt_session_close(cli); } - if (mem_ctx) { - talloc_destroy(mem_ctx); - } return -1; } |