summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2014-08-18 13:14:04 +1200
committerAndrew Bartlett <abartlet@samba.org>2014-09-01 00:36:42 +0200
commit5602377fcec03ee57cb87c1600b519484c6adc10 (patch)
tree96c75acf9a0c512b6659167e2a7fcc0b021c9296
parent1c979b1cfc483b88f169e90ba20f773001bcfc26 (diff)
downloadsamba-5602377fcec03ee57cb87c1600b519484c6adc10.tar.gz
set_dc_type_and_flags_trustinfo: Use init_dc_connection and wb_open_internal_pipe
This means we call this code, and mark trusted domains as active directory, when we are an AD DC. Otherwise, in the previous case we would not have domain->active_directory set, and would fail on connection_ok() due to not having a full connection to our internal DC Change-Id: I7ccee569d69d6c5466334540db8920e57aafa991 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--source3/winbindd/winbindd_cm.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 1e898d27b30..95c0aa8ed27 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -2020,38 +2020,46 @@ static bool set_dc_type_and_flags_trustinfo( struct winbindd_domain *domain )
return False;
}
+ mem_ctx = talloc_stackframe();
our_domain = find_our_domain();
-
- if ( !connection_ok(our_domain) ) {
- DEBUG(3,("set_dc_type_and_flags_trustinfo: No connection to our domain!\n"));
- return False;
+ if (our_domain->internal) {
+ result = init_dc_connection(our_domain, false);
+ if (!NT_STATUS_IS_OK(result)) {
+ DEBUG(3,("set_dc_type_and_flags_trustinfo: "
+ "Not able to make a connection to our domain: %s\n",
+ nt_errstr(result)));
+ TALLOC_FREE(mem_ctx);
+ return false;
+ }
}
/* This won't work unless our domain is AD */
-
if ( !our_domain->active_directory ) {
+ TALLOC_FREE(mem_ctx);
return False;
}
- /* Use DsEnumerateDomainTrusts to get us the trust direction
- and type */
-
- result = cm_connect_netlogon(our_domain, &cli);
+ if (our_domain->internal) {
+ result = wb_open_internal_pipe(mem_ctx, &ndr_table_netlogon, &cli);
+ } else if (!connection_ok(our_domain)) {
+ DEBUG(3,("set_dc_type_and_flags_trustinfo: "
+ "No connection to our domain!\n"));
+ TALLOC_FREE(mem_ctx);
+ return False;
+ } else {
+ result = cm_connect_netlogon(our_domain, &cli);
+ }
if (!NT_STATUS_IS_OK(result)) {
DEBUG(5, ("set_dc_type_and_flags_trustinfo: Could not open "
"a connection to %s for PIPE_NETLOGON (%s)\n",
domain->name, nt_errstr(result)));
+ TALLOC_FREE(mem_ctx);
return False;
}
-
b = cli->binding_handle;
- if ( (mem_ctx = talloc_init("set_dc_type_and_flags_trustinfo")) == NULL ) {
- DEBUG(0,("set_dc_type_and_flags_trustinfo: talloc_init() failed!\n"));
- return False;
- }
-
+ /* Use DsEnumerateDomainTrusts to get us the trust direction and type. */
result = dcerpc_netr_DsrEnumerateDomainTrusts(b, mem_ctx,
cli->desthost,
flags,
@@ -2061,14 +2069,14 @@ static bool set_dc_type_and_flags_trustinfo( struct winbindd_domain *domain )
DEBUG(0,("set_dc_type_and_flags_trustinfo: "
"failed to query trusted domain list: %s\n",
nt_errstr(result)));
- talloc_destroy(mem_ctx);
+ TALLOC_FREE(mem_ctx);
return false;
}
if (!W_ERROR_IS_OK(werr)) {
DEBUG(0,("set_dc_type_and_flags_trustinfo: "
"failed to query trusted domain list: %s\n",
win_errstr(werr)));
- talloc_destroy(mem_ctx);
+ TALLOC_FREE(mem_ctx);
return false;
}
@@ -2105,7 +2113,7 @@ static bool set_dc_type_and_flags_trustinfo( struct winbindd_domain *domain )
}
}
- talloc_destroy( mem_ctx );
+ TALLOC_FREE(mem_ctx);
return domain->initialized;
}