smbd/nmbd: Remove HAVE_LONGLONG
[Samba.git] / python / samba / netcmd / time.py
blob694b6adda9bc94f44f1af4570751b974c8ba42d8
1 # time
3 # Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import samba.getopt as options
20 import common
21 from samba.net import Net
23 from samba.netcmd import (
24 Command,
27 class cmd_time(Command):
28 """Retrieve the time on a server.
30 This command returns the date and time of the Active Directory server specified on the command. The server name specified may be the local server or a remote server. If the servername is not specified, the command returns the time and date of the local AD server.
32 Example1:
33 samba-tool time samdom.example.com
35 Example1 returns the date and time of the server samdom.example.com.
37 Example2:
38 samba-tool time
40 Example2 return the date and time of the local server.
41 """
42 synopsis = "%prog [server-name] [options]"
44 takes_optiongroups = {
45 "sambaopts": options.SambaOptions,
46 "credopts": options.CredentialsOptions,
47 "versionopts": options.VersionOptions,
50 takes_args = ["server_name?"]
52 def run(self, server_name=None, credopts=None, sambaopts=None,
53 versionopts=None):
54 lp = sambaopts.get_loadparm()
55 creds = credopts.get_credentials(lp, fallback_machine=True)
56 net = Net(creds, lp, server=credopts.ipaddress)
57 if server_name is None:
58 server_name = common.netcmd_dnsname(lp)
59 self.outf.write(net.time(server_name)+"\n")