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, result;
- struct dcerpc_binding_handle *b = lsa_pipe->binding_handle;
-
- do {
- struct lsa_DomainList dom_list;
- struct lsa_DomainListEx dom_list_ex;
- bool has_ex = false;
- uint32_t i;
-
- /*
- * We don't run into deadlocks here, cause winbind_off() is
- * called in the main function.
- */
- status = dcerpc_lsa_EnumTrustedDomainsEx(b,
- mem_ctx,
- lsa_policy,
- &enum_ctx,
- &dom_list_ex,
- (uint32_t) -1,
- &result);
- if (NT_STATUS_IS_OK(status) && !NT_STATUS_IS_ERR(result) &&
- dom_list_ex.count > 0) {
- count += dom_list_ex.count;
- has_ex = true;
- } else {
- status = dcerpc_lsa_EnumTrustDom(b,
- mem_ctx,
- lsa_policy,
- &enum_ctx,
- &dom_list,
- (uint32_t) -1,
- &result);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
- if (!NT_STATUS_IS_OK(result)) {
- if (!NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
- return result;
- }
- }
-
- 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 < count; i++) {
- struct netr_DomainTrust *trust = &array[i];
- struct dom_sid *sid;
-
- ZERO_STRUCTP(trust);
-
- sid = talloc(array, struct dom_sid);
- if (sid == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- if (dom_list_ex.domains[i].sid == NULL) {
- DBG_ERR("Trusted domain %s has no SID, "
- "skipping!\n",
- trust->dns_name);
- continue;
- }
-
- if (has_ex) {
- trust->netbios_name = talloc_move(array,
- &dom_list_ex.domains[i].netbios_name.string);
- trust->dns_name = talloc_move(array,
- &dom_list_ex.domains[i].domain_name.string);
- sid_copy(sid, dom_list_ex.domains[i].sid);
- } else {
- trust->netbios_name = talloc_move(array,
- &dom_list.domains[i].name.string);
- trust->dns_name = NULL;
-
- sid_copy(sid, dom_list.domains[i].sid);
- }
-
- trust->sid = sid;
- }
- } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
-
- *pnum_trusts = count;
- *ptrusts = array;
-
- return NT_STATUS_OK;
-}
-
static NTSTATUS rpc_try_lookup_sids3(TALLOC_CTX *mem_ctx,
struct winbindd_domain *domain,
struct rpc_pipe_client *cli,