# Unix SMB/CIFS implementation.
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2009-2011
# Copyright (C) Theresa Halloran <theresahalloran@gmail.com> 2011
-# Copyright (C) Giampaolo Lauria <lauria2@yahoo.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
synopsis = None
takes_args = []
takes_options = []
- takes_optiongroups = {
- "sambaopts": options.SambaOptions,
- "credopts": options.CredentialsOptions,
- "versionopts": options.VersionOptions,
- }
+ takes_optiongroups = {}
def __init__(self, outf=sys.stdout, errf=sys.stderr):
self.outf = outf
# Samba4 AD database checker
#
# Copyright (C) Andrew Tridgell 2011
-# 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
"""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 = [
# Copyright Matthieu Patou mat@samba.org 2010
# Copyright Stefan Metzmacher metze@samba.org 2011
# Copyright Bjoern Baumbach bb@sernet.de 2011
-# 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
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):
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):
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):
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):
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):
synopsis = "%prog <keytab> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
takes_options = [
Option("--principal", help="extract only this principal", type=str),
]
synopsis = "%prog <dnsdomain> [DC|RODC|MEMBER|SUBDOMAIN] [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("--server", help="DC to join", type=str),
Option("--site", help="site to join", type=str),
except ldb.LdbError, l:
pass
- print "Demote successfull"
+ self.outf.write("Demote successfull\n")
synopsis = "%prog (show|raise <options>) [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H"),
raise CommandError("invalid argument: '%s' (choose from 'show', 'raise')" % subcommand)
-
class cmd_domain_passwordsettings(Command):
"""Sets password settings
synopsis = "%prog (show|set <options>) [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H"),
# implement samba_tool drs commands
#
# Copyright Andrew Tridgell 2010
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
#
# based on C implementation by Kamen Mazdrashki <kamen.mazdrashki@postpath.com>
#
synopsis = "%prog [<DC>] [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_args = ["DC?"]
def print_neighbour(self, n):
synopsis = "%prog [<DC>] [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_args = ["DC?"]
def run(self, DC=None, sambaopts=None,
synopsis = "%prog <destinationDC> <sourceDC> <NC> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_args = ["DEST_DC", "SOURCE_DC", "NC"]
takes_options = [
synopsis = "%prog [<DC>] [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_args = ["DC?"]
def run(self, DC=None, sambaopts=None,
synopsis = "%prog [<DC>] [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_args = ["DC?"]
takes_options = [
# Manipulate ACLs on directory objects
#
# Copyright (C) Nadezhda Ivanova <nivanova@samba.org> 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
synopsis = "%prog [options]"
car_help = """ The access control right to allow or deny """
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server",
type=str, metavar="URL", dest="H"),
#
# Copyright Nadezhda Ivanova 2009
# Copyright Jelmer Vernooij 2009
-# 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
synopsis = "%prog [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H"),
# implement samba_tool gpo commands
#
# Copyright Andrew Tridgell 2010
-# Copyright Giampaolo Lauria 2011 <lauria2@yahoo.com>
# Copyright Amitay Isaacs 2011 <amitay@gmail.com>
#
# based on C implementation by Guenther Deschner and Wilco Baan Hofman
synopsis = "%prog [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H")
synopsis = "%prog <username> [options]"
takes_args = ['username']
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server",
#
# Based on the original in EJS:
# Copyright Andrew Tridgell 2005
-# 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
synopsis = "%prog <groupname> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H"),
synopsis = "%prog <groupname> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H"),
synopsis = "%prog <groupname> <listofmembers> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H"),
synopsis = "%prog <groupname> <listofmembers> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H"),
# above partitions.
# Copyright (C) Zahari Zahariev <zahari.zahariev@postpath.com> 2009, 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
"credopts": options.CredentialsOptionsDouble,
}
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptionsDouble,
+ }
+
takes_args = ["URL1", "URL2", "context1?", "context2?", "context3?"]
takes_options = [
# Manipulate file NT ACLs
#
# Copyright Matthieu Patou 2010 <mat@matws.net>
-# 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
synopsis = "%prog <acl> <file> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
takes_options = [
Option("--quiet", help="Be quiet", action="store_true"),
Option("--xattr-backend", type="choice", help="xattr backend type (native fs or tdb)",
"""Set ACLs on a file"""
synopsis = "%prog <file> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
takes_options = [
Option("--as-sddl", help="Output ACL in the SDDL format", action="store_true"),
Option("--xattr-backend", type="choice", help="xattr backend type (native fs or tdb)",
# rodc related 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
synopsis = "%prog (<SID>|<DN>|<accountname>) [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("--server", help="DC to use", type=str),
]
# spn management
#
# Copyright Matthieu Patou mat@samba.org 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
synopsis = "%prog <user> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
takes_args = ["user"]
def run(self, user, credopts=None, sambaopts=None, versionopts=None):
synopsis = "%prog <name> <user> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
takes_options = [
Option("--force", help="Force the addition of the spn"\
" even it exists already", action="store_true"),
synopsis = "%prog <name> [user] [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
takes_args = ["name", "user?"]
def run(self, name, user=None, credopts=None, sambaopts=None, versionopts=None):
# Unix SMB/CIFS implementation.
# Test validity of smb.conf
# Copyright (C) 2010-2011 Jelmer Vernooij <jelmer@samba.org>
-# Copyright (C) Giampaolo Lauria 2011 <lauria2@yahoo.com>
#
# Based on the original in C:
# Copyright (C) Karl Auer 1993, 1994-1998
"versionopts": options.VersionOptions
}
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions
+ }
+
takes_options = [
Option("--section-name", type=str,
help="Limit testparm to a named section"),
# time
#
# Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
-# 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
"""
synopsis = "%prog [server-name] [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
takes_args = ["server_name?"]
def run(self, server_name=None, credopts=None, sambaopts=None, versionopts=None):
#
# Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
# Copyright Theresa Halloran 2011 <theresahalloran@gmail.com>
-# 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
#
import samba.getopt as options
-import sys, ldb
+import ldb
from getpass import getpass
from samba.auth import system_session
from samba.samdb import SamDB
-from samba import gensec, generate_random_password
-from samba import dsdb
+from samba import (
+ dsdb,
+ gensec,
+ generate_random_password,
+ )
from samba.net import Net
from samba.netcmd import (
takes_args = ["username", "password?"]
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
def run(self, username, password=None, credopts=None, sambaopts=None,
versionopts=None, H=None, must_change_at_next_login=False, random_password=False,
use_username_as_cn=False, userou=None, surname=None, given_name=None, initials=None,
Example2 shows how to delete a user in the domain against the local server. sudo is used so a user may run the command as root.
+<<<<<<< HEAD
"""
synopsis = "%prog <username> [options]"
]
takes_args = ["username"]
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
def run(self, username, credopts=None, sambaopts=None, versionopts=None, H=None):
-
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp, fallback_machine=True)
metavar="URL", dest="H"),
]
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
def run(self, sambaopts=None, credopts=None, versionopts=None, H=None):
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp, fallback_machine=True)
"""
synopsis = "%prog (<username>|--filter <filter>) [options]"
+
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H"),
"""
synopsis = "%prog (<username>|--filter <filter>) [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H"),
"""
synopsis = "%prog (<username>|--filter <filter>) [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
takes_options = [
Option("-H", "--URL", help="LDB URL for database or target server", type=str,
metavar="URL", dest="H"),
# Vampire
#
# Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
-# 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
"""Join and synchronise a remote AD domain to the local server"""
synopsis = "%prog [options] <domain>"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
takes_options = [
Option("--target-dir", help="Target directory.", type=str),
Option("--force", help="force run", action='store_true', default=False),