try:
self.delete(msg.dn)
except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
- # Ignor eno such object errors
+ # Ignore no such object errors
pass
res = self.search(basedn, ldb.SCOPE_SUBTREE, "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", ["distinguishedName"])
k = 0
while ++k < 10 and (previous_remaining != current_remaining):
# and the rest
- res2 = self.search(basedn, ldb.SCOPE_SUBTREE, "(|(objectclass=*)(distinguishedName=*))", ["distinguishedName"])
+ try:
+ res2 = self.search(basedn, ldb.SCOPE_SUBTREE, "(|(objectclass=*)(distinguishedName=*))", ["distinguishedName"])
+ except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
+ # Ignore missing dn errors
+ return
+
previous_remaining = current_remaining
current_remaining = len(res2)
for msg in res2:
- self.delete(msg.dn)
+ try:
+ self.delete(msg.dn)
+ # Ignore no such object errors
+ except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
+ pass
+ # Ignore not allowed on non leaf errors
+ except ldb.LdbError, (LDB_ERR_NOT_ALLOWED_ON_NON_LEAF, _):
+ pass
def load_ldif_file_add(self, ldif_path):
"""Load a LDIF file.