Author: vlendec
Date: 2005-10-27 11:01:29 +0000 (Thu, 27 Oct 2005)
New Revision: 11323

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11323

Log:
Fix usage of rpccli_netlogon_getdcname. Add some debug messages.

Volker

Modified:
   branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c
   trunk/source/nsswitch/winbindd_cm.c


Changeset:
Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c    2005-10-27 10:45:16 UTC 
(rev 11322)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c    2005-10-27 11:01:29 UTC 
(rev 11323)
@@ -116,6 +116,7 @@
        struct rpc_pipe_client *netlogon_pipe;
        NTSTATUS result;
        TALLOC_CTX *mem_ctx;
+       const char *server_name;
 
        fstring tmp;
        char *p;
@@ -142,13 +143,21 @@
                return False;
        }
 
-       result = rpccli_netlogon_getdcname(netlogon_pipe, mem_ctx, 
domain->dcname,
+       server_name = talloc_asprintf(mem_ctx, "\\\\%s", our_domain->dcname);
+       if (server_name == NULL) {
+               return False;
+       }
+
+       result = rpccli_netlogon_getdcname(netlogon_pipe, mem_ctx, server_name,
                                           domain->name, tmp);
 
        talloc_destroy(mem_ctx);
 
-       if (!NT_STATUS_IS_OK(result))
+       if (!NT_STATUS_IS_OK(result)) {
+               DEBUG(10, ("rpccli_netlogon_getdcname failed: %s\n",
+                          nt_errstr(result)));
                return False;
+       }
 
        /* cli_netlogon_getdcname gives us a name with \\ */
        p = tmp;
@@ -161,6 +170,8 @@
 
        fstrcpy(dcname, p);
 
+       DEBUG(10, ("rpccli_netlogon_getdcname returned %s\n", dcname));
+
        if (!resolve_name(dcname, dc_ip, 0x20)) {
                return False;
        }
@@ -417,8 +428,10 @@
                              const char *dcname, struct in_addr ip,
                              struct dc_name_ip **dcs, int *num)
 {
-       if (!NT_STATUS_IS_OK(check_negative_conn_cache(domain_name, dcname)))
+       if (!NT_STATUS_IS_OK(check_negative_conn_cache(domain_name, dcname))) {
+               DEBUG(10, ("DC %s was in the negative conn cache\n", dcname));
                return False;
+       }
 
        *dcs = TALLOC_REALLOC_ARRAY(mem_ctx, *dcs, struct dc_name_ip, (*num)+1);
 
@@ -657,6 +670,8 @@
                && get_dc_name_via_netlogon(domain, dcname, &ip) 
                && add_one_dc_unique(mem_ctx, domain->name, dcname, ip, dcs, 
num_dcs) )
        {
+               DEBUG(10, ("Retrieved DC %s at %s via netlogon\n",
+                          dcname, inet_ntoa(ip)));
                return True;
        }
 

Modified: trunk/source/nsswitch/winbindd_cm.c
===================================================================
--- trunk/source/nsswitch/winbindd_cm.c 2005-10-27 10:45:16 UTC (rev 11322)
+++ trunk/source/nsswitch/winbindd_cm.c 2005-10-27 11:01:29 UTC (rev 11323)
@@ -116,6 +116,7 @@
        struct rpc_pipe_client *netlogon_pipe;
        NTSTATUS result;
        TALLOC_CTX *mem_ctx;
+       const char *server_name;
 
        fstring tmp;
        char *p;
@@ -142,13 +143,21 @@
                return False;
        }
 
-       result = rpccli_netlogon_getdcname(netlogon_pipe, mem_ctx, 
domain->dcname,
+       server_name = talloc_asprintf(mem_ctx, "\\\\%s", our_domain->dcname);
+       if (server_name == NULL) {
+               return False;
+       }
+
+       result = rpccli_netlogon_getdcname(netlogon_pipe, mem_ctx, server_name,
                                           domain->name, tmp);
 
        talloc_destroy(mem_ctx);
 
-       if (!NT_STATUS_IS_OK(result))
+       if (!NT_STATUS_IS_OK(result)) {
+               DEBUG(10, ("rpccli_netlogon_getdcname failed: %s\n",
+                          nt_errstr(result)));
                return False;
+       }
 
        /* cli_netlogon_getdcname gives us a name with \\ */
        p = tmp;
@@ -161,6 +170,8 @@
 
        fstrcpy(dcname, p);
 
+       DEBUG(10, ("rpccli_netlogon_getdcname returned %s\n", dcname));
+
        if (!resolve_name(dcname, dc_ip, 0x20)) {
                return False;
        }
@@ -417,8 +428,10 @@
                              const char *dcname, struct in_addr ip,
                              struct dc_name_ip **dcs, int *num)
 {
-       if (!NT_STATUS_IS_OK(check_negative_conn_cache(domain_name, dcname)))
+       if (!NT_STATUS_IS_OK(check_negative_conn_cache(domain_name, dcname))) {
+               DEBUG(10, ("DC %s was in the negative conn cache\n", dcname));
                return False;
+       }
 
        *dcs = TALLOC_REALLOC_ARRAY(mem_ctx, *dcs, struct dc_name_ip, (*num)+1);
 
@@ -657,6 +670,8 @@
                && get_dc_name_via_netlogon(domain, dcname, &ip) 
                && add_one_dc_unique(mem_ctx, domain->name, dcname, ip, dcs, 
num_dcs) )
        {
+               DEBUG(10, ("Retrieved DC %s at %s via netlogon\n",
+                          dcname, inet_ntoa(ip)));
                return True;
        }
 

Reply via email to