summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-02-06 20:26:54 +0100
committerGünther Deschner <gd@samba.org>2008-02-08 23:01:16 +0100
commitab346de34029e423f54bb7d902fc6d2ceef2ce5f (patch)
treed67482792cd1d5c80ed41450f6eeda7db853b5d7 /source3/rpcclient
parentb98f927fabb7218ac84e0c888707f5ef2a86286e (diff)
downloadsamba-ab346de34029e423f54bb7d902fc6d2ceef2ce5f.tar.gz
samba-ab346de34029e423f54bb7d902fc6d2ceef2ce5f.tar.bz2
samba-ab346de34029e423f54bb7d902fc6d2ceef2ce5f.zip
Add cmd_samr_enum_domains command to rpcclient.
Guenther (This used to be commit f429153de299a1144bdf4fc4f9753fff0140c3bf)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_samr.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index edc3c9d4b2..5170fb37bb 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -1046,6 +1046,72 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
return result;
}
+/* Enumerate domains */
+
+static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ POLICY_HND connect_pol;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ uint32 start_idx, size, num_entries, i;
+ uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ bool got_connect_pol = false;
+ struct samr_SamArray *sam = NULL;
+
+ if ((argc < 1) || (argc > 2)) {
+ printf("Usage: %s [access mask]\n", argv[0]);
+ return NT_STATUS_OK;
+ }
+
+ if (argc > 2) {
+ sscanf(argv[2], "%x", &access_mask);
+ }
+
+ /* Get sam policy handle */
+
+ result = try_samr_connects(cli, mem_ctx,
+ access_mask,
+ &connect_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ got_connect_pol = true;
+
+ /* Enumerate alias groups */
+
+ start_idx = 0;
+ size = 0xffff;
+
+ do {
+ result = rpccli_samr_EnumDomains(cli, mem_ctx,
+ &connect_pol,
+ &start_idx,
+ &sam,
+ size,
+ &num_entries);
+
+ if (NT_STATUS_IS_OK(result) ||
+ NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
+
+ for (i = 0; i < num_entries; i++)
+ printf("name:[%s] idx:[0x%x]\n",
+ sam->entries[i].name.string,
+ sam->entries[i].idx);
+ }
+ } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
+
+ done:
+ if (got_connect_pol) {
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
+ }
+
+ return result;
+}
+
+
/* Query alias membership */
static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli,
@@ -2485,6 +2551,7 @@ struct cmd_set samr_commands[] = {
{ "enumdomusers", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_users, NULL, PI_SAMR, NULL, "Enumerate domain users", "" },
{ "enumdomgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_groups, NULL, PI_SAMR, NULL, "Enumerate domain groups", "" },
{ "enumalsgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_als_groups, NULL, PI_SAMR, NULL, "Enumerate alias groups", "" },
+ { "enumdomains", RPC_RTYPE_NTSTATUS, cmd_samr_enum_domains, NULL, PI_SAMR, NULL, "Enumerate domains", "" },
{ "createdomuser", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_user, NULL, PI_SAMR, NULL, "Create domain user", "" },
{ "createdomgroup", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_group, NULL, PI_SAMR, NULL, "Create domain group", "" },