When connecting to an AD DC, use the DsGetDCName variant.
authorGerald (Jerry) Carter <jerry@samba.org>
Fri, 4 Jan 2008 19:31:07 +0000 (13:31 -0600)
committerGerald (Jerry) Carter <jerry@samba.org>
Fri, 4 Jan 2008 19:31:07 +0000 (13:31 -0600)
This allows us to deal with child domains in transitive forest trusts.
It also allows us to fill in the forest name to the target domain to the
struct winbindd_domain *.

source/winbindd/winbindd_cm.c

index 33674d2cf70e12c929a77d0c80afbf542ed483ee..99e401d53f24d2dcb6fcf442a5a7ab4a5679a805 100644 (file)
@@ -601,8 +601,34 @@ static bool get_dc_name_via_netlogon(const struct winbindd_domain *domain,
 
        orig_timeout = cli_set_timeout(netlogon_pipe->cli, 35000);
        
-       werr = rpccli_netlogon_getanydcname(netlogon_pipe, mem_ctx, our_domain->dcname,
+       if (our_domain->active_directory) {
+               struct DS_DOMAIN_CONTROLLER_INFO *domain_info = NULL;
+               
+               werr = rpccli_netlogon_dsr_getdcname(netlogon_pipe, 
+                                                    mem_ctx, 
+                                                    our_domain->dcname,
+                                                    domain->name,
+                                                    NULL,
+                                                    NULL,
+                                                    DS_RETURN_DNS_NAME,
+                                                    &domain_info);
+               if (W_ERROR_IS_OK(werr)) {
+                       fstrcpy(tmp, domain_info->domain_controller_name);
+                       if (strlen(domain->alt_name) == 0) {
+                               fstrcpy(domain->alt_name, 
+                                       CONST_DISCARD(char*, domain_info->domain_name));
+                       }
+                       if (strlen(domain->forest_name) == 0) {
+                               fstrcpy(domain->forest_name, 
+                                       CONST_DISCARD(char*, domain_info->dns_forest_name));
+                       }
+               }               
+       } else {
+               
+               werr = rpccli_netlogon_getanydcname(netlogon_pipe, mem_ctx, 
+                                                   our_domain->dcname,
                                            domain->name, &tmp);
+       }
 
        /* And restore our original timeout. */
        cli_set_timeout(netlogon_pipe->cli, orig_timeout);
@@ -1869,9 +1895,17 @@ no_lsarpc_ds:
                if (dns_name)
                        fstrcpy(domain->alt_name, dns_name);
 
-               if ( forest_name )
+               /* See if we can set some domain trust flags about
+                  ourself */
+
+               if ( forest_name ) {
                        fstrcpy(domain->forest_name, forest_name);              
 
+                       if (strequal(domain->forest_name, domain->alt_name)) {
+                               domain->domain_flags = DS_DOMAIN_TREE_ROOT;
+                       }
+               }
+
                if (dom_sid) 
                        sid_copy(&domain->sid, dom_sid);
        } else {