s4:libnet/py_net.c: "py_net_finddc" - add an "address" parameter
[sfrench/samba-autobuild/.git] / source4 / libnet / libnet_time.c
index 655a4755038e9d0a9e2e07e4dba73ef047a89953..e3b6275207c2a341d6defa1636a8c6d40da046bc 100644 (file)
@@ -5,7 +5,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,
    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/>.
 */
 
 #include "includes.h"
 #include "libnet/libnet.h"
-#include "librpc/gen_ndr/ndr_srvsvc.h"
 #include "system/time.h"
+#include "librpc/gen_ndr/ndr_srvsvc_c.h"
 
 /*
  * get the remote time of a server via srvsvc_NetRemoteTOD
@@ -31,30 +30,34 @@ static NTSTATUS libnet_RemoteTOD_srvsvc(struct libnet_context *ctx, TALLOC_CTX *
         NTSTATUS status;
        struct libnet_RpcConnect c;
        struct srvsvc_NetRemoteTOD tod;
+       struct srvsvc_NetRemoteTODInfo *info = NULL;
        struct tm tm;
 
+       ZERO_STRUCT(c);
+
        /* prepare connect to the SRVSVC pipe of a timeserver */
-       c.level                    = LIBNET_RPC_CONNECT_SERVER;
-       c.in.domain_name           = r->srvsvc.in.server_name;
-       c.in.dcerpc_iface          = &dcerpc_table_srvsvc;
+       c.level             = LIBNET_RPC_CONNECT_SERVER;
+       c.in.name           = r->srvsvc.in.server_name;
+       c.in.dcerpc_iface   = &ndr_table_srvsvc;
 
        /* 1. connect to the SRVSVC pipe of a timeserver */
        status = libnet_RpcConnect(ctx, mem_ctx, &c);
        if (!NT_STATUS_IS_OK(status)) {
                r->srvsvc.out.error_string = talloc_asprintf(mem_ctx,
-                                               "Connection to SRVSVC pipe of server '%s' failed: %s\n",
+                                               "Connection to SRVSVC pipe of server '%s' failed: %s",
                                                r->srvsvc.in.server_name, nt_errstr(status));
                return status;
        }
 
        /* prepare srvsvc_NetrRemoteTOD */
-       tod.in.server_unc = talloc_asprintf(mem_ctx, "\\%s", c.in.domain_name);
+       tod.in.server_unc = talloc_asprintf(mem_ctx, "\\%s", c.in.name);
+       tod.out.info = &info;
 
        /* 2. try srvsvc_NetRemoteTOD */
-       status = dcerpc_srvsvc_NetRemoteTOD(c.out.dcerpc_pipe, mem_ctx, &tod);
+       status = dcerpc_srvsvc_NetRemoteTOD_r(c.out.dcerpc_pipe->binding_handle, mem_ctx, &tod);
        if (!NT_STATUS_IS_OK(status)) {
                r->srvsvc.out.error_string = talloc_asprintf(mem_ctx,
-                                               "srvsvc_NetrRemoteTOD on server '%s' failed: %s\n",
+                                               "srvsvc_NetrRemoteTOD on server '%s' failed: %s",
                                                r->srvsvc.in.server_name, nt_errstr(status));
                goto disconnect;
        }
@@ -62,25 +65,25 @@ static NTSTATUS libnet_RemoteTOD_srvsvc(struct libnet_context *ctx, TALLOC_CTX *
        /* check result of srvsvc_NetrRemoteTOD */
        if (!W_ERROR_IS_OK(tod.out.result)) {
                r->srvsvc.out.error_string = talloc_asprintf(mem_ctx,
-                                               "srvsvc_NetrRemoteTOD on server '%s' failed: %s\n",
+                                               "srvsvc_NetrRemoteTOD on server '%s' failed: %s",
                                                r->srvsvc.in.server_name, win_errstr(tod.out.result));
                status = werror_to_ntstatus(tod.out.result);
                goto disconnect;
        }
 
        /* need to set the out parameters */
-       tm.tm_sec = (int)tod.out.info->secs;
-       tm.tm_min = (int)tod.out.info->mins;
-       tm.tm_hour = (int)tod.out.info->hours;
-       tm.tm_mday = (int)tod.out.info->day;
-       tm.tm_mon = (int)tod.out.info->month -1;
-       tm.tm_year = (int)tod.out.info->year - 1900;
+       tm.tm_sec = (int)info->secs;
+       tm.tm_min = (int)info->mins;
+       tm.tm_hour = (int)info->hours;
+       tm.tm_mday = (int)info->day;
+       tm.tm_mon = (int)info->month -1;
+       tm.tm_year = (int)info->year - 1900;
        tm.tm_wday = -1;
        tm.tm_yday = -1;
        tm.tm_isdst = -1;
 
        r->srvsvc.out.time = timegm(&tm);
-       r->srvsvc.out.time_zone = tod.out.info->timezone * 60;
+       r->srvsvc.out.time_zone = info->timezone * 60;
 
        goto disconnect;