5
# Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
import samba.getopt as options
23
from samba.net import Net
25
from samba.netcmd import (
30
class cmd_user_add(Command):
31
"""Create a new user."""
32
synopsis = "%prog user add <name> [<password>]"
34
takes_optiongroups = {
35
"sambaopts": options.SambaOptions,
36
"credopts": options.CredentialsOptions,
37
"versionopts": options.VersionOptions,
40
takes_args = ["name", "password?"]
42
def run(self, name, password=None, credopts=None, sambaopts=None, versionopts=None):
43
lp = sambaopts.get_loadparm()
44
creds = credopts.get_credentials(lp )
45
net = Net(creds, lp, server=credopts.ipaddress)
47
if password is not None:
48
net.set_password(name, creds.get_domain(), password, creds)
51
class cmd_user_delete(Command):
53
synopsis = "%prog user delete <name>"
55
takes_optiongroups = {
56
"sambaopts": options.SambaOptions,
57
"credopts": options.CredentialsOptions,
58
"versionopts": options.VersionOptions,
63
def run(self, name, credopts=None, sambaopts=None, versionopts=None):
64
lp = sambaopts.get_loadparm()
65
creds = credopts.get_credentials(lp, fallback_machine=True)
66
net = Net(creds, lp, server=credopts.ipaddress)
70
class cmd_user(SuperCommand):
71
"""User management [server connection needed]"""
74
subcommands["add"] = cmd_user_add()
75
subcommands["delete"] = cmd_user_delete()