summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-02-07 20:46:02 +0100
committerGünther Deschner <gd@samba.org>2008-02-08 00:10:55 +0100
commit781776d8643ba649a3c52978ff7e07511b43572d (patch)
tree685728d892e40eb4178bcfdc6e3f78dd3c7a6d56
parentf27a5561aa95051ef4ccffd661601c242281e450 (diff)
downloadsamba-781776d8643ba649a3c52978ff7e07511b43572d.tar.gz
samba-781776d8643ba649a3c52978ff7e07511b43572d.tar.bz2
samba-781776d8643ba649a3c52978ff7e07511b43572d.zip
Use rpccli_samr_QueryDisplayInfo() all over the place.
Guenther (This used to be commit 66b79add353bf7a09f304eac5274cb89b23d7b06)
-rw-r--r--source3/rpcclient/cmd_samr.c166
-rw-r--r--source3/utils/net_rpc.c63
-rw-r--r--source3/winbindd/winbindd_rpc.c39
3 files changed, 120 insertions, 148 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index a864874c8e..0082d5c9f5 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -241,80 +241,44 @@ static void display_sam_dom_info_13(struct samr_DomInfo13 *info13)
}
-static void display_sam_info_1(SAM_ENTRY1 *e1, SAM_STR1 *s1)
+static void display_sam_info_1(struct samr_DispEntryGeneral *r)
{
- fstring tmp;
-
- printf("index: 0x%x ", e1->user_idx);
- printf("RID: 0x%x ", e1->rid_user);
- printf("acb: 0x%x ", e1->acb_info);
-
- unistr2_to_ascii(tmp, &s1->uni_acct_name, sizeof(tmp));
- printf("Account: %s\t", tmp);
-
- unistr2_to_ascii(tmp, &s1->uni_full_name, sizeof(tmp));
- printf("Name: %s\t", tmp);
-
- unistr2_to_ascii(tmp, &s1->uni_acct_desc, sizeof(tmp));
- printf("Desc: %s\n", tmp);
+ printf("index: 0x%x ", r->idx);
+ printf("RID: 0x%x ", r->rid);
+ printf("acb: 0x%x ", 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);
}
-static void display_sam_info_2(SAM_ENTRY2 *e2, SAM_STR2 *s2)
+static void display_sam_info_2(struct samr_DispEntryFull *r)
{
- fstring tmp;
-
- printf("index: 0x%x ", e2->user_idx);
- printf("RID: 0x%x ", e2->rid_user);
- printf("acb: 0x%x ", e2->acb_info);
-
- unistr2_to_ascii(tmp, &s2->uni_srv_name, sizeof(tmp));
- printf("Account: %s\t", tmp);
-
- unistr2_to_ascii(tmp, &s2->uni_srv_desc, sizeof(tmp));
- printf("Name: %s\n", tmp);
-
+ printf("index: 0x%x ", r->idx);
+ printf("RID: 0x%x ", r->rid);
+ printf("acb: 0x%x ", r->acct_flags);
+ printf("Account: %s\t", r->account_name.string);
+ printf("Desc: %s\n", r->description.string);
}
-static void display_sam_info_3(SAM_ENTRY3 *e3, SAM_STR3 *s3)
+static void display_sam_info_3(struct samr_DispEntryFullGroup *r)
{
- fstring tmp;
-
- printf("index: 0x%x ", e3->grp_idx);
- printf("RID: 0x%x ", e3->rid_grp);
- printf("attr: 0x%x ", e3->attr);
-
- unistr2_to_ascii(tmp, &s3->uni_grp_name, sizeof(tmp));
- printf("Account: %s\t", tmp);
-
- unistr2_to_ascii(tmp, &s3->uni_grp_desc, sizeof(tmp));
- printf("Name: %s\n", tmp);
-
+ printf("index: 0x%x ", r->idx);
+ printf("RID: 0x%x ", r->rid);
+ printf("acb: 0x%x ", r->acct_flags);
+ printf("Account: %s\t", r->account_name.string);
+ printf("Desc: %s\n", r->description.string);
}
-static void display_sam_info_4(SAM_ENTRY4 *e4, SAM_STR4 *s4)
+static void display_sam_info_4(struct samr_DispEntryAscii *r)
{
- int i;
-
- printf("index: %d ", e4->user_idx);
-
- printf("Account: ");
- for (i=0; i<s4->acct_name.str_str_len; i++)
- printf("%c", s4->acct_name.buffer[i]);
- printf("\n");
-
+ printf("index: 0x%x ", r->idx);
+ printf("Account: %s\n", r->account_name.string);
}
-static void display_sam_info_5(SAM_ENTRY5 *e5, SAM_STR5 *s5)
+static void display_sam_info_5(struct samr_DispEntryAscii *r)
{
- int i;
-
- printf("index: 0x%x ", e5->grp_idx);
-
- printf("Account: ");
- for (i=0; i<s5->grp_name.str_str_len; i++)
- printf("%c", s5->grp_name.buffer[i]);
- printf("\n");
-
+ printf("index: 0x%x ", r->idx);
+ printf("Account: %s\n", r->account_name.string);
}
/****************************************************************************
@@ -1363,14 +1327,10 @@ static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
uint32 start_idx=0, max_entries=250, max_size = 0xffff, num_entries, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
uint32 info_level = 1;
- SAM_DISPINFO_CTR ctr;
- SAM_DISPINFO_1 info1;
- SAM_DISPINFO_2 info2;
- SAM_DISPINFO_3 info3;
- SAM_DISPINFO_4 info4;
- SAM_DISPINFO_5 info5;
+ union samr_DispInfo info;
int loop_count = 0;
bool got_params = False; /* Use get_query_dispinfo_params() or not? */
+ uint32_t total_size, returned_size;
if (argc > 6) {
printf("Usage: %s [info level] [start index] [max entries] [max size] [access mask]\n", argv[0]);
@@ -1417,46 +1377,46 @@ static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
/* Query display info */
- ZERO_STRUCT(ctr);
- ZERO_STRUCT(info1);
-
- switch (info_level) {
- case 1:
- ZERO_STRUCT(info1);
- ctr.sam.info1 = &info1;
- break;
- case 2:
- ZERO_STRUCT(info2);
- ctr.sam.info2 = &info2;
- break;
- case 3:
- ZERO_STRUCT(info3);
- ctr.sam.info3 = &info3;
- break;
- case 4:
- ZERO_STRUCT(info4);
- ctr.sam.info4 = &info4;
- break;
- case 5:
- ZERO_STRUCT(info5);
- ctr.sam.info5 = &info5;
- break;
- }
-
-
do {
if (!got_params)
get_query_dispinfo_params(
loop_count, &max_entries, &max_size);
- result = rpccli_samr_query_dispinfo(cli, mem_ctx, &domain_pol,
- &start_idx, info_level,
- &num_entries, max_entries,
- max_size, &ctr);
+ result = rpccli_samr_QueryDisplayInfo(cli, mem_ctx,
+ &domain_pol,
+ info_level,
+ start_idx,
+ max_entries,
+ max_size,
+ &total_size,
+ &returned_size,
+ &info);
loop_count++;
+ switch (info_level) {
+ case 1:
+ num_entries = info.info1.count;
+ break;
+ case 2:
+ num_entries = info.info2.count;
+ break;
+ case 3:
+ num_entries = info.info3.count;
+ break;
+ case 4:
+ num_entries = info.info4.count;
+ break;
+ case 5:
+ num_entries = info.info5.count;
+ break;
+ default:
+ break;
+ }
+
+ start_idx += num_entries;
+
if (NT_STATUS_IS_ERR(result))
break;
@@ -1466,19 +1426,19 @@ static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
for (i = 0; i < num_entries; i++) {
switch (info_level) {
case 1:
- display_sam_info_1(&ctr.sam.info1->sam[i], &ctr.sam.info1->str[i]);
+ display_sam_info_1(&info.info1.entries[i]);
break;
case 2:
- display_sam_info_2(&ctr.sam.info2->sam[i], &ctr.sam.info2->str[i]);
+ display_sam_info_2(&info.info2.entries[i]);
break;
case 3:
- display_sam_info_3(&ctr.sam.info3->sam[i], &ctr.sam.info3->str[i]);
+ display_sam_info_3(&info.info3.entries[i]);
break;
case 4:
- display_sam_info_4(&ctr.sam.info4->sam[i], &ctr.sam.info4->str[i]);
+ display_sam_info_4(&info.info4.entries[i]);
break;
case 5:
- display_sam_info_5(&ctr.sam.info5->sam[i], &ctr.sam.info5->str[i]);
+ display_sam_info_5(&info.info5.entries[i]);
break;
}
}
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 612ae1cb2e..7d057132dd 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -1307,29 +1307,36 @@ static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid,
}
/* Query domain users */
- ZERO_STRUCT(ctr);
- ZERO_STRUCT(info1);
- ctr.sam.info1 = &info1;
if (opt_long_list_entries)
d_printf("\nUser name Comment"\
"\n-----------------------------\n");
do {
- fstring user, desc;
+ const char *user = NULL;
+ const char *desc = NULL;
uint32 max_entries, max_size;
+ uint32_t total_size, returned_size;
+ union samr_DispInfo info;
get_query_dispinfo_params(
loop_count, &max_entries, &max_size);
- result = rpccli_samr_query_dispinfo(pipe_hnd, mem_ctx, &domain_pol,
- &start_idx, 1, &num_entries,
- max_entries, max_size, &ctr);
+ result = rpccli_samr_QueryDisplayInfo(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 1,
+ start_idx,
+ max_entries,
+ max_size,
+ &total_size,
+ &returned_size,
+ &info);
loop_count++;
+ start_idx += info.info1.count;
+ num_entries = info.info1.count;
for (i = 0; i < num_entries; i++) {
- unistr2_to_ascii(user, &(&ctr.sam.info1->str[i])->uni_acct_name, sizeof(user));
- if (opt_long_list_entries)
- unistr2_to_ascii(desc, &(&ctr.sam.info1->str[i])->uni_acct_desc, sizeof(desc));
-
+ user = info.info1.entries[i].account_name.string;
+ if (opt_long_list_entries)
+ desc = info.info1.entries[i].description.string;
if (opt_long_list_entries)
printf("%-21.21s %s\n", user, desc);
else
@@ -2647,34 +2654,38 @@ static NTSTATUS rpc_group_list_internals(const DOM_SID *domain_sid,
d_printf("\nGroup name Comment"\
"\n-----------------------------\n");
do {
- SAM_DISPINFO_CTR ctr;
- SAM_DISPINFO_3 info3;
- uint32 max_size;
-
- ZERO_STRUCT(ctr);
- ZERO_STRUCT(info3);
- ctr.sam.info3 = &info3;
+ uint32_t max_size, total_size, returned_size;
+ union samr_DispInfo info;
if (!global) break;
get_query_dispinfo_params(
loop_count, &max_entries, &max_size);
- result = rpccli_samr_query_dispinfo(pipe_hnd, mem_ctx, &domain_pol,
- &start_idx, 3, &num_entries,
- max_entries, max_size, &ctr);
+ result = rpccli_samr_QueryDisplayInfo(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 3,
+ start_idx,
+ max_entries,
+ max_size,
+ &total_size,
+ &returned_size,
+ &info);
+ num_entries = info.info3.count;
+ start_idx += info.info3.count;
if (!NT_STATUS_IS_OK(result) &&
!NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES))
break;
-
+
for (i = 0; i < num_entries; i++) {
- fstring group, desc;
+ const char *group = NULL;
+ const char *desc = NULL;
+
+ group = info.info3.entries[i].account_name.string;
+ desc = info.info3.entries[i].description.string;
- unistr2_to_ascii(group, &(&ctr.sam.info3->str[i])->uni_grp_name, sizeof(group));
- unistr2_to_ascii(desc, &(&ctr.sam.info3->str[i])->uni_grp_desc, sizeof(desc));
-
if (opt_long_list_entries)
printf("%-21.21s %-50.50s\n",
group, desc);
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c
index 8e196e50ec..edcdd5f049 100644
--- a/source3/winbindd/winbindd_rpc.c
+++ b/source3/winbindd/winbindd_rpc.c
@@ -63,24 +63,26 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
do {
uint32 num_dom_users, j;
uint32 max_entries, max_size;
- SAM_DISPINFO_CTR ctr;
- SAM_DISPINFO_1 info1;
+ uint32_t total_size, returned_size;
- ZERO_STRUCT( ctr );
- ZERO_STRUCT( info1 );
- ctr.sam.info1 = &info1;
+ union samr_DispInfo disp_info;
/* this next bit is copied from net_user_list_internal() */
get_query_dispinfo_params(loop_count, &max_entries,
&max_size);
- result = rpccli_samr_query_dispinfo(cli, mem_ctx, &dom_pol,
- &start_idx, 1,
- &num_dom_users,
- max_entries, max_size,
- &ctr);
-
+ result = rpccli_samr_QueryDisplayInfo(cli, mem_ctx,
+ &dom_pol,
+ 1,
+ start_idx,
+ max_entries,
+ max_size,
+ &total_size,
+ &returned_size,
+ &disp_info);
+ num_dom_users = disp_info.info1.count;
+ start_idx += disp_info.info1.count;
loop_count++;
*num_entries += num_dom_users;
@@ -93,14 +95,13 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
}
for (j = 0; j < num_dom_users; i++, j++) {
- fstring username, fullname;
- uint32 rid = ctr.sam.info1->sam[j].rid_user;
-
- unistr2_to_ascii( username, &(&ctr.sam.info1->str[j])->uni_acct_name, sizeof(username));
- unistr2_to_ascii( fullname, &(&ctr.sam.info1->str[j])->uni_full_name, sizeof(fullname));
-
- (*info)[i].acct_name = talloc_strdup(mem_ctx, username );
- (*info)[i].full_name = talloc_strdup(mem_ctx, fullname );
+
+ uint32_t rid = disp_info.info1.entries[j].rid;
+
+ (*info)[i].acct_name = talloc_strdup(mem_ctx,
+ disp_info.info1.entries[j].account_name.string);
+ (*info)[i].full_name = talloc_strdup(mem_ctx,
+ disp_info.info1.entries[j].full_name.string);
(*info)[i].homedir = NULL;
(*info)[i].shell = NULL;
sid_compose(&(*info)[i].user_sid, &domain->sid, rid);