diff options
author | Matthieu Patou <mat@matws.net> | 2011-05-13 16:04:07 +0400 |
---|---|---|
committer | Matthieu Patou <mat@samba.org> | 2011-05-17 00:31:09 +0200 |
commit | c2ac7473f38a1e61499f6cf01ce9de19bcd3abc6 (patch) | |
tree | 45143cb14991a6d416b93734b7dcd3d6a42de747 | |
parent | 8cf14c21b3bc55454728bf48b23f696e15c92aea (diff) | |
download | samba-c2ac7473f38a1e61499f6cf01ce9de19bcd3abc6.tar.gz samba-c2ac7473f38a1e61499f6cf01ce9de19bcd3abc6.tar.bz2 samba-c2ac7473f38a1e61499f6cf01ce9de19bcd3abc6.zip |
s4-python: raise an error if unable to bind remote ldap while joining
-rw-r--r-- | source4/scripting/python/samba/join.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/join.py b/source4/scripting/python/samba/join.py index c0aee71407..b586e2cd5b 100644 --- a/source4/scripting/python/samba/join.py +++ b/source4/scripting/python/samba/join.py @@ -36,6 +36,11 @@ import talloc # this makes debugging easier talloc.enable_null_tracking() +class DCJoinException(Exception): + + def __init__(self, msg): + super(DCJoinException, self).__init__("Can't join, error: %s" % msg) + class dc_join(object): '''perform a DC join''' @@ -62,6 +67,12 @@ class dc_join(object): session_info=system_session(), credentials=ctx.creds, lp=ctx.lp) + try: + ctx.samdb.search(scope=ldb.SCOPE_ONELEVEL, attrs=["dn"]) + except ldb.LdbError, (enum, estr): + raise DCJoinException(estr) + + ctx.myname = netbios_name ctx.samname = "%s$" % ctx.myname ctx.base_dn = str(ctx.samdb.get_default_basedn()) |