From: Björn Baumbach Date: Mon, 12 Aug 2019 18:43:48 +0000 (+0200) Subject: samba-tool: add --full-dn option to group list command X-Git-Tag: samba-4.12.0rc1~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51d4c82f3c5bed8a412ccf747e0617e14ca35671;p=thirdparty%2Fsamba.git samba-tool: add --full-dn option to group list command With this option the command lists the groups distringuished names instead of the sAMAccountNames. Signed-off-by: Björn Baumbach Reviewed-by: Ralph Boehme --- diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py index 95843eecea4..cabb56c23db 100644 --- a/python/samba/netcmd/group.py +++ b/python/samba/netcmd/group.py @@ -313,7 +313,10 @@ class cmd_group_list(Command): Option("-v", "--verbose", help="Verbose output, showing group type and group scope.", action="store_true"), - + Option("--full-dn", dest="full_dn", + default=False, + action='store_true', + help="Display DN instead of the sAMAccountName."), ] takes_optiongroups = { @@ -322,8 +325,13 @@ class cmd_group_list(Command): "versionopts": options.VersionOptions, } - def run(self, sambaopts=None, credopts=None, versionopts=None, H=None, - verbose=False): + def run(self, + sambaopts=None, + credopts=None, + versionopts=None, + H=None, + verbose=False, + full_dn=False): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) @@ -367,6 +375,10 @@ class cmd_group_list(Command): self.outf.write(" %6u\n" % num_members) else: for msg in res: + if full_dn: + self.outf.write("%s\n" % msg.get("dn")) + continue + self.outf.write("%s\n" % msg.get("samaccountname", idx=0))