summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2010-08-10 18:19:40 +0400
committerMatthieu Patou <mat@matws.net>2010-08-19 15:59:04 +0400
commit3e49b20cf0b0cadccc4e5b5ff3d20cbf60eeb3c4 (patch)
treef41f147d8250de6aacb547f6e989b0cfb01fd7d0 /source4
parent503824b75723f62bbe7ee578d0ed6ad4a1203665 (diff)
downloadsamba-3e49b20cf0b0cadccc4e5b5ff3d20cbf60eeb3c4.tar.gz
samba-3e49b20cf0b0cadccc4e5b5ff3d20cbf60eeb3c4.tar.bz2
samba-3e49b20cf0b0cadccc4e5b5ff3d20cbf60eeb3c4.zip
s4 upgradeprovision: Fixes for increment_keyversion
fix
Diffstat (limited to 'source4')
-rwxr-xr-xsource4/scripting/bin/upgradeprovision3
-rw-r--r--source4/scripting/python/samba/samdb.py19
-rwxr-xr-xsource4/scripting/python/samba/upgradehelpers.py3
3 files changed, 22 insertions, 3 deletions
diff --git a/source4/scripting/bin/upgradeprovision b/source4/scripting/bin/upgradeprovision
index f171aebe58..0c810307ac 100755
--- a/source4/scripting/bin/upgradeprovision
+++ b/source4/scripting/bin/upgradeprovision
@@ -1337,7 +1337,8 @@ def sync_calculated_attributes(samdb, names):
"""
listAttrs = ["msDs-KeyVersionNumber"]
hash = search_constructed_attrs_stored(samdb, names.rootdn, listAttrs)
- increment_calculated_keyversion_number(samdb, names.rootdn,
+ if hash.has_key("msDs-KeyVersionNumber"):
+ increment_calculated_keyversion_number(samdb, names.rootdn,
hash["msDs-KeyVersionNumber"])
def setup_path(file):
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py
index f358747b51..1765a07b6b 100644
--- a/source4/scripting/python/samba/samdb.py
+++ b/source4/scripting/python/samba/samdb.py
@@ -536,7 +536,7 @@ accountExpires: %u
return None
- def set_attribute_replmetadata_version(self, dn, att, value):
+ def set_attribute_replmetadata_version(self, dn, att, value, addifnotexist=False):
res = self.search(expression="dn=%s" % dn,
scope=ldb.SCOPE_SUBTREE,
controls=["search_options:1:2"],
@@ -563,6 +563,23 @@ accountExpires: %u
o.originating_invocation_id = misc.GUID(self.get_invocation_id())
o.originating_usn = seq
o.local_usn = seq
+
+ if not found and addifnotexist and len(ctr.array) >0:
+ o2 = drsblobs.replPropertyMetaData1()
+ o2.attid = 589914
+ att_oid = self.get_oid_from_attid(o2.attid)
+ seq = self.sequence_number(ldb.SEQ_NEXT)
+ o2.version = value
+ o2.originating_change_time = now
+ o2.originating_invocation_id = misc.GUID(self.get_invocation_id())
+ o2.originating_usn = seq
+ o2.local_usn = seq
+ found = True
+ tab = ctr.array
+ tab.append(o2)
+ ctr.count = ctr.count + 1
+ ctr.array = tab
+
if found :
replBlob = ndr_pack(repl)
msg = ldb.Message()
diff --git a/source4/scripting/python/samba/upgradehelpers.py b/source4/scripting/python/samba/upgradehelpers.py
index 2bc1795fbc..cc8322f361 100755
--- a/source4/scripting/python/samba/upgradehelpers.py
+++ b/source4/scripting/python/samba/upgradehelpers.py
@@ -732,6 +732,7 @@ def increment_calculated_keyversion_number(samdb, rootdn, hashDns):
scope=SCOPE_SUBTREE, attrs=["msDs-KeyVersionNumber"],
controls=["search_options:1:2"])
done = 0
+ hashDone = {}
if len(entry) == 0:
raise ProvisioningError("Unable to find msDs-KeyVersionNumber")
else:
@@ -739,7 +740,7 @@ def increment_calculated_keyversion_number(samdb, rootdn, hashDns):
if hashDns.has_key(str(e.dn).lower()):
val = e.get("msDs-KeyVersionNumber")
if not val:
- continue
+ val = "0"
version = int(str(hashDns[str(e.dn).lower()]))
if int(str(val)) < version:
done = done + 1