summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-07-28 10:59:09 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-07-28 05:40:43 +0200
commit6a37b55dfb2d8e6683538400d41c2b139a553eaa (patch)
tree839a7ff6d027f154d4fc78a35801bf728f7be023
parentdc00df2adddfe23e5ebb61f9f7c16ec7d3f2c03e (diff)
downloadsamba-6a37b55dfb2d8e6683538400d41c2b139a553eaa.tar.gz
samba-6a37b55dfb2d8e6683538400d41c2b139a553eaa.tar.bz2
samba-6a37b55dfb2d8e6683538400d41c2b139a553eaa.zip
s4-dbcheck: Add lastKnownParent when moving an object to lostAndFound
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Sat Jul 28 05:40:43 CEST 2012 on sn-devel-104
-rw-r--r--source4/scripting/python/samba/dbchecker.py35
1 files changed, 28 insertions, 7 deletions
diff --git a/source4/scripting/python/samba/dbchecker.py b/source4/scripting/python/samba/dbchecker.py
index 03ec7abc82..a6495fc8e1 100644
--- a/source4/scripting/python/samba/dbchecker.py
+++ b/source4/scripting/python/samba/dbchecker.py
@@ -366,13 +366,34 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
self.report('Not moving object %s into LostAndFound' % (obj.dn))
return
- nc_root = self.samdb.get_nc_root(obj.dn);
- lost_and_found = self.samdb.get_wellknown_dn(nc_root, dsdb.DS_GUID_LOSTANDFOUND_CONTAINER)
- new_dn = ldb.Dn(self.samdb, str(obj.dn))
- new_dn.remove_base_components(len(new_dn) - 1)
- if self.do_rename(obj.dn, new_dn, lost_and_found, ["show_deleted:0", "relax:0"],
- "Failed to rename object %s into lostAndFound at %s" % (obj.dn, new_dn + lost_and_found)):
- self.report("Renamed object %s into lostAndFound at %s" % (obj.dn, new_dn + lost_and_found))
+ keep_transaction = True
+ self.samdb.transaction_start()
+ try:
+ nc_root = self.samdb.get_nc_root(obj.dn);
+ lost_and_found = self.samdb.get_wellknown_dn(nc_root, dsdb.DS_GUID_LOSTANDFOUND_CONTAINER)
+ new_dn = ldb.Dn(self.samdb, str(obj.dn))
+ new_dn.remove_base_components(len(new_dn) - 1)
+ if self.do_rename(obj.dn, new_dn, lost_and_found, ["show_deleted:0", "relax:0"],
+ "Failed to rename object %s into lostAndFound at %s" % (obj.dn, new_dn + lost_and_found)):
+ self.report("Renamed object %s into lostAndFound at %s" % (obj.dn, new_dn + lost_and_found))
+
+ m = ldb.Message()
+ m.dn = obj.dn
+ m['lastKnownParent'] = ldb.MessageElement(str(obj.dn.parent()), ldb.FLAG_MOD_REPLACE, 'lastKnownParent')
+
+ if self.do_modify(m, [],
+ "Failed to set lastKnownParent on lostAndFound object at %s" % (new_dn + lost_and_found)):
+ self.report("Set lastKnownParent on lostAndFound object at %s" % (new_dn + lost_and_found))
+ keep_transaction = True
+ except:
+ self.samdb.transaction_cancel()
+ raise
+
+ if keep_transaction:
+ self.samdb.transaction_commit()
+ else:
+ self.samdb.transaction_cancel()
+
def err_wrong_instancetype(self, obj, calculated_instancetype):
'''handle a wrong instanceType'''