diff options
Diffstat (limited to 'source4/scripting')
4 files changed, 20 insertions, 21 deletions
diff --git a/source4/scripting/bin/upgradeprovision b/source4/scripting/bin/upgradeprovision index d2a645a637..54f3cf1507 100755 --- a/source4/scripting/bin/upgradeprovision +++ b/source4/scripting/bin/upgradeprovision @@ -1349,7 +1349,7 @@ def rebuild_sd(samdb, names): def removeProvisionUSN(samdb): attrs = [samba.provision.LAST_PROVISION_USN_ATTRIBUTE, "dn"] entry = samdb.search(expression="dn=@PROVISION", base = "", - scope=SCOPE_SUBTREE, + scope=SCOPE_BASE, attrs=attrs) empty = Message() empty.dn = entry[0].dn diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py index 97cf7bff17..4fa2823214 100644 --- a/source4/scripting/python/samba/provision/__init__.py +++ b/source4/scripting/python/samba/provision/__init__.py @@ -331,10 +331,9 @@ def update_provision_usn(samdb, low, high, id, replace=False): tab = [] if not replace: - entry = samdb.search(expression="(&(dn=@PROVISION)(%s=*))" % - LAST_PROVISION_USN_ATTRIBUTE, base="", - scope=ldb.SCOPE_SUBTREE, - attrs=[LAST_PROVISION_USN_ATTRIBUTE, "dn"]) + entry = samdb.search(base="@PROVISION", + scope=ldb.SCOPE_BASE, + attrs=[LAST_PROVISION_USN_ATTRIBUTE, "dn"]) for e in entry[0][LAST_PROVISION_USN_ATTRIBUTE]: if not re.search(';', e): e = "%s;%s" % (e, id) @@ -345,9 +344,9 @@ def update_provision_usn(samdb, low, high, id, replace=False): delta.dn = ldb.Dn(samdb, "@PROVISION") delta[LAST_PROVISION_USN_ATTRIBUTE] = ldb.MessageElement(tab, ldb.FLAG_MOD_REPLACE, LAST_PROVISION_USN_ATTRIBUTE) - entry = samdb.search(expression="(&(dn=@PROVISION)(provisionnerID=*))", - base="", scope=ldb.SCOPE_SUBTREE, - attrs=["provisionnerID"]) + entry = samdb.search(expression='provisionnerID=*', + base="@PROVISION", scope=ldb.SCOPE_BASE, + attrs=["provisionnerID"]) if len(entry) == 0 or len(entry[0]) == 0: delta["provisionnerID"] = ldb.MessageElement(id, ldb.FLAG_MOD_ADD, "provisionnerID") samdb.modify(delta) @@ -398,10 +397,14 @@ def get_last_provision_usn(sam): :return: a dictionnary which keys are invocation id and values are an array of integer representing the different ranges """ - entry = sam.search(expression="(&(dn=@PROVISION)(%s=*))" % - LAST_PROVISION_USN_ATTRIBUTE, - base="", scope=ldb.SCOPE_SUBTREE, - attrs=[LAST_PROVISION_USN_ATTRIBUTE, "provisionnerID"]) + try: + entry = sam.search(expression="%s=*" % LAST_PROVISION_USN_ATTRIBUTE, + base="@PROVISION", scope=ldb.SCOPE_BASE, + attrs=[LAST_PROVISION_USN_ATTRIBUTE, "provisionnerID"]) + except ldb.LdbError, (ecode, emsg): + if ecode == ldb.ERR_NO_SUCH_OBJECT: + return None + raise if len(entry): myids = [] range = {} diff --git a/source4/scripting/python/samba/tests/upgradeprovision.py b/source4/scripting/python/samba/tests/upgradeprovision.py index b81ee8a8ab..62ab1790bc 100644 --- a/source4/scripting/python/samba/tests/upgradeprovision.py +++ b/source4/scripting/python/samba/tests/upgradeprovision.py @@ -27,7 +27,7 @@ from samba.upgradehelpers import (usn_in_range, dn_sort, from samba.tests.provision import create_dummy_secretsdb from samba.tests import TestCaseInTempDir from samba import Ldb -from ldb import SCOPE_SUBTREE +from ldb import SCOPE_BASE import samba.tests def dummymessage(a=None, b=None): @@ -123,10 +123,8 @@ class UpdateSecretsTests(samba.tests.TestCaseInTempDir): def test_update_modules(self): empty_db = self._getEmptyDb() update_secrets(self.referencedb, empty_db, dummymessage) - newmodules = empty_db.search( - expression="dn=@MODULES", base="", scope=SCOPE_SUBTREE) - refmodules = self.referencedb.search( - expression="dn=@MODULES", base="", scope=SCOPE_SUBTREE) + newmodules = empty_db.search(base="@MODULES", scope=SCOPE_BASE) + refmodules = self.referencedb.search(base="@MODULES", scope=SCOPE_BASE) self.assertEquals(newmodules.msgs, refmodules.msgs) def tearDown(self): diff --git a/source4/scripting/python/samba/upgradehelpers.py b/source4/scripting/python/samba/upgradehelpers.py index e15523033f..1ee1c044e7 100755 --- a/source4/scripting/python/samba/upgradehelpers.py +++ b/source4/scripting/python/samba/upgradehelpers.py @@ -441,10 +441,8 @@ def update_secrets(newsecrets_ldb, secrets_ldb, messagefunc): """ messagefunc(SIMPLE, "Update of secrets.ldb") - reference = newsecrets_ldb.search(expression="dn=@MODULES", base="", - scope=SCOPE_SUBTREE) - current = secrets_ldb.search(expression="dn=@MODULES", base="", - scope=SCOPE_SUBTREE) + reference = newsecrets_ldb.search(base="@MODULES", scope=SCOPE_BASE) + current = secrets_ldb.search(base="@MODULES", scope=SCOPE_BASE) assert reference, "Reference modules list can not be empty" if len(current) == 0: # No modules present |