Doh ! Lookup name before checking negative cache (the way Tim originally
[tprouty/samba.git] / source / nsswitch / winbindd_cm.c
index 97d9159f66ee9737ab1a1640f7a4abb6aa1a6b27..0de6c9022bcc5551ec72e99b8107f2f6762b3c86 100644 (file)
@@ -398,6 +398,16 @@ static NTSTATUS cm_open_connection(const char *domain,const char *pipe_name,
        fstrcpy(new_conn->domain, domain);
        fstrcpy(new_conn->pipe_name, pipe_name);
        
+       /* Look for a domain controller for this domain.  Negative results
+          are cached so don't bother applying the caching for this
+          function just yet.  */
+
+       if (!cm_get_dc_name(domain, new_conn->controller, &dc_ip)) {
+               result = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
+               add_failed_connection_entry(new_conn, result);
+               return result;
+       }
+               
        /* Return false if we have tried to look up this domain and netbios
           name before and failed. */
 
@@ -429,16 +439,6 @@ static NTSTATUS cm_open_connection(const char *domain,const char *pipe_name,
                return result;
        }
 
-       /* Look for a domain controller for this domain.  Negative results
-          are cached so don't bother applying the caching for this
-          function just yet.  */
-
-       if (!cm_get_dc_name(domain, new_conn->controller, &dc_ip)) {
-               result = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
-               add_failed_connection_entry(new_conn, result);
-               return result;
-       }
-               
        /* Initialise SMB connection */
 
        cm_get_ipc_userpass(&ipc_username, &ipc_domain, &ipc_password);