s4 dns: Check more of the returned values for the A query
[Samba/gebeck_regimport.git] / source4 / scripting / python / samba / netcmd / time.py
blob966799e7db714dff3191021a53cfe4fdc0791f5d
1 #!/usr/bin/env python
3 # time
5 # Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
6 # Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 import samba.getopt as options
23 import common
24 from samba.net import Net
26 from samba.netcmd import (
27 Command,
30 class cmd_time(Command):
31 """Retrieve the time on a server
33 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.
35 Example1:
36 samba-tool time samdom.example.com
38 Example1 returns the date and time of the server samdom.example.com.
40 Example2:
41 samba-tool time
43 Example2 return the date and time of the local server.
44 """
45 synopsis = "%prog [server-name] [options]"
47 takes_args = ["server_name?"]
49 def run(self, server_name=None, credopts=None, sambaopts=None, versionopts=None):
50 lp = sambaopts.get_loadparm()
51 creds = credopts.get_credentials(lp, fallback_machine=True)
52 net = Net(creds, lp, server=credopts.ipaddress)
53 if server_name is None:
54 server_name = common.netcmd_dnsname(lp)
55 self.outf.write(net.time(server_name)+"\n")