1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

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
This commit is contained in:
David Mulder 2021-10-25 08:49:35 -06:00 committed by David Mulder
parent 5a75212b60
commit 7c9195e28b

View File

@ -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')