summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-21 11:14:12 +0200
committerAndreas Schneider <asn@samba.org>2010-07-05 15:59:15 +0200
commit973ef399e3b7853e68bf8d3d54700fd2c89a9611 (patch)
treed2c6a78f26768fe17eb86ba7b10003a1483faf54 /source3
parentb4160af73646f48073778b610938c9f67a5f6e39 (diff)
downloadsamba-973ef399e3b7853e68bf8d3d54700fd2c89a9611.tar.gz
samba-973ef399e3b7853e68bf8d3d54700fd2c89a9611.tar.bz2
samba-973ef399e3b7853e68bf8d3d54700fd2c89a9611.zip
s3-winbind: Use rpc_trusted_domains in msrpc.
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/winbindd_msrpc.c91
1 files changed, 35 insertions, 56 deletions
diff --git a/source3/winbindd/winbindd_msrpc.c b/source3/winbindd/winbindd_msrpc.c
index b7476b6ebd..2fbfd21c4a 100644
--- a/source3/winbindd/winbindd_msrpc.c
+++ b/source3/winbindd/winbindd_msrpc.c
@@ -890,70 +890,49 @@ done:
}
/* get a list of trusted domains */
-static NTSTATUS trusted_domains(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- struct netr_DomainTrustList *trusts)
+static NTSTATUS msrpc_trusted_domains(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ struct netr_DomainTrustList *ptrust_list)
{
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 enum_ctx = 0;
- struct rpc_pipe_client *cli;
+ struct rpc_pipe_client *lsa_pipe;
struct policy_handle lsa_policy;
+ struct netr_DomainTrust *trusts = NULL;
+ uint32_t num_trusts = 0;
+ TALLOC_CTX *tmp_ctx;
+ NTSTATUS status;
- DEBUG(3,("rpc: trusted_domains\n"));
-
- ZERO_STRUCTP(trusts);
-
- result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
- if (!NT_STATUS_IS_OK(result))
- return result;
-
- result = STATUS_MORE_ENTRIES;
-
- while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
- uint32 start_idx;
- int i;
- struct lsa_DomainList dom_list;
-
- result = rpccli_lsa_EnumTrustDom(cli, mem_ctx,
- &lsa_policy,
- &enum_ctx,
- &dom_list,
- (uint32_t)-1);
-
- if (!NT_STATUS_IS_OK(result) &&
- !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES))
- break;
-
- start_idx = trusts->count;
- trusts->count += dom_list.count;
+ DEBUG(3,("samr: trusted domains\n"));
- trusts->array = talloc_realloc(
- mem_ctx, trusts->array, struct netr_DomainTrust,
- trusts->count);
- if (trusts->array == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
+ if (ptrust_list) {
+ ZERO_STRUCTP(ptrust_list);
+ }
- for (i=0; i<dom_list.count; i++) {
- struct netr_DomainTrust *trust = &trusts->array[i];
- struct dom_sid *sid;
+ tmp_ctx = talloc_stackframe();
+ if (tmp_ctx == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
- ZERO_STRUCTP(trust);
+ status = cm_connect_lsa(domain, tmp_ctx, &lsa_pipe, &lsa_policy);
+ if (!NT_STATUS_IS_OK(status))
+ return status;
- trust->netbios_name = talloc_move(
- trusts->array,
- &dom_list.domains[i].name.string);
- trust->dns_name = NULL;
+ status = rpc_trusted_domains(tmp_ctx,
+ lsa_pipe,
+ &lsa_policy,
+ &num_trusts,
+ &trusts);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
- sid = talloc(trusts->array, struct dom_sid);
- if (sid == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- sid_copy(sid, dom_list.domains[i].sid);
- trust->sid = sid;
- }
+ if (ptrust_list) {
+ ptrust_list->count = num_trusts;
+ ptrust_list->array = talloc_move(mem_ctx, &trusts);
}
- return result;
+
+done:
+ TALLOC_FREE(tmp_ctx);
+ return status;
}
/* find the lockout policy for a domain */
@@ -1185,5 +1164,5 @@ struct winbindd_methods msrpc_methods = {
msrpc_sequence_number,
msrpc_lockout_policy,
msrpc_password_policy,
- trusted_domains,
+ msrpc_trusted_domains,
};