2 Samba Unix/Linux SMB client library
3 Distributed SMB/CIFS Server Management Utility
5 Copyright (C) 2004 Stefan Metzmacher (metze@samba.org)
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * Code for getting the remote time
29 int net_time(struct net_context *ctx, int argc, const char **argv)
32 struct libnet_context *libnetctx;
33 union libnet_RemoteTOD r;
34 const char *server_name;
38 if (argc > 0 && argv[0]) {
39 server_name = argv[0];
41 DEBUG(0,("net_time: server name needed!\n"));
45 libnetctx = libnet_context_init();
49 libnetctx->user.account_name = ctx->user.account_name;
50 libnetctx->user.domain_name = ctx->user.domain_name;
51 libnetctx->user.password = ctx->user.password;
53 /* prepare to get the time */
54 r.generic.level = LIBNET_REMOTE_TOD_GENERIC;
55 r.generic.in.server_name = server_name;
58 status = libnet_RemoteTOD(libnetctx, ctx->mem_ctx, &r);
59 if (!NT_STATUS_IS_OK(status)) {
60 DEBUG(0,("net_time: %s\n",r.generic.out.error_string));
65 tm = localtime(&r.generic.out.time);
66 strftime(timestr, sizeof(timestr)-1, "%c %Z",tm);
68 printf("%s\n",timestr);
70 libnet_context_destroy(&libnetctx);
75 int net_time_usage(struct net_context *ctx, int argc, const char **argv)
77 d_printf("net_time_usage: TODO\n");
81 int net_time_help(struct net_context *ctx, int argc, const char **argv)
83 d_printf("net_time_help: TODO\n");