summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDavid Mulder <dmulder@suse.com>2021-10-25 08:49:35 -0600
committerDavid Mulder <dmulder@samba.org>2021-10-26 14:23:42 +0000
commit7c9195e28bc51ac375d609f8306db2456f348167 (patch)
treee3027049ede4b4a4649700ffa977ea7ed1952f3f /python
parent5a75212b60b8d90e63e6ff048fda4f00ad6ff94a (diff)
downloadsamba-7c9195e28bc51ac375d609f8306db2456f348167.tar.gz
samba-tool: Pick local host if calling samba-tool from DC
It is reasonable to assume, that if we are running a command from a DC, that a user expects that the command will run against this DC. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Rowland Penny <rpenny@samba.org> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Tue Oct 26 14:23:42 UTC 2021 on sn-devel-184
Diffstat (limited to 'python')
-rw-r--r--python/samba/netcmd/common.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/python/samba/netcmd/common.py b/python/samba/netcmd/common.py
index bb17bfa10f2..588806b2ad3 100644
--- a/python/samba/netcmd/common.py
+++ b/python/samba/netcmd/common.py
@@ -18,6 +18,7 @@
#
import re
+from socket import gethostname
from samba.dcerpc import nbt
from samba.net import Net
import ldb
@@ -59,6 +60,10 @@ def netcmd_finddc(lp, creds, realm=None):
'''Return domain-name of a writable/ldap-capable DC for the default
domain (parameter "realm" in smb.conf) unless another realm has been
specified as argument'''
+ # It is reasonable to assume, that if we are running a command from a DC,
+ # that a user expects that the command will run against this DC.
+ if lp.get('server role') == 'active directory domain controller':
+ return gethostname()
net = Net(creds=creds, lp=lp)
if realm is None:
realm = lp.get('realm')