From: Jule Anger Date: Thu, 22 Aug 2019 07:30:21 +0000 (+0200) Subject: samba-tool: add --full-dn option to user list command X-Git-Tag: samba-4.12.0rc1~34 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=31060963956ba6feb81d45c3afe140a0a4c3d235;p=thirdparty%2Fsamba.git samba-tool: add --full-dn option to user list command With this option the command lists the users distringuished names instead of the sAMAccountNames. Signed-off-by: Jule Anger Reviewed-by: Björn Baumbach Reviewed-by: Ralph Boehme --- diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index c66fd98139c..9a1883fea1f 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -481,6 +481,10 @@ class cmd_user_list(Command): 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_optiongroups = { @@ -489,7 +493,12 @@ class cmd_user_list(Command): "versionopts": options.VersionOptions, } - def run(self, sambaopts=None, credopts=None, versionopts=None, H=None): + def run(self, + sambaopts=None, + credopts=None, + versionopts=None, + H=None, + full_dn=False): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) @@ -505,6 +514,10 @@ class cmd_user_list(Command): return 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))