summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-21 11:13:50 +0200
committerAndreas Schneider <asn@samba.org>2010-07-05 15:59:14 +0200
commitb4160af73646f48073778b610938c9f67a5f6e39 (patch)
treeebf4856926eecce95d4eada730966aaa8d702ea9
parent9c372a145dacfabd14dd86b6dbc458f20ce73fe9 (diff)
downloadsamba-b4160af73646f48073778b610938c9f67a5f6e39.tar.gz
samba-b4160af73646f48073778b610938c9f67a5f6e39.tar.bz2
samba-b4160af73646f48073778b610938c9f67a5f6e39.zip
s3-winbind: Use rpc_trusted_domains in samr.
-rw-r--r--source3/winbindd/winbindd_samr.c81
1 files changed, 20 insertions, 61 deletions
diff --git a/source3/winbindd/winbindd_samr.c b/source3/winbindd/winbindd_samr.c
index 12298e1829..35d4c00181 100644
--- a/source3/winbindd/winbindd_samr.c
+++ b/source3/winbindd/winbindd_samr.c
@@ -325,18 +325,21 @@ done:
/* get a list of trusted domains - builtin domain */
static NTSTATUS sam_trusted_domains(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- struct netr_DomainTrustList *trusts)
+ struct netr_DomainTrustList *ptrust_list)
{
struct rpc_pipe_client *lsa_pipe;
- struct netr_DomainTrust *array = NULL;
struct policy_handle lsa_policy;
- uint32_t enum_ctx = 0;
- uint32_t count = 0;
+ struct netr_DomainTrust *trusts = NULL;
+ uint32_t num_trusts = 0;
TALLOC_CTX *tmp_ctx;
NTSTATUS status;
DEBUG(3,("samr: trusted domains\n"));
+ if (ptrust_list) {
+ ZERO_STRUCTP(ptrust_list);
+ }
+
tmp_ctx = talloc_stackframe();
if (tmp_ctx == NULL) {
return NT_STATUS_NO_MEMORY;
@@ -344,68 +347,24 @@ static NTSTATUS sam_trusted_domains(struct winbindd_domain *domain,
status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
if (!NT_STATUS_IS_OK(status)) {
- goto error;
+ goto done;
}
- do {
- struct lsa_DomainList dom_list;
- uint32_t start_idx;
- uint32_t i;
-
- /*
- * We don't run into deadlocks here, cause winbind_off() is
- * called in the main function.
- */
- status = rpccli_lsa_EnumTrustDom(lsa_pipe,
- tmp_ctx,
- &lsa_policy,
- &enum_ctx,
- &dom_list,
- (uint32_t) -1);
- if (!NT_STATUS_IS_OK(status)) {
- if (!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
- goto error;
- }
- }
-
- start_idx = trusts->count;
- count += dom_list.count;
-
- array = talloc_realloc(tmp_ctx,
- array,
- struct netr_DomainTrust,
- count);
- if (array == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto error;
- }
-
- for (i = 0; i < dom_list.count; i++) {
- struct netr_DomainTrust *trust = &array[i];
- struct dom_sid *sid;
-
- ZERO_STRUCTP(trust);
-
- trust->netbios_name = talloc_move(array,
- &dom_list.domains[i].name.string);
- trust->dns_name = NULL;
-
- sid = talloc(array, struct dom_sid);
- if (sid == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto error;
- }
- sid_copy(sid, dom_list.domains[i].sid);
- trust->sid = sid;
- }
- } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
+ status = rpc_trusted_domains(tmp_ctx,
+ lsa_pipe,
+ &lsa_policy,
+ &num_trusts,
+ &trusts);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
- if (trusts) {
- trusts->count = count;
- trusts->array = talloc_move(mem_ctx, &array);
+ if (ptrust_list) {
+ ptrust_list->count = num_trusts;
+ ptrust_list->array = talloc_move(mem_ctx, &trusts);
}
-error:
+done:
TALLOC_FREE(tmp_ctx);
return status;
}