.gitlab-ci-main.yml: Add safe.directory '*'
[Samba.git] / python / samba / netcmd / domain / info.py
blob8454cb33124aaedb452d3864a0f508d0b9bc0a5d
1 # domain management - domain info
3 # Copyright Matthias Dieter Wallnoefer 2009
4 # Copyright Andrew Kroeger 2009
5 # Copyright Jelmer Vernooij 2007-2012
6 # Copyright Giampaolo Lauria 2011
7 # Copyright Matthieu Patou <mat@matws.net> 2011
8 # Copyright Andrew Bartlett 2008-2015
9 # Copyright Stefan Metzmacher 2012
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 import samba.getopt as options
26 from samba.netcmd import Command, CommandError
27 from samba.netcmd.common import netcmd_get_domain_infos_via_cldap
30 class cmd_domain_info(Command):
31 """Print basic info about a domain and the DC passed as parameter."""
33 synopsis = "%prog <ip_address> [options]"
35 takes_options = [
38 takes_optiongroups = {
39 "sambaopts": options.SambaOptions,
40 "credopts": options.CredentialsOptions,
41 "versionopts": options.VersionOptions,
44 takes_args = ["address"]
46 def run(self, address, credopts=None, sambaopts=None, versionopts=None):
47 lp = sambaopts.get_loadparm()
48 try:
49 res = netcmd_get_domain_infos_via_cldap(lp, None, address)
50 except RuntimeError:
51 raise CommandError("Invalid IP address '" + address + "'!")
52 self.outf.write("Forest : %s\n" % res.forest)
53 self.outf.write("Domain : %s\n" % res.dns_domain)
54 self.outf.write("Netbios domain : %s\n" % res.domain_name)
55 self.outf.write("DC name : %s\n" % res.pdc_dns_name)
56 self.outf.write("DC netbios name : %s\n" % res.pdc_name)
57 self.outf.write("Server site : %s\n" % res.server_site)
58 self.outf.write("Client site : %s\n" % res.client_site)