summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/rpcclient/cmd_samr.c30
-rw-r--r--source3/winbindd/winbindd_rpc.c37
2 files changed, 38 insertions, 29 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index e751c4d132..ccea73e5a1 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -696,11 +696,11 @@ static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
DOM_SID *sids;
size_t num_sids;
- uint32 num_aliases, *alias_rids;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
int i;
fstring server;
- DOM_SID2 *sid2;
+ struct lsa_SidArray sid_array;
+ struct samr_Ids alias_rids;
if (argc < 3) {
printf("Usage: %s builtin|domain sid1 sid2 ...\n", argv[0]);
@@ -723,18 +723,22 @@ static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
}
if (num_sids) {
- sid2 = TALLOC_ARRAY(mem_ctx, DOM_SID2, num_sids);
- if (sid2 == NULL)
+ sid_array.sids = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_SidPtr, num_sids);
+ if (sid_array.sids == NULL)
return NT_STATUS_NO_MEMORY;
} else {
- sid2 = NULL;
+ sid_array.sids = NULL;
}
for (i=0; i<num_sids; i++) {
- sid_copy(&sid2[i].sid, &sids[i]);
- sid2[i].num_auths = sid2[i].sid.num_auths;
+ sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sids[i]);
+ if (!sid_array.sids[i].sid) {
+ return NT_STATUS_NO_MEMORY;
+ }
}
+ sid_array.num_sids = num_sids;
+
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
@@ -763,15 +767,15 @@ static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_query_useraliases(cli, mem_ctx, &domain_pol,
- num_sids, sid2,
- &num_aliases, &alias_rids);
-
+ result = rpccli_samr_GetAliasMembership(cli, mem_ctx,
+ &domain_pol,
+ &sid_array,
+ &alias_rids);
if (!NT_STATUS_IS_OK(result))
goto done;
- for (i = 0; i < num_aliases; i++) {
- printf("\tgroup rid:[0x%x]\n", alias_rids[i]);
+ for (i = 0; i < alias_rids.count; i++) {
+ printf("\tgroup rid:[0x%x]\n", alias_rids.ids[i]);
}
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c
index 0d937ef30e..7e35759348 100644
--- a/source3/winbindd/winbindd_rpc.c
+++ b/source3/winbindd/winbindd_rpc.c
@@ -585,11 +585,10 @@ NTSTATUS msrpc_lookup_useraliases(struct winbindd_domain *domain,
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
POLICY_HND dom_pol;
- DOM_SID2 *query_sids;
uint32 num_query_sids = 0;
int i;
struct rpc_pipe_client *cli;
- uint32 *alias_rids_query, num_aliases_query;
+ struct samr_Ids alias_rids_query;
int rangesize = MAX_SAM_ENTRIES_W2K;
uint32 total_sids = 0;
int num_queries = 1;
@@ -611,6 +610,9 @@ NTSTATUS msrpc_lookup_useraliases(struct winbindd_domain *domain,
do {
/* prepare query */
+ struct lsa_SidArray sid_array;
+
+ ZERO_STRUCT(sid_array);
num_query_sids = MIN(num_sids - total_sids, rangesize);
@@ -618,45 +620,48 @@ NTSTATUS msrpc_lookup_useraliases(struct winbindd_domain *domain,
num_queries, num_query_sids));
if (num_query_sids) {
- query_sids = TALLOC_ARRAY(mem_ctx, DOM_SID2, num_query_sids);
- if (query_sids == NULL) {
+ sid_array.sids = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_SidPtr, num_query_sids);
+ if (sid_array.sids == NULL) {
return NT_STATUS_NO_MEMORY;
}
} else {
- query_sids = NULL;
+ sid_array.sids = NULL;
}
for (i=0; i<num_query_sids; i++) {
- sid_copy(&query_sids[i].sid, &sids[total_sids++]);
- query_sids[i].num_auths = query_sids[i].sid.num_auths;
+ sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sids[total_sids++]);
+ if (sid_array.sids[i].sid) {
+ TALLOC_FREE(sid_array.sids);
+ return NT_STATUS_NO_MEMORY;
+ }
}
+ sid_array.num_sids = num_query_sids;
/* do request */
-
- result = rpccli_samr_query_useraliases(cli, mem_ctx, &dom_pol,
- num_query_sids, query_sids,
- &num_aliases_query,
- &alias_rids_query);
+ result = rpccli_samr_GetAliasMembership(cli, mem_ctx,
+ &dom_pol,
+ &sid_array,
+ &alias_rids_query);
if (!NT_STATUS_IS_OK(result)) {
*num_aliases = 0;
*alias_rids = NULL;
- TALLOC_FREE(query_sids);
+ TALLOC_FREE(sid_array.sids);
goto done;
}
/* process output */
- for (i=0; i<num_aliases_query; i++) {
+ for (i=0; i<alias_rids_query.count; i++) {
size_t na = *num_aliases;
- if (!add_rid_to_array_unique(mem_ctx, alias_rids_query[i],
+ if (!add_rid_to_array_unique(mem_ctx, alias_rids_query.ids[i],
alias_rids, &na)) {
return NT_STATUS_NO_MEMORY;
}
*num_aliases = na;
}
- TALLOC_FREE(query_sids);
+ TALLOC_FREE(sid_array.sids);
num_queries++;