diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-07-13 15:14:39 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-07-13 15:14:39 +0000 |
commit | db34ff6714cb91c568106a02d99b2d2924c62df7 (patch) | |
tree | 6874b2d393484dcf14e5bbf125e4d0f2cf37569b | |
parent | 351831683d6d1d7040fe36b04331746e95aaac87 (diff) | |
download | samba-db34ff6714cb91c568106a02d99b2d2924c62df7.tar.gz samba-db34ff6714cb91c568106a02d99b2d2924c62df7.tar.bz2 samba-db34ff6714cb91c568106a02d99b2d2924c62df7.zip |
added useful 'net rpc info' command
this also gives a way to distinguish a 'native mode' server from a
non-native server. This call will fail for a native mode server.
(This used to be commit a7663428e05bdd41a1975d0db9be6537b7238b95)
-rw-r--r-- | source3/utils/net_rpc.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index b202a7e8cc..dc50c438d4 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -305,6 +305,80 @@ int net_rpc_join(int argc, const char **argv) } + +/** + * display info about a rpc domain + * + * All paramaters are provided by the run_rpc_command function, except for + * argc, argv which are passes through. + * + * @param domain_sid The domain sid acquired from the remote server + * @param cli A cli_state connected to the server. + * @param mem_ctx Talloc context, destoyed on completion of the function. + * @param argc Standard main() style argc + * @param argv Standard main() style argv. Initial components are already + * stripped + * + * @return Normal NTSTATUS return. + **/ + +static NTSTATUS +rpc_info_internals(const DOM_SID *domain_sid, struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, const char **argv) +{ + POLICY_HND connect_pol, domain_pol; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + SAM_UNK_CTR ctr; + + /* Get sam policy handle */ + result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, + &connect_pol); + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + /* Get domain policy handle */ + result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + MAXIMUM_ALLOWED_ACCESS, + domain_sid, &domain_pol); + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + ZERO_STRUCT(ctr); + result = cli_samr_query_dom_info(cli, mem_ctx, &domain_pol, + 2, &ctr); + if (NT_STATUS_IS_OK(result)) { + TALLOC_CTX *ctx = talloc_init(); + d_printf("Domain Name: %s\n", unistr2_tdup(ctx, &ctr.info.inf2.uni_domain)); + d_printf("Sequence number: %u\n", ctr.info.inf2.seq_num); + d_printf("Num users: %u\n", ctr.info.inf2.num_domain_usrs); + d_printf("Num domain groups: %u\n", ctr.info.inf2.num_domain_grps); + d_printf("Num local groups: %u\n", ctr.info.inf2.num_local_grps); + talloc_destroy(ctx); + } + + done: + return result; +} + + +/** + * 'net rpc info' entrypoint. + * @param argc Standard main() style argc + * @param argc Standard main() style argv. Initial components are already + * stripped + **/ +int net_rpc_info(int argc, const char **argv) +{ + return run_rpc_command(PIPE_SAMR, NET_FLAGS_ANONYMOUS | NET_FLAGS_PDC, + rpc_info_internals, + argc, argv); +} + + + + /****************************************************************************/ /** @@ -1786,6 +1860,7 @@ BOOL net_rpc_check(unsigned flags) int net_rpc_usage(int argc, const char **argv) { + d_printf(" net rpc info \t\t\tshow basic info about a domain \n"); d_printf(" net rpc join \t\t\tto join a domain \n"); d_printf(" net rpc user \t\t\tto add, delete and list users\n"); d_printf(" net rpc group \t\tto list groups\n"); @@ -1847,6 +1922,7 @@ int net_rpc_help(int argc, const char **argv) int net_rpc(int argc, const char **argv) { struct functable func[] = { + {"info", net_rpc_info}, {"join", net_rpc_join}, {"user", net_rpc_user}, {"group", net_rpc_group}, |