1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-31 20:22:15 +03:00

samba-tool: add --full-dn option to group listmembers command

With this option the command lists the groupmembers distinguished names
instead of the sAMAccountName.

Signed-off-by: Jule Anger <ja@sernet.de>
Reviewed-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Jule Anger
2019-08-22 15:39:37 +02:00
committed by Stefan Metzmacher
parent 08207f77f1
commit bb66b32254

View File

@ -396,6 +396,10 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
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 = {
@ -406,7 +410,13 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
takes_args = ["groupname"]
def run(self, groupname, credopts=None, sambaopts=None, versionopts=None, H=None):
def run(self,
groupname,
credopts=None,
sambaopts=None,
versionopts=None,
H=None,
full_dn=False):
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp, fallback_machine=True)
@ -437,6 +447,10 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com
return
for msg in res:
if full_dn:
self.outf.write("%s\n" % msg.get("dn"))
continue
member_name = msg.get("samAccountName", idx=0)
if member_name is None:
member_name = msg.get("cn", idx=0)