From 9c372a145dacfabd14dd86b6dbc458f20ce73fe9 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 21 Jun 2010 11:13:25 +0200 Subject: s3-winbind: Added a common rpc_trusted_domains function. --- source3/winbindd/winbindd_rpc.c | 69 +++++++++++++++++++++++++++++++++++++++++ source3/winbindd/winbindd_rpc.h | 7 +++++ 2 files changed, 76 insertions(+) (limited to 'source3') diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c index 05638244ec..785e01319e 100644 --- a/source3/winbindd/winbindd_rpc.c +++ b/source3/winbindd/winbindd_rpc.c @@ -832,3 +832,72 @@ seq_num: return status; } + +/* Get a list of trusted domains */ +NTSTATUS rpc_trusted_domains(TALLOC_CTX *mem_ctx, + struct rpc_pipe_client *lsa_pipe, + struct policy_handle *lsa_policy, + uint32_t *pnum_trusts, + struct netr_DomainTrust **ptrusts) +{ + struct netr_DomainTrust *array = NULL; + uint32_t enum_ctx = 0; + uint32_t count = 0; + NTSTATUS status; + + 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, + mem_ctx, + lsa_policy, + &enum_ctx, + &dom_list, + (uint32_t) -1); + if (!NT_STATUS_IS_OK(status)) { + if (!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { + return status; + } + } + + start_idx = count; + count += dom_list.count; + + array = talloc_realloc(mem_ctx, + array, + struct netr_DomainTrust, + count); + if (array == NULL) { + return NT_STATUS_NO_MEMORY; + } + + 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) { + return NT_STATUS_NO_MEMORY; + } + sid_copy(sid, dom_list.domains[i].sid); + trust->sid = sid; + } + } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)); + + *pnum_trusts = count; + *ptrusts = array; + + return NT_STATUS_OK; +} diff --git a/source3/winbindd/winbindd_rpc.h b/source3/winbindd/winbindd_rpc.h index fb1abd0575..42405df6e0 100644 --- a/source3/winbindd/winbindd_rpc.h +++ b/source3/winbindd/winbindd_rpc.h @@ -124,4 +124,11 @@ NTSTATUS rpc_sequence_number(TALLOC_CTX *mem_ctx, const char *domain_name, uint32_t *pseq); +/* Get a list of trusted domains */ +NTSTATUS rpc_trusted_domains(TALLOC_CTX *mem_ctx, + struct rpc_pipe_client *lsa_pipe, + struct policy_handle *lsa_policy, + uint32_t *pnum_trusts, + struct netr_DomainTrust **ptrusts); + #endif /* _WINBINDD_RPC_H_ */ -- cgit