summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_server')
-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;
}