summaryrefslogtreecommitdiff
path: root/source4/scripting/python/samba/netcmd
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2012-12-28 15:37:14 +0100
committerAndrew Bartlett <abartlet@samba.org>2013-03-02 03:57:34 +0100
commit87afc3aee1ea593069322a49355dd8780d99e123 (patch)
tree8e1ea6678d93b53f21b34c4940b7d5a64e0f5020 /source4/scripting/python/samba/netcmd
parent80fce353e740c793619005ac102ab07fb5e7d280 (diff)
downloadsamba-87afc3aee1ea593069322a49355dd8780d99e123.tar.gz
samba-87afc3aee1ea593069322a49355dd8780d99e123.tar.bz2
samba-87afc3aee1ea593069322a49355dd8780d99e123.zip
Move python modules from source4/scripting/python/ to python/.
Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Sat Mar 2 03:57:34 CET 2013 on sn-devel-104
Diffstat (limited to 'source4/scripting/python/samba/netcmd')
-rw-r--r--source4/scripting/python/samba/netcmd/__init__.py231
-rw-r--r--source4/scripting/python/samba/netcmd/common.py71
-rw-r--r--source4/scripting/python/samba/netcmd/dbcheck.py143
-rw-r--r--source4/scripting/python/samba/netcmd/delegation.py263
-rw-r--r--source4/scripting/python/samba/netcmd/dns.py1186
-rw-r--r--source4/scripting/python/samba/netcmd/domain.py1344
-rw-r--r--source4/scripting/python/samba/netcmd/drs.py510
-rw-r--r--source4/scripting/python/samba/netcmd/dsacl.py182
-rw-r--r--source4/scripting/python/samba/netcmd/fsmo.py277
-rw-r--r--source4/scripting/python/samba/netcmd/gpo.py1177
-rw-r--r--source4/scripting/python/samba/netcmd/group.py376
-rw-r--r--source4/scripting/python/samba/netcmd/ldapcmp.py998
-rw-r--r--source4/scripting/python/samba/netcmd/main.py70
-rw-r--r--source4/scripting/python/samba/netcmd/ntacl.py260
-rw-r--r--source4/scripting/python/samba/netcmd/processes.py78
-rw-r--r--source4/scripting/python/samba/netcmd/rodc.py108
-rw-r--r--source4/scripting/python/samba/netcmd/sites.py105
-rw-r--r--source4/scripting/python/samba/netcmd/spn.py205
-rw-r--r--source4/scripting/python/samba/netcmd/testparm.py209
-rw-r--r--source4/scripting/python/samba/netcmd/time.py59
-rw-r--r--source4/scripting/python/samba/netcmd/user.py605
-rw-r--r--source4/scripting/python/samba/netcmd/vampire.py55
22 files changed, 0 insertions, 8512 deletions
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py
deleted file mode 100644
index a3edf505165..00000000000
--- a/source4/scripting/python/samba/netcmd/__init__.py
+++ /dev/null
@@ -1,231 +0,0 @@
-# Unix SMB/CIFS implementation.
-# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2009-2012
-# Copyright (C) Theresa Halloran <theresahalloran@gmail.com> 2011
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-
-import optparse, samba
-from samba import getopt as options
-from ldb import LdbError
-import sys, traceback
-import textwrap
-
-class Option(optparse.Option):
- pass
-
-# This help formatter does text wrapping and preserves newlines
-class PlainHelpFormatter(optparse.IndentedHelpFormatter):
- def format_description(self,description=""):
- desc_width = self.width - self.current_indent
- indent = " "*self.current_indent
- paragraphs = description.split('\n')
- wrapped_paragraphs = [
- textwrap.fill(p,
- desc_width,
- initial_indent=indent,
- subsequent_indent=indent)
- for p in paragraphs]
- result = "\n".join(wrapped_paragraphs) + "\n"
- return result
-
- def format_epilog(self, epilog):
- if epilog:
- return "\n" + epilog + "\n"
- else:
- return ""
-
-class Command(object):
- """A samba-tool command."""
-
- def _get_short_description(self):
- return self.__doc__.splitlines()[0].rstrip("\n")
-
- short_description = property(_get_short_description)
-
- def _get_full_description(self):
- lines = self.__doc__.split("\n")
- return lines[0] + "\n" + textwrap.dedent("\n".join(lines[1:]))
-
- full_description = property(_get_full_description)
-
- def _get_name(self):
- name = self.__class__.__name__
- if name.startswith("cmd_"):
- return name[4:]
- return name
-
- name = property(_get_name)
-
- # synopsis must be defined in all subclasses in order to provide the
- # command usage
- synopsis = None
- takes_args = []
- takes_options = []
- takes_optiongroups = {}
-
- hidden = False
-
- raw_argv = None
- raw_args = None
- raw_kwargs = None
-
- def __init__(self, outf=sys.stdout, errf=sys.stderr):
- self.outf = outf
- self.errf = errf
-
- def usage(self, prog, *args):
- parser, _ = self._create_parser(prog)
- parser.print_usage()
-
- def show_command_error(self, e):
- '''display a command error'''
- if isinstance(e, CommandError):
- (etype, evalue, etraceback) = e.exception_info
- inner_exception = e.inner_exception
- message = e.message
- force_traceback = False
- else:
- (etype, evalue, etraceback) = sys.exc_info()
- inner_exception = e
- message = "uncaught exception"
- force_traceback = True
-
- if isinstance(inner_exception, LdbError):
- (ldb_ecode, ldb_emsg) = inner_exception
- self.errf.write("ERROR(ldb): %s - %s\n" % (message, ldb_emsg))
- elif isinstance(inner_exception, AssertionError):
- self.errf.write("ERROR(assert): %s\n" % message)
- force_traceback = True
- elif isinstance(inner_exception, RuntimeError):
- self.errf.write("ERROR(runtime): %s - %s\n" % (message, evalue))
- elif type(inner_exception) is Exception:
- self.errf.write("ERROR(exception): %s - %s\n" % (message, evalue))
- force_traceback = True
- elif inner_exception is None:
- self.errf.write("ERROR: %s\n" % (message))
- else:
- self.errf.write("ERROR(%s): %s - %s\n" % (str(etype), message, evalue))
- force_traceback = True
-
- if force_traceback or samba.get_debug_level() >= 3:
- traceback.print_tb(etraceback)
-
- def _create_parser(self, prog, epilog=None):
- parser = optparse.OptionParser(
- usage=self.synopsis,
- description=self.full_description,
- formatter=PlainHelpFormatter(),
- prog=prog,epilog=epilog)
- parser.add_options(self.takes_options)
- optiongroups = {}
- for name, optiongroup in self.takes_optiongroups.iteritems():
- optiongroups[name] = optiongroup(parser)
- parser.add_option_group(optiongroups[name])
- return parser, optiongroups
-
- def message(self, text):
- self.outf.write(text+"\n")
-
- def _run(self, *argv):
- parser, optiongroups = self._create_parser(argv[0])
- opts, args = parser.parse_args(list(argv))
- # Filter out options from option groups
- args = args[1:]
- kwargs = dict(opts.__dict__)
- for option_group in parser.option_groups:
- for option in option_group.option_list:
- if option.dest is not None:
- del kwargs[option.dest]
- kwargs.update(optiongroups)
-
- # Check for a min a max number of allowed arguments, whenever possible
- # The suffix "?" means zero or one occurence
- # The suffix "+" means at least one occurence
- min_args = 0
- max_args = 0
- undetermined_max_args = False
- for i, arg in enumerate(self.takes_args):
- if arg[-1] != "?":
- min_args += 1
- if arg[-1] == "+":
- undetermined_max_args = True
- else:
- max_args += 1
- if (len(args) < min_args) or (not undetermined_max_args and len(args) > max_args):
- parser.print_usage()
- return -1
-
- self.raw_argv = list(argv)
- self.raw_args = args
- self.raw_kwargs = kwargs
-
- try:
- return self.run(*args, **kwargs)
- except Exception, e:
- self.show_command_error(e)
- return -1
-
- def run(self):
- """Run the command. This should be overriden by all subclasses."""
- raise NotImplementedError(self.run)
-
- def get_logger(self, name="netcmd"):
- """Get a logger object."""
- import logging
- logger = logging.getLogger(name)
- logger.addHandler(logging.StreamHandler(self.errf))
- return logger
-
-
-class SuperCommand(Command):
- """A samba-tool command with subcommands."""
-
- synopsis = "%prog <subcommand>"
-
- subcommands = {}
-
- def _run(self, myname, subcommand=None, *args):
- if subcommand in self.subcommands:
- return self.subcommands[subcommand]._run(
- "%s %s" % (myname, subcommand), *args)
-
- epilog = "\nAvailable subcommands:\n"
- subcmds = self.subcommands.keys()
- subcmds.sort()
- max_length = max([len(c) for c in subcmds])
- for cmd_name in subcmds:
- cmd = self.subcommands[cmd_name]
- if not cmd.hidden:
- epilog += " %*s - %s\n" % (
- -max_length, cmd_name, cmd.short_description)
- epilog += "For more help on a specific subcommand, please type: %s <subcommand> (-h|--help)\n" % myname
-
- parser, optiongroups = self._create_parser(myname, epilog=epilog)
- args_list = list(args)
- if subcommand:
- args_list.insert(0, subcommand)
- opts, args = parser.parse_args(args_list)
-
- parser.print_help()
- return -1
-
-
-class CommandError(Exception):
- """An exception class for samba-tool Command errors."""
-
- def __init__(self, message, inner_exception=None):
- self.message = message
- self.inner_exception = inner_exception
- self.exception_info = sys.exc_info()
diff --git a/source4/scripting/python/samba/netcmd/common.py b/source4/scripting/python/samba/netcmd/common.py
deleted file mode 100644
index 5c0bd95f089..00000000000
--- a/source4/scripting/python/samba/netcmd/common.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# common functions for samba-tool python commands
-#
-# Copyright Andrew Tridgell 2010
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-
-import re
-from samba.dcerpc import nbt
-from samba.net import Net
-
-
-def _get_user_realm_domain(user):
- """ get the realm or the domain and the base user
- from user like:
- * username
- * DOMAIN\username
- * username@REALM
- """
- baseuser = user
- realm = ""
- domain = ""
- m = re.match(r"(\w+)\\(\w+$)", user)
- if m:
- domain = m.group(1)
- baseuser = m.group(2)
- return (baseuser.lower(), domain.upper(), realm)
- m = re.match(r"(\w+)@(\w+)", user)
- if m:
- baseuser = m.group(1)
- realm = m.group(2)
- return (baseuser.lower(), domain, realm.upper())
-
-
-def netcmd_dnsname(lp):
- '''return the full DNS name of our own host. Used as a default
- for hostname when running status queries'''
- return lp.get('netbios name').lower() + "." + lp.get('realm').lower()
-
-
-def netcmd_finddc(lp, creds, realm=None):
- '''Return domain-name of a writable/ldap-capable DC for the default
- domain (parameter "realm" in smb.conf) unless another realm has been
- specified as argument'''
- net = Net(creds=creds, lp=lp)
- if realm is None:
- realm = lp.get('realm')
- cldap_ret = net.finddc(domain=realm,
- flags=nbt.NBT_SERVER_LDAP | nbt.NBT_SERVER_DS | nbt.NBT_SERVER_WRITABLE)
- return cldap_ret.pdc_dns_name
-
-
-def netcmd_get_domain_infos_via_cldap(lp, creds, address=None):
- '''Return domain informations (CLDAP record) of the ldap-capable
- DC with the specified address'''
- net = Net(creds=creds, lp=lp)
- cldap_ret = net.finddc(address=address,
- flags=nbt.NBT_SERVER_LDAP | nbt.NBT_SERVER_DS)
- return cldap_ret
diff --git a/source4/scripting/python/samba/netcmd/dbcheck.py b/source4/scripting/python/samba/netcmd/dbcheck.py
deleted file mode 100644
index 889b0ff075c..00000000000
--- a/source4/scripting/python/samba/netcmd/dbcheck.py
+++ /dev/null
@@ -1,143 +0,0 @@
-# Samba4 AD database checker
-#
-# Copyright (C) Andrew Tridgell 2011
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-
-import ldb, sys
-import samba.getopt as options
-from samba.auth import system_session
-from samba.samdb import SamDB
-from samba.netcmd import (
- Command,
- CommandError,
- Option
- )
-from samba.dbchecker import dbcheck
-
-
-class cmd_dbcheck(Command):
- """Check local AD database for errors."""
- synopsis = "%prog [<DN>] [options]"
-
- takes_optiongroups = {
- "sambaopts": options.SambaOptions,
- "versionopts": options.VersionOptions,
- "credopts": options.CredentialsOptionsDouble,
- }
-
- takes_args = ["DN?"]
-
- takes_options = [
- Option("--scope", dest="scope", default="SUB",
- help="Pass search scope that builds DN list. Options: SUB, ONE, BASE"),
- Option("--fix", dest="fix", default=False, action='store_true',
- help='Fix any errors found'),
- Option("--yes", dest="yes", default=False, action='store_true',
- help="don't confirm changes, just do them all as a single transaction"),
- Option("--cross-ncs", dest="cross_ncs", default=False, action='store_true',
- help="cross naming context boundaries"),
- Option("-v", "--verbose", dest="verbose", action="store_true", default=False,
- help="Print more details of checking"),
- Option("--quiet", dest="quiet", action="store_true", default=False,
- help="don't print details of checking"),
- Option("--attrs", dest="attrs", default=None, help="list of attributes to check (space separated)"),
- Option("--reindex", dest="reindex", default=False, action="store_true", help="force database re-index"),
- Option("--force-modules", dest="force_modules", default=False, action="store_true", help="force loading of Samba modules and ignore the @MODULES record (for very old databases)"),
- Option("-H", "--URL", help="LDB URL for database or target server (defaults to local SAM database)",
- type=str, metavar="URL", dest="H"),
- ]
-
- def run(self, DN=None, H=None, verbose=False, fix=False, yes=False,
- cross_ncs=False, quiet=False,
- scope="SUB", credopts=None, sambaopts=None, versionopts=None,
- attrs=None, reindex=False, force_modules=False):
-
- lp = sambaopts.get_loadparm()
-
- over_ldap = H is not None and H.startswith('ldap')
-
- if over_ldap:
- creds = credopts.get_credentials(lp, fallback_machine=True)
- else:
- creds = None
-
- if force_modules:
- samdb = SamDB(session_info=system_session(), url=H,
- credentials=creds, lp=lp, options=["modules=samba_dsdb"])
- else:
- try:
- samdb = SamDB(session_info=system_session(), url=H,
- credentials=creds, lp=lp)
- except:
- raise CommandError("Failed to connect to DB at %s. If this is a really old sam.ldb (before alpha9), then try again with --force-modules" % H)
-
-
- if H is None or not over_ldap:
- samdb_schema = samdb
- else:
- samdb_schema = SamDB(session_info=system_session(), url=None,
- credentials=creds, lp=lp)
-
- scope_map = { "SUB": ldb.SCOPE_SUBTREE, "BASE": ldb.SCOPE_BASE, "ONE":ldb.SCOPE_ONELEVEL }
- scope = scope.upper()
- if not scope in scope_map:
- raise CommandError("Unknown scope %s" % scope)
- search_scope = scope_map[scope]
-
- controls = ['show_deleted:1']
- if over_ldap:
- controls.append('paged_results:1:1000')
- if cross_ncs:
- controls.append("search_options:1:2")
-
- if not attrs:
- attrs = ['*']
- else:
- attrs = attrs.split()
-
- started_transaction = False
- if yes and fix:
- samdb.transaction_start()
- started_transaction = True
- try:
- chk = dbcheck(samdb, samdb_schema=samdb_schema, verbose=verbose,
- fix=fix, yes=yes, quiet=quiet, in_transaction=started_transaction)
-
- if reindex:
- self.outf.write("Re-indexing...\n")
- error_count = 0
- if chk.reindex_database():
- self.outf.write("completed re-index OK\n")
-
- elif force_modules:
- self.outf.write("Resetting @MODULES...\n")
- error_count = 0
- if chk.reset_modules():
- self.outf.write("completed @MODULES reset OK\n")
-
- else:
- error_count = chk.check_database(DN=DN, scope=search_scope,
- controls=controls, attrs=attrs)
- except:
- if started_transaction:
- samdb.transaction_cancel()
- raise
-
- if started_transaction:
- samdb.transaction_commit()
-
- if error_count != 0:
- sys.exit(1)
diff --git a/source4/scripting/python/samba/netcmd/delegation.py b/source4/scripting/python/samba/netcmd/delegation.py
deleted file mode 100644
index 47dffb07d51..00000000000
--- a/source4/scripting/python/samba/netcmd/delegation.py
+++ /dev/null
@@ -1,263 +0,0 @@
-# delegation management
-#
-# Copyright Matthieu Patou mat@samba.org 2010
-# Copyright Stefan Metzmacher metze@samba.org 2011
-# Copyright Bjoern Baumbach bb@sernet.de 2011
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-
-import samba.getopt as options
-import ldb
-from samba import provision
-from samba import dsdb
-from samba.samdb import SamDB
-from samba.auth import system_session
-from samba.netcmd.common import _get_user_realm_domain
-from samba.netcmd import (
- Command,
- CommandError,
- SuperCommand,
- Option
- )
-
-
-class cmd_delegation_show(Command):
- """Show the delegation setting of an account."""
-
- synopsis = "%prog <accountname> [options]"
-
- takes_optiongroups = {
- "sambaopts": options.SambaOptions,
- "credopts": options.CredentialsOptions,
- "versionopts": options.VersionOptions,
- }
-
- takes_args = ["accountname"]
-
- def run(self, accountname, credopts=None, sambaopts=None, versionopts=None):
- lp = sambaopts.get_loadparm()
- creds = credopts.get_credentials(lp)
- paths = provision.provision_paths_from_lp(lp, lp.get("realm"))
- sam = SamDB(paths.samdb, session_info=system_session(),
- credentials=creds, lp=lp)
- # TODO once I understand how, use the domain info to naildown
- # to the correct domain
- (cleanedaccount, realm, domain) = _get_user_realm_domain(accountname)
-
- res = sam.search(expression="sAMAccountName=%s" %
- ldb.binary_encode(cleanedaccount),
- scope=ldb.SCOPE_SUBTREE,
- attrs=["userAccountControl", "msDS-AllowedToDelegateTo"])
- if len(res) == 0:
- raise CommandError("Unable to find account name '%s'" % accountname)
- assert(len(res) == 1)
-
- uac = int(res[0].get("userAccountControl")[0])
- allowed = res[0].get("msDS-AllowedToDelegateTo")
-
- self.outf.write("Account-DN: %s\n" % str(res[0].dn))
- self.outf.write("UF_TRUSTED_FOR_DELEGATION: %s\n"
- % bool(uac & dsdb.UF_TRUSTED_FOR_DELEGATION))
- self.outf.write("UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION: %s\n" %
- bool(uac & dsdb.UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION))
-
- if allowed is not None:
- for a in allowed:
- self.outf.write("msDS-AllowedToDelegateTo: %s\n" % a)
-
-
-class cmd_delegation_for_any_service(Command):
- """Set/unset UF_TRUSTED_FOR_DELEGATION for an account."""
-
- synopsis = "%prog <accountname> [(on|off)] [options]"
-
- takes_optiongroups = {
- "sambaopts": options.SambaOptions,
- "credopts": options.CredentialsOptions,
- "versionopts": options.VersionOptions,
- }
-
- takes_args = ["accountname", "onoff"]
-
- def run(self, accountname, onoff, credopts=None, sambaopts=None,
- versionopts=None):
-
- on = False
- if onoff == "on":
- on = True
- elif onoff == "off":
- on = False
- else:
- raise CommandError("invalid argument: '%s' (choose from 'on', 'off')" % onoff)
-
- lp = sambaopts.get_loadparm()
- creds = credopts.get_credentials(lp)
- paths = provision.provision_paths_from_lp(lp, lp.get("realm"))
- sam = SamDB(paths.samdb, session_info=system_session(),
- credentials=creds, lp=lp)
- # TODO once I understand how, use the domain info to naildown
- # to the correct domain
- (cleanedaccount, realm, domain) = _get_user_realm_domain(accountname)
-
- search_filter = "sAMAccountName=%s" % ldb.binary_encode(cleanedaccount)
- flag = dsdb.UF_TRUSTED_FOR_DELEGATION
- try:
- sam.toggle_userAccountFlags(search_filter, flag,
- flags_str="Trusted-for-Delegation",
- on=on, strict=True)
- except Exception, err:
- raise CommandError(err)
-
-
-class cmd_delegation_for_any_protocol(Command):
- """Set/unset UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION (S4U2Proxy) for an account."""
-
- synopsis = "%prog <accountname> [(on|off)] [options]"
-
- takes_optiongroups = {
- "sambaopts": options.SambaOptions,
- "credopts": options.CredentialsOptions,
- "versionopts": options.VersionOptions,
- }
-
- takes_args = ["accountname", "onoff"]
-
- def run(self, accountname, onoff, credopts=None, sambaopts=None,
- versionopts=None):
-
- on = False
- if onoff == "on":
- on = True
- elif onoff == "off":
- on = False
- else:
- raise CommandError("invalid argument: '%s' (choose from 'on', 'off')" % onoff)
-
- lp = sambaopts.get_loadparm()
- creds = credopts.get_credentials(lp)
- paths = provision.provision_paths_from_lp(lp, lp.get("realm"))
- sam = SamDB(paths.samdb, session_info=system_session(),
- credentials=creds, lp=lp)
- # TODO once I understand how, use the domain info to naildown
- # to the correct domain
- (cleanedaccount, realm, domain) = _get_user_realm_domain(accountname)
-
- search_filter = "sAMAccountName=%s" % ldb.binary_encode(cleanedaccount)
- flag = dsdb.UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION
- try:
- sam.toggle_userAccountFlags(search_filter, flag,
- flags_str="Trusted-to-Authenticate-for-Delegation",
- on=on, strict=True)
- except Exception, err:
- raise CommandError(err)
-
-
-class cmd_delegation_add_service(Command):
- """Add a service principal as msDS-AllowedToDelegateTo."""
-
- synopsis = "%prog <accountname> <principal> [options]"
-
- takes_optiongroups = {
- "sambaopts": options.SambaOptions,
- "credopts": options.CredentialsOptions,
- "versionopts": options.VersionOptions,
- }
-
- takes_args = ["accountname", "principal"]
-
- def run(self, accountname, principal, credopts=None, sambaopts=None,
- versionopts=None):
-
- lp = sambaopts.get_loadparm()
- creds = credopts.get_credentials(lp)
- paths = provision.provision_paths_from_lp(lp, lp.get("realm"))
- sam = SamDB(paths.samdb, session_info=system_session(),
- credentials=creds, lp=lp)
- # TODO once I understand how, use the domain info to naildown
- # to the correct domain
- (cleanedaccount, realm, domain) = _get_user_realm_domain(accountname)
-
- res = sam.search(expression="sAMAccountName=%s" %
- ldb.binary_encode(cleanedaccount),
- scope=ldb.SCOPE_SUBTREE,
- attrs=["msDS-AllowedToDelegateTo"])
- if len(res) == 0:
- raise CommandError("Unable to find account name '%s'" % accountname)
- assert(len(res) == 1)
-
- msg = ldb.Message()
- msg.dn = res[0].dn
- msg["msDS-AllowedToDelegateTo"] = ldb.MessageElement([principal],
- ldb.FLAG_MOD_ADD,
- "msDS-AllowedToDelegateTo")
- try:
- sam.modify(msg)
- except Exception, err:
- raise CommandError(err)
-
-
-class cmd_delegation_del_service(Command):
- """Delete a service principal as msDS-AllowedToDelegateTo."""
-
- synopsis = "%prog <accountname> <principal> [options]"
-
- takes_optiongroups = {
- "sambaopts": options.SambaOptions,
- "credopts": options.CredentialsOptions,
- "versionopts": options.VersionOptions,
- }
-
- takes_args = ["accountname", "principal"]
-
- def run(self, accountname, principal, credopts=None, sambaopts=None,
- versionopts=None):
-
- lp = sambaopts.get_loadparm()
- creds = credopts.get_credentials(lp)
- paths = provision.provision_paths_from_lp(lp, lp.get("realm"))
- sam = SamDB(paths.samdb, session_info=system_session(),
- credentials=creds, lp=lp)
- # TODO once I understand how, use the domain info to naildown
- # to the correct domain
- (cleanedaccount, realm, domain) = _get_user_realm_domain(accountname)
-
- res = sam.search(expression="sAMAccountName=%s" %
- ldb.binary_encode(cleanedaccount),
- scope=ldb.SCOPE_SUBTREE,
- attrs=["msDS-AllowedToDelegateTo"])
- if len(res) == 0:
- raise CommandError("Unable to find account name '%s'" % accountname)
- assert(len(res) == 1)
-
- msg = ldb.Message()
- msg.dn = res[0].dn
- msg["msDS-AllowedToDelegateTo"] = ldb.MessageElement([principal],
- ldb.FLAG_MOD_DELETE,
- "msDS-AllowedToDelegateTo")
- try:
- sam.modify(msg)
- except Exception, err:
- raise CommandError(err)
-
-
-class cmd_delegation(SuperCommand):
- """Delegation management."""
-
- subcommands = {}
- subcommands["show"] = cmd_delegation_show()
- subcommands["for-any-service"] = cmd_delegation_for_any_service()
- subcommands["for-any-protocol"] = cmd_delegation_for_any_protocol()
- subcommands["add-service"] = cmd_delegation_add_service()
- subcommands["del-service"] = cmd_delegation_del_service()
diff --git a/source4/scripting/python/samba/netcmd/dns.py b/source4/scripting/python/samba/netcmd/dns.py
deleted file mode 100644
index c00d17ad727..00000000000
--- a/source4/scripting/python/samba/netcmd/dns.py
+++ /dev/null
@@ -1,1186 +0,0 @@
-# DNS management tool
-#
-# Copyright (C) Amitay Isaacs 2011-2012
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULA