ctdb-scripts: Improve update and listing code
[samba4-gss.git] / python / samba / netcmd / domain / leave.py
blob0d58360721e0f421935405b980990d7f071ff5c0
1 # domain management - domain leave
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.net_s3 import Net as s3_Net
27 from samba.netcmd import Command, Option
28 from samba.param import default_path
29 from samba.samba3 import param as s3param
32 class cmd_domain_leave(Command):
33 """Cause a domain member to leave the joined domain."""
35 synopsis = "%prog [options]"
37 takes_optiongroups = {
38 "sambaopts": options.SambaOptions,
39 "versionopts": options.VersionOptions,
40 "credopts": options.CredentialsOptions,
43 takes_options = [
44 Option("--keep-account", action="store_true",
45 help="Disable the machine account instead of deleting it.")
48 takes_args = []
50 def run(self, sambaopts=None, credopts=None, versionopts=None,
51 keep_account=False):
52 lp = sambaopts.get_loadparm()
53 creds = credopts.get_credentials(lp)
55 s3_lp = s3param.get_context()
56 smb_conf = lp.configfile if lp.configfile else default_path()
57 s3_lp.load(smb_conf)
58 s3_net = s3_Net(creds, s3_lp)
59 s3_net.leave(keep_account)