samba-tool: add -b/--base-dn option to groups list command
authorJule Anger <ja@sernet.de>
Mon, 12 Aug 2019 18:46:47 +0000 (20:46 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 21 Jan 2020 14:38:45 +0000 (14:38 +0000)
With this option it's e.g. possible to list the groups of a
specify OU or groups which are located under a different specific
place in the AD.

Signed-off-by: Jule Anger <ja@sernet.de>
Pair-programmed-with: Björn Baumbach <bb@samba.org>
Reviewed-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
python/samba/netcmd/group.py

index ac3dbd9bb02b804ba9c961fa1f37040d470d2e94..2e1db1371b4a66199d2b4a697bf8bcbfe67b25a9 100644 (file)
@@ -313,6 +313,9 @@ class cmd_group_list(Command):
         Option("-v", "--verbose",
                help="Verbose output, showing group type and group scope.",
                action="store_true"),
+        Option("-b", "--base-dn",
+               help="Specify base DN to use.",
+               type=str),
         Option("--full-dn", dest="full_dn",
                default=False,
                action='store_true',
@@ -331,6 +334,7 @@ class cmd_group_list(Command):
             versionopts=None,
             H=None,
             verbose=False,
+            base_dn=None,
             full_dn=False):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
@@ -342,6 +346,8 @@ class cmd_group_list(Command):
         if verbose:
             attrs += ["grouptype", "member"]
         domain_dn = samdb.domain_dn()
+        if base_dn:
+            domain_dn = samdb.normalize_dn_in_domain(base_dn)
         res = samdb.search(domain_dn, scope=ldb.SCOPE_SUBTREE,
                            expression=("(objectClass=group)"),
                            attrs=attrs)