From: Björn Baumbach Date: Tue, 21 Jan 2020 10:39:30 +0000 (+0100) Subject: samba-tool: add --full-dn option for user getgroups command X-Git-Tag: samba-4.12.0rc1~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41262d1d66c18e3ea2f2f3c009a88ef830d25aa4;p=thirdparty%2Fsamba.git samba-tool: add --full-dn option for user getgroups command Signed-off-by: Björn Baumbach Reviewed-by: Ralph Boehme --- diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index 9a1883fea1f..b04ee49d018 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -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: