summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-07 21:46:02 +0200
committerAndreas Schneider <asn@samba.org>2010-07-05 15:59:06 +0200
commit41939ce32f66c288e51013648adfdcae64a97396 (patch)
tree00b696247f524e5c57cfee9ac27a2d49bbc9c9e5 /source3
parent48147555d2a2e879b027c09fb48c2ab7c40f4126 (diff)
downloadsamba-41939ce32f66c288e51013648adfdcae64a97396.tar.gz
samba-41939ce32f66c288e51013648adfdcae64a97396.tar.bz2
samba-41939ce32f66c288e51013648adfdcae64a97396.zip
s3-winbind: Implemented samr backend function sam_trusted_domains.
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/winbindd_samr.c83
1 files changed, 81 insertions, 2 deletions
diff --git a/source3/winbindd/winbindd_samr.c b/source3/winbindd/winbindd_samr.c
index 57a9d58292..2cf3b649bf 100644
--- a/source3/winbindd/winbindd_samr.c
+++ b/source3/winbindd/winbindd_samr.c
@@ -474,8 +474,87 @@ static NTSTATUS sam_trusted_domains(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
struct netr_DomainTrustList *trusts)
{
- /* TODO FIXME */
- return NT_STATUS_NOT_IMPLEMENTED;
+ 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;
+ TALLOC_CTX *tmp_ctx;
+ NTSTATUS status;
+
+ DEBUG(3,("samr: trusted domains\n"));
+
+ tmp_ctx = talloc_stackframe();
+ if (tmp_ctx == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto error;
+ }
+
+ 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));
+
+ if (trusts) {
+ trusts->count = count;
+ trusts->array = talloc_move(mem_ctx, &array);
+ }
+
+error:
+ TALLOC_FREE(tmp_ctx);
+ return status;
}
/* Lookup group membership given a rid. */