summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-09-24 18:53:40 +0200
committerGünther Deschner <gd@samba.org>2009-09-30 00:37:13 +0200
commit6c0abbdd350f9af5cfb59381efb80385e5d3a4f3 (patch)
tree8c2592231bb1602f7c4a9dbe38b3f17af4cfba96 /source3
parenteb7a40422593970eba0541a7e4deaa6bc31f94e0 (diff)
downloadsamba-6c0abbdd350f9af5cfb59381efb80385e5d3a4f3.tar.gz
samba-6c0abbdd350f9af5cfb59381efb80385e5d3a4f3.tar.bz2
samba-6c0abbdd350f9af5cfb59381efb80385e5d3a4f3.zip
s3-netlogon: properly implement _netr_NetrEnumerateTrustedDomains().
Guenther
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_server/srv_netlog_nt.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c
index 9169c74534..2aee00581b 100644
--- a/source3/rpc_server/srv_netlog_nt.c
+++ b/source3/rpc_server/srv_netlog_nt.c
@@ -229,20 +229,47 @@ WERROR _netr_LogonControl2Ex(pipes_struct *p,
WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p,
struct netr_NetrEnumerateTrustedDomains *r)
{
- struct netr_Blob trusted_domains_blob;
+ NTSTATUS status;
DATA_BLOB blob;
+ struct trustdom_info **domains;
+ uint32_t num_domains;
+ const char **trusted_domains;
+ int i;
DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__));
/* set up the Trusted Domain List response */
- blob = data_blob_talloc_zero(p->mem_ctx, 2);
- trusted_domains_blob.data = blob.data;
- trusted_domains_blob.length = blob.length;
+ become_root();
+ status = pdb_enum_trusteddoms(p->mem_ctx, &num_domains, &domains);
+ unbecome_root();
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
- DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__));
+ trusted_domains = talloc_zero_array(p->mem_ctx, const char *, num_domains + 1);
+ if (!trusted_domains) {
+ return WERR_NOMEM;
+ }
+
+ for (i = 0; i < num_domains; i++) {
+ trusted_domains[i] = talloc_strdup(trusted_domains, domains[i]->name);
+ if (!trusted_domains[i]) {
+ TALLOC_FREE(trusted_domains);
+ return WERR_NOMEM;
+ }
+ }
- *r->out.trusted_domains_blob = trusted_domains_blob;
+ if (!push_reg_multi_sz(trusted_domains, &blob, trusted_domains)) {
+ TALLOC_FREE(trusted_domains);
+ return WERR_NOMEM;
+ }
+
+ r->out.trusted_domains_blob->data = blob.data;
+ r->out.trusted_domains_blob->length = blob.length;
+
+ DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__));
return WERR_OK;
}