summaryrefslogtreecommitdiff
path: root/source3/winbindd/winbindd_msrpc.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-17 13:56:54 +0200
committerAndreas Schneider <asn@samba.org>2010-07-05 15:59:09 +0200
commit11610a4e996fd70a2df3b1124f8e658cc9188827 (patch)
tree352fc6830974989f4a9cebaf2a372de24ef39b37 /source3/winbindd/winbindd_msrpc.c
parentbec184048ee691d9f709365f65104a53f2f33cc0 (diff)
downloadsamba-11610a4e996fd70a2df3b1124f8e658cc9188827.tar.gz
samba-11610a4e996fd70a2df3b1124f8e658cc9188827.tar.bz2
samba-11610a4e996fd70a2df3b1124f8e658cc9188827.zip
s3-winbind: Use rpc_enum_dom_groups in msrpc.
Diffstat (limited to 'source3/winbindd/winbindd_msrpc.c')
-rw-r--r--source3/winbindd/winbindd_msrpc.c94
1 files changed, 42 insertions, 52 deletions
diff --git a/source3/winbindd/winbindd_msrpc.c b/source3/winbindd/winbindd_msrpc.c
index 1515cfa6e3..9dba883c47 100644
--- a/source3/winbindd/winbindd_msrpc.c
+++ b/source3/winbindd/winbindd_msrpc.c
@@ -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"));
+
+ if (pnum_info) {
+ *pnum_info = 0;
+ }
- DEBUG(3,("rpc: enum_dom_groups\n"));
+ 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;
-
- do {
- struct samr_SamArray *sam_array = NULL;
- uint32 count = 0;
- TALLOC_CTX *mem_ctx2;
- int g;
-
- mem_ctx2 = talloc_init("enum_dom_groups[rpc]");
-
- /* 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;
- }
+ status = cm_connect_sam(domain, tmp_ctx, &samr_pipe, &dom_pol);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
- for (g=0; g < count; g++) {
+ status = rpc_enum_dom_groups(tmp_ctx,
+ samr_pipe,
+ &dom_pol,
+ &num_info,
+ &info);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
- fstrcpy((*info)[*num_entries + g].acct_name,
- sam_array->entries[g].name.string);
- (*info)[*num_entries + g].rid = sam_array->entries[g].idx;
- }
+ if (pnum_info) {
+ *pnum_info = num_info;
+ }
- (*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,