From: Jule Anger Date: Mon, 26 Aug 2019 07:33:24 +0000 (+0200) Subject: samba-tool: add -b/--base-dn option to contacts list command X-Git-Tag: samba-4.12.0rc1~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8a45adb2b19279d01b33d0f7c15f1cd1c5f9e863;p=thirdparty%2Fsamba.git samba-tool: add -b/--base-dn option to contacts list command With this option it's e.g. possible to list the contacts of a specify OU or contacts which are located under a different specific place in the AD. Signed-off-by: Jule Anger Reviewed-by: Björn Baumbach Reviewed-by: Ralph Boehme --- diff --git a/python/samba/netcmd/contact.py b/python/samba/netcmd/contact.py index b35f3f16a88..73b7d141af6 100644 --- a/python/samba/netcmd/contact.py +++ b/python/samba/netcmd/contact.py @@ -254,6 +254,9 @@ class cmd_list(Command): type=str, metavar="URL", dest="H"), + Option("-b", "--base-dn", + help="Specify base DN to use.", + type=str), Option("--full-dn", dest="full_dn", default=False, @@ -272,6 +275,7 @@ class cmd_list(Command): credopts=None, versionopts=None, H=None, + base_dn=None, full_dn=False): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) @@ -281,8 +285,11 @@ class cmd_list(Command): credentials=creds, lp=lp) - domain_dn = samdb.domain_dn() - res = samdb.search(domain_dn, + search_dn = samdb.domain_dn() + if base_dn: + search_dn = samdb.normalize_dn_in_domain(base_dn) + + res = samdb.search(search_dn, scope=ldb.SCOPE_SUBTREE, expression="(objectClass=contact)", attrs=["name"])