s4-python: raise an error if unable to bind remote ldap while joining
authorMatthieu Patou <mat@matws.net>
Fri, 13 May 2011 12:04:07 +0000 (16:04 +0400)
committerMatthieu Patou <mat@samba.org>
Mon, 16 May 2011 22:31:09 +0000 (00:31 +0200)
source4/scripting/python/samba/join.py

index c0aee714070e1a878312ded9174a0e4dfac8419a..b586e2cd5b04c0b4fbfcf41bb56cbc81f16fe9c1 100644 (file)
@@ -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())