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
#
import re
+from socket import gethostname
from samba.dcerpc import nbt
from samba.net import Net
import ldb
'''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')