From 436d8b6e06c555b2f3dabad8218f08b713e7664c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 25 Aug 2009 16:27:20 +1000 Subject: s4:python Fix the reprovision test by deleting 'deleted' objects too. 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'source4') diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index 59a6e00c5d..69a0320be7 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -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 -- cgit