summaryrefslogtreecommitdiff
path: root/source3/rpcclient/cmd_samr.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-02-08 17:00:31 -0800
committerJeremy Allison <jra@samba.org>2008-02-08 17:00:31 -0800
commitc7f34889591174ae335a37ab62747afab8fc418c (patch)
tree3dacbead8b7c8425e0e69bcebaa82b810f70976d /source3/rpcclient/cmd_samr.c
parent7a694af2f4581b6ca96745f7b82318cb75d26d6e (diff)
parent5da927716a857ce686f3b75476671d32f047d2c0 (diff)
downloadsamba-c7f34889591174ae335a37ab62747afab8fc418c.tar.gz
samba-c7f34889591174ae335a37ab62747afab8fc418c.tar.bz2
samba-c7f34889591174ae335a37ab62747afab8fc418c.zip
Merge branch 'v3-2-test' of ssh://jra@git.samba.org/data/git/samba into v3-2-test
(This used to be commit 33a9859cbdb0dac035af36aa561b6acb24196c86)
Diffstat (limited to 'source3/rpcclient/cmd_samr.c')
-rw-r--r--source3/rpcclient/cmd_samr.c73
1 files changed, 70 insertions, 3 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index edc3c9d4b2..4f0e45ec74 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -245,7 +245,7 @@ static void display_sam_info_1(struct samr_DispEntryGeneral *r)
{
printf("index: 0x%x ", r->idx);
printf("RID: 0x%x ", r->rid);
- printf("acb: 0x%x ", r->acct_flags);
+ printf("acb: 0x%08x ", r->acct_flags);
printf("Account: %s\t", r->account_name.string);
printf("Name: %s\t", r->full_name.string);
printf("Desc: %s\n", r->description.string);
@@ -255,7 +255,7 @@ static void display_sam_info_2(struct samr_DispEntryFull *r)
{
printf("index: 0x%x ", r->idx);
printf("RID: 0x%x ", r->rid);
- printf("acb: 0x%x ", r->acct_flags);
+ printf("acb: 0x%08x ", r->acct_flags);
printf("Account: %s\t", r->account_name.string);
printf("Desc: %s\n", r->description.string);
}
@@ -264,7 +264,7 @@ static void display_sam_info_3(struct samr_DispEntryFullGroup *r)
{
printf("index: 0x%x ", r->idx);
printf("RID: 0x%x ", r->rid);
- printf("acb: 0x%x ", r->acct_flags);
+ printf("acb: 0x%08x ", r->acct_flags);
printf("Account: %s\t", r->account_name.string);
printf("Desc: %s\n", r->description.string);
}
@@ -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", "" },