summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-09-14 18:22:13 +1000
committerAndrew Tridgell <tridge@samba.org>2010-09-15 15:39:35 +1000
commit011978eb1baf16c622ffcfcaf9944a217d95fadf (patch)
treeaeedbbf94f55d8e148cc6c7febed96e3e066de24 /source4/scripting
parent2e92484c60f55b967dcd3c698e6553c2eed4a4ea (diff)
downloadsamba-011978eb1baf16c622ffcfcaf9944a217d95fadf.tar.gz
samba-011978eb1baf16c622ffcfcaf9944a217d95fadf.tar.bz2
samba-011978eb1baf16c622ffcfcaf9944a217d95fadf.zip
s4-rodc: use python finddc code to avoid the need for --server
The DC is now found via DNS/CLDAP Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/join.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/source4/scripting/python/samba/join.py b/source4/scripting/python/samba/join.py
index ecc225ae3b..36732d692d 100644
--- a/source4/scripting/python/samba/join.py
+++ b/source4/scripting/python/samba/join.py
@@ -25,7 +25,7 @@ from samba import gensec, Ldb
import ldb, samba, sys
from samba.ndr import ndr_pack, ndr_unpack, ndr_print
from samba.dcerpc import security
-from samba.dcerpc import drsuapi, misc, netlogon
+from samba.dcerpc import drsuapi, misc, netlogon, nbt
from samba.credentials import Credentials, DONT_USE_KERBEROS
from samba.provision import secretsdb_self_join, provision, FILL_DRS, find_setup_dir
from samba.net import Net
@@ -43,9 +43,6 @@ def join_rodc(server=None, creds=None, lp=None, site=None, netbios_name=None,
targetdir=None, domain=None):
"""join as a RODC"""
- if server is None:
- raise Exception("You must supply a server for a RODC join")
-
def del_noerror(samdb, dn):
try:
samdb.delete(dn)
@@ -69,6 +66,11 @@ def join_rodc(server=None, creds=None, lp=None, site=None, netbios_name=None,
except:
pass
+ def find_dc(ctx, domain):
+ '''find a writeable DC for the given domain'''
+ return ctx.net.finddc(domain, nbt.NBT_SERVER_LDAP | nbt.NBT_SERVER_DS | nbt.NBT_SERVER_WRITABLE)
+
+
def get_dsServiceName(samdb):
res = samdb.search(base="", scope=ldb.SCOPE_BASE, attrs=["dsServiceName"])
return res[0]["dsServiceName"][0]
@@ -285,14 +287,18 @@ def join_rodc(server=None, creds=None, lp=None, site=None, netbios_name=None,
ctx.site = site
ctx.netbios_name = netbios_name
ctx.targetdir = targetdir
- ctx.server = server
ctx.creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL)
+ ctx.net = Net(creds=ctx.creds, lp=ctx.lp)
+
+ if server is not None:
+ ctx.server = server
+ else:
+ ctx.server = find_dc(ctx, domain)
ctx.samdb = SamDB(url="ldap://%s" % ctx.server,
session_info=system_session(),
credentials=ctx.creds, lp=ctx.lp)
- ctx.net = Net(creds=ctx.creds, lp=ctx.lp)
ctx.myname = netbios_name
ctx.samname = "%s$" % ctx.myname