From eaf1d050febc4d9ebf6cde9fd671ac5362d10e29 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Thu, 12 Aug 2010 01:25:27 +0400 Subject: s4 upgradeprovision: upgrade_delta_samdb return a msg_diff of @ATTRIBUTES This is used by upgradeprovision to readd this delta just before loading a merged schema --- source4/scripting/python/samba/upgradehelpers.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/upgradehelpers.py b/source4/scripting/python/samba/upgradehelpers.py index cc8322f361..a588a84346 100755 --- a/source4/scripting/python/samba/upgradehelpers.py +++ b/source4/scripting/python/samba/upgradehelpers.py @@ -746,27 +746,29 @@ def increment_calculated_keyversion_number(samdb, rootdn, hashDns): done = done + 1 samdb.set_attribute_replmetadata_version(str(e.dn), "unicodePwd", - version) - -def delta_update_basesamdb(refsam, sam, creds, session, lp, message): + version, True) +def delta_update_basesamdb(refsampath, sampath, creds, session, lp, message): """Update the provision container db: sam.ldb This function is aimed for alpha9 and newer; - :param refsam: Path to the samdb in the reference provision - :param sam: Path to the samdb in the upgraded provision + :param refsampath: Path to the samdb in the reference provision + :param sampath: Path to the samdb in the upgraded provision :param creds: Credential used for openning LDB files :param session: Session to use for openning LDB files - :param lp: A loadparam object""" + :param lp: A loadparam object + :return: A msg_diff object with the difference between the @ATTRIBUTES + of the current provision and the reference provision + """ message(SIMPLE, "Update base samdb by searching difference with reference one") - refsam = Ldb(refsam, session_info=session, credentials=creds, + refsam = Ldb(refsampath, session_info=session, credentials=creds, lp=lp, options=["modules:"]) - sam = Ldb(sam, session_info=session, credentials=creds, lp=lp, + sam = Ldb(sampath, session_info=session, credentials=creds, lp=lp, options=["modules:"]) empty = ldb.Message() - + deltaattr = None reference = refsam.search(expression="") for refentry in reference: @@ -782,6 +784,8 @@ def delta_update_basesamdb(refsam, sam, creds, session, lp, message): sam.add(delta) else: delta = sam.msg_diff(entry[0], refentry) + if str(refentry.dn) == "@ATTRIBUTES": + deltaattr = sam.msg_diff(refentry, entry[0]) if str(refentry.dn) == "@PROVISION" and\ delta.get(samba.provision.LAST_PROVISION_USN_ATTRIBUTE): delta.remove(samba.provision.LAST_PROVISION_USN_ATTRIBUTE) @@ -789,6 +793,7 @@ def delta_update_basesamdb(refsam, sam, creds, session, lp, message): delta.dn = refentry.dn sam.modify(delta) + return deltaattr def construct_existor_expr(attrs): """Construct a exists or LDAP search expression. -- cgit