summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2012-07-03 14:22:42 +1000
committerAmitay Isaacs <amitay@gmail.com>2012-07-03 15:20:42 +1000
commit8768f4fc34c0a41f63bbbd0fe81e983dd5baa0b3 (patch)
treee66191e636711a752e711d24126dc3c21811bdda /source4
parent0365df93e61b44cbdd7270c48495a6b4ac251677 (diff)
downloadsamba-8768f4fc34c0a41f63bbbd0fe81e983dd5baa0b3.tar.gz
samba-8768f4fc34c0a41f63bbbd0fe81e983dd5baa0b3.tar.bz2
samba-8768f4fc34c0a41f63bbbd0fe81e983dd5baa0b3.zip
samba-tool: gpo: Add listcontainers subcommand to list containers using given GPO
Thanks to Denis Bonnenfant <denis.bonnenfant@diderot.org> for patch.
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/netcmd/gpo.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/netcmd/gpo.py b/source4/scripting/python/samba/netcmd/gpo.py
index 86c5465bb5..e32458ed47 100644
--- a/source4/scripting/python/samba/netcmd/gpo.py
+++ b/source4/scripting/python/samba/netcmd/gpo.py
@@ -652,6 +652,42 @@ class cmd_dellink(Command):
cmd_getlink().run(container_dn, H, sambaopts, credopts, versionopts)
+class cmd_listcontainers(Command):
+ """List all linked containers for a GPO"""
+
+ synopsis = "%prog <gpo> [options]"
+
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptions,
+ }
+
+ takes_args = ['gpo']
+
+ takes_options = [
+ Option("-H", help="LDB URL for database or target server", type=str)
+ ]
+
+ def run(self, gpo, H=None, sambaopts=None, credopts=None,
+ versionopts=None):
+
+ self.lp = sambaopts.get_loadparm()
+ self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
+
+ self.url = dc_url(self.lp, self.creds, H)
+
+ samdb_connect(self)
+
+ msg = get_gpo_containers(self.samdb, gpo)
+ if len(msg):
+ self.outf.write("Container(s) using GPO %s\n" % gpo)
+ for m in msg:
+ self.outf.write(" DN: %s\n" % m['dn'])
+ else:
+ self.outf.write("No Containers using GPO %s\n" % gpo)
+
+
class cmd_getinheritance(Command):
"""Get inheritance flag for a container"""
@@ -966,6 +1002,7 @@ class cmd_gpo(SuperCommand):
subcommands["getlink"] = cmd_getlink()
subcommands["setlink"] = cmd_setlink()
subcommands["dellink"] = cmd_dellink()
+ subcommands["listcontainers"] = cmd_listcontainers()
subcommands["getinheritance"] = cmd_getinheritance()
subcommands["setinheritance"] = cmd_setinheritance()
subcommands["fetch"] = cmd_fetch()