1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

s3-winbind: Use rpc_enum_dom_groups in msrpc.

This commit is contained in:
Andreas Schneider 2010-06-17 13:56:54 +02:00
parent bec184048e
commit 11610a4e99

View File

@ -24,6 +24,8 @@
#include "includes.h"
#include "winbindd.h"
#include "winbindd_rpc.h"
#include "../librpc/gen_ndr/cli_samr.h"
#include "rpc_client/cli_samr.h"
#include "../librpc/gen_ndr/cli_lsa.h"
@ -135,72 +137,60 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
}
/* list all domain groups */
static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
uint32 *num_entries,
struct acct_info **info)
static NTSTATUS msrpc_enum_dom_groups(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
uint32_t *pnum_info,
struct acct_info **pinfo)
{
struct rpc_pipe_client *samr_pipe;
struct policy_handle dom_pol;
struct acct_info *info = NULL;
uint32_t num_info = 0;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
uint32 start = 0;
struct rpc_pipe_client *cli;
*num_entries = 0;
*info = NULL;
DEBUG(3,("msrpc_enum_dom_groups\n"));
DEBUG(3,("rpc: enum_dom_groups\n"));
if (pnum_info) {
*pnum_info = 0;
}
tmp_ctx = talloc_stackframe();
if (tmp_ctx == NULL) {
return NT_STATUS_NO_MEMORY;
}
if ( !winbindd_can_contact_domain( domain ) ) {
DEBUG(10,("enum_domain_groups: No incoming trust for domain %s\n",
domain->name));
return NT_STATUS_OK;
status = NT_STATUS_OK;
goto done;
}
status = cm_connect_sam(domain, mem_ctx, &cli, &dom_pol);
if (!NT_STATUS_IS_OK(status))
return status;
status = cm_connect_sam(domain, tmp_ctx, &samr_pipe, &dom_pol);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
do {
struct samr_SamArray *sam_array = NULL;
uint32 count = 0;
TALLOC_CTX *mem_ctx2;
int g;
status = rpc_enum_dom_groups(tmp_ctx,
samr_pipe,
&dom_pol,
&num_info,
&info);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
mem_ctx2 = talloc_init("enum_dom_groups[rpc]");
if (pnum_info) {
*pnum_info = num_info;
}
/* start is updated by this call. */
status = rpccli_samr_EnumDomainGroups(cli, mem_ctx2,
&dom_pol,
&start,
&sam_array,
0xFFFF, /* buffer size? */
&count);
if (!NT_STATUS_IS_OK(status) &&
!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
talloc_destroy(mem_ctx2);
break;
}
(*info) = TALLOC_REALLOC_ARRAY(mem_ctx, *info,
struct acct_info,
(*num_entries) + count);
if (! *info) {
talloc_destroy(mem_ctx2);
return NT_STATUS_NO_MEMORY;
}
for (g=0; g < count; g++) {
fstrcpy((*info)[*num_entries + g].acct_name,
sam_array->entries[g].name.string);
(*info)[*num_entries + g].rid = sam_array->entries[g].idx;
}
(*num_entries) += count;
talloc_destroy(mem_ctx2);
} while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
if (pinfo) {
*pinfo = talloc_move(mem_ctx, &info);
}
done:
TALLOC_FREE(tmp_ctx);
return status;
}
@ -1314,7 +1304,7 @@ NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
struct winbindd_methods msrpc_methods = {
False,
query_user_list,
enum_dom_groups,
msrpc_enum_dom_groups,
enum_local_groups,
msrpc_name_to_sid,
msrpc_sid_to_name,