diff options
author | Andreas Schneider <asn@samba.org> | 2010-06-21 11:13:25 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2010-07-05 15:59:14 +0200 |
commit | 9c372a145dacfabd14dd86b6dbc458f20ce73fe9 (patch) | |
tree | f3133877b2a5d401b21e416e39a67bb10e3833bf /source3/winbindd | |
parent | b8a0b95e74bf4e57d5ee5e15a91c7b27f7edd3c6 (diff) | |
download | samba-9c372a145dacfabd14dd86b6dbc458f20ce73fe9.tar.gz samba-9c372a145dacfabd14dd86b6dbc458f20ce73fe9.tar.bz2 samba-9c372a145dacfabd14dd86b6dbc458f20ce73fe9.zip |
s3-winbind: Added a common rpc_trusted_domains function.
Diffstat (limited to 'source3/winbindd')
-rw-r--r-- | source3/winbindd/winbindd_rpc.c | 69 | ||||
-rw-r--r-- | source3/winbindd/winbindd_rpc.h | 7 |
2 files changed, 76 insertions, 0 deletions
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_ */ |