samba-tool: add --full-dn option for user getgroups command
authorBjörn Baumbach <bb@sernet.de>
Tue, 21 Jan 2020 10:39:30 +0000 (11:39 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 21 Jan 2020 14:38:45 +0000 (14:38 +0000)
Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Ralph Boehme <slow@samba.org>
python/samba/netcmd/user.py

index 9a1883fea1f4de2abfb6c877f363c52c582edc02..b04ee49d018856abeb00e33757394a1c0f343f91 100644 (file)
@@ -764,12 +764,21 @@ The username specified on the command is the sAMAccountName."""
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server",
                type=str, metavar="URL", dest="H"),
+        Option("--full-dn", dest="full_dn",
+               default=False,
+               action='store_true',
+               help="Display DN instead of the sAMAccountName."),
         ]
 
     takes_args = ["username"]
 
-    def run(self, username, credopts=None, sambaopts=None,
-            versionopts=None, H=None):
+    def run(self,
+            username,
+            credopts=None,
+            sambaopts=None,
+            versionopts=None,
+            H=None,
+            full_dn=False):
 
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp)
@@ -810,6 +819,12 @@ The username specified on the command is the sAMAccountName."""
         except IndexError:
             raise CommandError("Unable to find primary group '%s'" % (primarygroup_sid_dn))
 
+        if full_dn:
+            self.outf.write("%s\n" % primary_group_dn)
+            for group_dn in user_groups:
+                self.outf.write("%s\n" % group_dn)
+            return
+
         group_names = []
         for gdn in user_groups:
             try: