r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
[vlendec/samba-autobuild/.git] / source3 / nsswitch / winbindd_cm.c
index ba91239a7396203409044f9e1c81854e33aa4105..269dab0389b976eb52db0e59ac5b8996a3114c48 100644 (file)
@@ -11,7 +11,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -20,8 +20,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
@@ -258,9 +257,7 @@ static void check_domain_online_handler(struct event_context *ctx,
                  "%s (online = %s)\n", domain->name, 
                  domain->online ? "True" : "False" ));
 
-       if (domain->check_online_event) {
-               TALLOC_FREE(domain->check_online_event);
-       }
+       TALLOC_FREE(domain->check_online_event);
 
        /* Are we still in "startup" mode ? */
 
@@ -312,9 +309,7 @@ void set_domain_offline(struct winbindd_domain *domain)
        DEBUG(10,("set_domain_offline: called for domain %s\n",
                domain->name ));
 
-       if (domain->check_online_event) {
-               TALLOC_FREE(domain->check_online_event);
-       }
+       TALLOC_FREE(domain->check_online_event);
 
        if (domain->internal) {
                DEBUG(3,("set_domain_offline: domain %s is internal - logic error.\n",
@@ -353,7 +348,7 @@ void set_domain_offline(struct winbindd_domain *domain)
 
        /* The above *has* to succeed for winbindd to work. */
        if (!domain->check_online_event) {
-               smb_panic("set_domain_offline: failed to add online handler.\n");
+               smb_panic("set_domain_offline: failed to add online handler");
        }
 
        DEBUG(10,("set_domain_offline: added event handler for domain %s\n",
@@ -426,9 +421,7 @@ static void set_domain_online(struct winbindd_domain *domain)
 
        /* Ensure we have no online timeout checks. */
        domain->check_online_timeout = 0;
-       if (domain->check_online_event) {
-               TALLOC_FREE(domain->check_online_event);
-       }
+       TALLOC_FREE(domain->check_online_event);
 
        /* Ensure we ignore any pending child messages. */
        messaging_deregister(winbind_messaging_context(),
@@ -496,7 +489,7 @@ void set_domain_online_request(struct winbindd_domain *domain)
 
                /* The above *has* to succeed for winbindd to work. */
                if (!domain->check_online_event) {
-                       smb_panic("set_domain_online_request: failed to add online handler.\n");
+                       smb_panic("set_domain_online_request: failed to add online handler");
                }
        }
 
@@ -602,8 +595,8 @@ static BOOL get_dc_name_via_netlogon(const struct winbindd_domain *domain,
 
        orig_timeout = cli_set_timeout(netlogon_pipe->cli, 35000);
        
-       werr = rpccli_netlogon_getdcname(netlogon_pipe, mem_ctx, our_domain->dcname,
-                                          domain->name, tmp);
+       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);
@@ -611,12 +604,12 @@ static BOOL get_dc_name_via_netlogon(const struct winbindd_domain *domain,
        talloc_destroy(mem_ctx);
 
        if (!W_ERROR_IS_OK(werr)) {
-               DEBUG(10, ("rpccli_netlogon_getdcname failed: %s\n",
+               DEBUG(10, ("rpccli_netlogon_getanydcname failed: %s\n",
                           dos_errstr(werr)));
                return False;
        }
 
-       /* cli_netlogon_getdcname gives us a name with \\ */
+       /* cli_netlogon_getanydcname gives us a name with \\ */
        p = tmp;
        if (*p == '\\') {
                p+=1;
@@ -627,7 +620,7 @@ static BOOL get_dc_name_via_netlogon(const struct winbindd_domain *domain,
 
        fstrcpy(dcname, p);
 
-       DEBUG(10, ("rpccli_netlogon_getdcname returned %s\n", dcname));
+       DEBUG(10, ("rpccli_netlogon_getanydcname returned %s\n", dcname));
 
        if (!resolve_name(dcname, dc_ip, 0x20)) {
                return False;
@@ -2201,6 +2194,12 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
  no_schannel:
        if ((lp_client_schannel() == False) ||
                        ((neg_flags & NETLOGON_NEG_SCHANNEL) == 0)) {
+
+               /*
+                * NetSamLogonEx only works for schannel
+                */
+               domain->can_do_samlogon_ex = False;
+
                /* We're done - just keep the existing connection to NETLOGON
                 * open */
                conn->netlogon_pipe = netlogon_pipe;
@@ -2232,6 +2231,11 @@ NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
                return !NT_STATUS_IS_OK(result) ? result : NT_STATUS_PIPE_NOT_AVAILABLE;
        }
 
+       /*
+        * Try NetSamLogonEx for AD domains
+        */
+       domain->can_do_samlogon_ex = domain->active_directory;
+       
        *cli = conn->netlogon_pipe;
        return NT_STATUS_OK;
 }