s4:python Fix the reprovision test by deleting 'deleted' objects too.
authorAndrew Bartlett <abartlet@samba.org>
Tue, 25 Aug 2009 06:27:20 +0000 (16:27 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 25 Aug 2009 06:28:44 +0000 (16:28 +1000)
We were failing because CN=Deleted Objects, which is marked as
'deleted' itself, could not be re-added in a reprovision.

Andrew Bartlett

source4/scripting/python/samba/__init__.py

index 59a6e00c5d84c7fc28b184b1998e658d5919cc1c..69a0320be78546a53688b5b5cba8fba257eaa960 100644 (file)
@@ -135,17 +135,19 @@ class Ldb(ldb.Ldb):
     def erase_except_schema_controlled(self):
         """Erase this ldb, removing all records, except those that are controlled by Samba4's schema."""
         basedn = ""
-        # Delete the 'visible' records
+        # Delete the 'visible' records, and the invisble 'deleted' records (if this DB supports it)
         for msg in self.search(basedn, ldb.SCOPE_SUBTREE, 
-                "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", 
-                ["distinguishedName"]):
+                               "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))",
+                               [], controls=["show_deleted:0"]):
             try:
                 self.delete(msg.dn)
             except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
                 # Ignore no such object errors
                 pass
-
-        res = self.search(basedn, ldb.SCOPE_SUBTREE, "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", ["distinguishedName"])
+            
+        res = self.search(basedn, ldb.SCOPE_SUBTREE, 
+                          "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))",
+                          [], controls=["show_deleted:0"])
         assert len(res) == 0
 
         # delete the specials
@@ -175,7 +177,8 @@ class Ldb(ldb.Ldb):
 
         def erase_recursive(self, dn):
             try:
-                res = self.search(base=dn, scope=ldb.SCOPE_ONELEVEL, attrs=[])
+                res = self.search(base=dn, scope=ldb.SCOPE_ONELEVEL, attrs=[], 
+                                  controls=["show_deleted:0"])
             except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
                 # Ignore no such object errors
                 return