summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-03-01 23:03:41 +0100
committerJelmer Vernooij <jelmer@samba.org>2010-04-09 11:53:00 +0200
commitffa73c412e1190024ae0bf4758174d1b21c16e13 (patch)
tree21a812f4c00746404d0e9181a77b9704ebb0608c /source4/scripting
parent8149094eddebd9a0e8b7c123c2ed54d00164bb26 (diff)
downloadsamba-ffa73c412e1190024ae0bf4758174d1b21c16e13.tar.gz
samba-ffa73c412e1190024ae0bf4758174d1b21c16e13.tar.bz2
samba-ffa73c412e1190024ae0bf4758174d1b21c16e13.zip
s4-net: Convert user subcommand to Python.
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/netcmd/__init__.py2
-rw-r--r--source4/scripting/python/samba/netcmd/user.py74
2 files changed, 76 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py
index f9c644582c..d4e21c1b4e 100644
--- a/source4/scripting/python/samba/netcmd/__init__.py
+++ b/source4/scripting/python/samba/netcmd/__init__.py
@@ -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()
diff --git a/source4/scripting/python/samba/netcmd/user.py b/source4/scripting/python/samba/netcmd/user.py
new file mode 100644
index 0000000000..319e8b0215
--- /dev/null
+++ b/source4/scripting/python/samba/netcmd/user.py
@@ -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()
+