KCC: use KccError, simplify logic in NTDSConn.commit_modified
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 13 May 2015 03:36:09 +0000 (15:36 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 12 Jun 2015 04:57:17 +0000 (06:57 +0200)
silence a pep8 thing.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/kcc/kcc_utils.py

index 684459b03352575f44f615993754ee24a4cebdb8..ef328bd47296a5e2e36bc7123980aed9822f9d0d 100644 (file)
@@ -1035,19 +1035,16 @@ class NTDSConnection(object):
         # First verify we have this entry to ensure nothing
         # is programatically amiss
         try:
-            #XXX msg is never used
-            msg = samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE)
-            found = True
+            # we don't use the search result, but it tests the status
+            # of self.dnstr in the database.
+            samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE)
 
         except ldb.LdbError, (enum, estr):
             if enum == ldb.ERR_NO_SUCH_OBJECT:
-                found = False
-            else:
-                raise Exception("Unable to search for (%s) - (%s)" %
-                                (self.dnstr, estr))
-        if not found:
-            raise Exception("nTDSConnection for (%s) doesn't exist!" %
-                            self.dnstr)
+                raise KCCError("nTDSConnection for (%s) doesn't exist!" %
+                               self.dnstr)
+            raise KccError("Unable to search for (%s) - (%s)" %
+                           (self.dnstr, estr))
 
         if self.enabled:
             enablestr = "TRUE"