summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJule Anger <ja@sernet.de>2019-08-26 09:33:24 +0200
committerStefan Metzmacher <metze@samba.org>2020-01-21 14:38:45 +0000
commit8a45adb2b19279d01b33d0f7c15f1cd1c5f9e863 (patch)
treeecb6fe0d999193841ede5aa69b721f9946d1656c /python
parent88f0a1390b854f4ea1f6e29914e3bac85457c745 (diff)
downloadsamba-8a45adb2b19279d01b33d0f7c15f1cd1c5f9e863.tar.gz
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 <ja@sernet.de> Reviewed-by: Björn Baumbach <bb@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/netcmd/contact.py11
1 files changed, 9 insertions, 2 deletions
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"])