samba-tool: add --full-dn option to group list command
authorBjörn Baumbach <bb@sernet.de>
Mon, 12 Aug 2019 18:43:48 +0000 (20:43 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 21 Jan 2020 14:38:44 +0000 (14:38 +0000)
With this option the command lists the groups distringuished names
instead of the sAMAccountNames.

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

index 95843eecea41cfbd3e1b46d458d5b7b08880e94c..cabb56c23dbe74114cf5ce3384888af553a7aef6 100644 (file)
@@ -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))