mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
s4-net: Convert user subcommand to Python.
This commit is contained in:
@ -151,3 +151,5 @@ from samba.netcmd.export import cmd_export
|
||||
commands["export"] = cmd_export()
|
||||
from samba.netcmd.time import cmd_time
|
||||
commands["time"] = cmd_time()
|
||||
from samba.netcmd.user import cmd_user
|
||||
commands["user"] = cmd_user()
|
||||
|
74
source4/scripting/python/samba/netcmd/user.py
Normal file
74
source4/scripting/python/samba/netcmd/user.py
Normal file
@ -0,0 +1,74 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# user management
|
||||
#
|
||||
# Copyright Jelmer Vernooij 2010 <jelmer@samba.org>
|
||||
#
|
||||
# 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
|
||||
|
||||
from samba.net import Net
|
||||
|
||||
from samba.netcmd import (
|
||||
Command,
|
||||
SuperCommand,
|
||||
)
|
||||
|
||||
class cmd_user_create(Command):
|
||||
"""Create a new user."""
|
||||
synopsis = "%prog user create <name>"
|
||||
|
||||
takes_optiongroups = {
|
||||
"sambaopts": options.SambaOptions,
|
||||
"credopts": options.CredentialsOptions,
|
||||
"versionopts": options.VersionOptions,
|
||||
}
|
||||
|
||||
takes_args = ["name"]
|
||||
|
||||
def run(self, name, credopts=None, sambaopts=None, versionopts=None):
|
||||
lp = sambaopts.get_loadparm()
|
||||
creds = credopts.get_credentials(lp)
|
||||
net = Net(creds, lp)
|
||||
net.create_user(name)
|
||||
|
||||
|
||||
class cmd_user_delete(Command):
|
||||
"""Delete a user."""
|
||||
synopsis = "%prog user delete <name>"
|
||||
|
||||
takes_optiongroups = {
|
||||
"sambaopts": options.SambaOptions,
|
||||
"credopts": options.CredentialsOptions,
|
||||
"versionopts": options.VersionOptions,
|
||||
}
|
||||
|
||||
takes_args = ["name"]
|
||||
|
||||
def run(self, name, credopts=None, sambaopts=None, versionopts=None):
|
||||
lp = sambaopts.get_loadparm()
|
||||
creds = credopts.get_credentials(lp)
|
||||
net = Net(creds, lp)
|
||||
net.delete_user(name)
|
||||
|
||||
|
||||
class cmd_user(SuperCommand):
|
||||
"""User management."""
|
||||
|
||||
subcommands = {}
|
||||
subcommands["create"] = cmd_user_create()
|
||||
subcommands["delete"] = cmd_user_delete()
|
||||
|
Reference in New Issue
Block a user