1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-08 05:57:51 +03:00

python/samba: port changes to allow samba.tests.dsdb_lock to work with PY3/PY2

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Noel Power 2018-08-08 17:03:48 +01:00 committed by Andrew Bartlett
parent 596db3a5bb
commit 27df0e81c2
3 changed files with 9 additions and 8 deletions

View File

@ -293,7 +293,7 @@ class dbcheck(object):
# as the original one, so that on replication we # as the original one, so that on replication we
# merge, rather than conflict. # merge, rather than conflict.
proposed_objectguid = dsdb_dn.dn.get_extended_component("GUID") proposed_objectguid = dsdb_dn.dn.get_extended_component("GUID")
listwko.append(o) listwko.append(str(o))
if proposed_objectguid is not None: if proposed_objectguid is not None:
guid_suffix = "\nobjectGUID: %s" % str(misc.GUID(proposed_objectguid)) guid_suffix = "\nobjectGUID: %s" % str(misc.GUID(proposed_objectguid))
@ -2223,7 +2223,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
values = set() values = set()
# check for incorrectly normalised attributes # check for incorrectly normalised attributes
for val in obj[attrname]: for val in obj[attrname]:
values.add(str(val)) values.add(val)
normalised = self.samdb.dsdb_normalise_attributes(self.samdb_schema, attrname, [val]) normalised = self.samdb.dsdb_normalise_attributes(self.samdb_schema, attrname, [val])
if len(normalised) != 1 or normalised[0] != val: if len(normalised) != 1 or normalised[0] != val:

View File

@ -27,6 +27,7 @@
__docformat__ = "restructuredText" __docformat__ = "restructuredText"
from samba.compat import urllib_quote from samba.compat import urllib_quote
from samba.compat import string_types
from base64 import b64encode from base64 import b64encode
import errno import errno
import os import os
@ -1573,8 +1574,8 @@ def fill_samdb(samdb, lp, names, logger, policyguid,
ntds_dn = "CN=NTDS Settings,%s" % names.serverdn ntds_dn = "CN=NTDS Settings,%s" % names.serverdn
names.ntdsguid = samdb.searchone(basedn=ntds_dn, names.ntdsguid = samdb.searchone(basedn=ntds_dn,
attribute="objectGUID", expression="", scope=ldb.SCOPE_BASE) attribute="objectGUID", expression="", scope=ldb.SCOPE_BASE).decode('utf8')
assert isinstance(names.ntdsguid, str) assert isinstance(names.ntdsguid, string_types)
return samdb return samdb
@ -1964,8 +1965,8 @@ def provision_fill(samdb, secrets_ldb, logger, names, paths,
backend_store=backend_store) backend_store=backend_store)
domainguid = samdb.searchone(basedn=samdb.get_default_basedn(), domainguid = samdb.searchone(basedn=samdb.get_default_basedn(),
attribute="objectGUID") attribute="objectGUID").decode('utf8')
assert isinstance(domainguid, str) assert isinstance(domainguid, string_types)
lastProvisionUSNs = get_last_provision_usn(samdb) lastProvisionUSNs = get_last_provision_usn(samdb)
maxUSN = get_max_usn(samdb, str(names.rootdn)) maxUSN = get_max_usn(samdb, str(names.rootdn))

View File

@ -1048,12 +1048,12 @@ schemaUpdateNow: 1
def get_dsServiceName(self): def get_dsServiceName(self):
'''get the NTDS DN from the rootDSE''' '''get the NTDS DN from the rootDSE'''
res = self.search(base="", scope=ldb.SCOPE_BASE, attrs=["dsServiceName"]) res = self.search(base="", scope=ldb.SCOPE_BASE, attrs=["dsServiceName"])
return res[0]["dsServiceName"][0] return str(res[0]["dsServiceName"][0])
def get_serverName(self): def get_serverName(self):
'''get the server DN from the rootDSE''' '''get the server DN from the rootDSE'''
res = self.search(base="", scope=ldb.SCOPE_BASE, attrs=["serverName"]) res = self.search(base="", scope=ldb.SCOPE_BASE, attrs=["serverName"])
return res[0]["serverName"][0] return str(res[0]["serverName"][0])
def dns_lookup(self, dns_name, dns_partition=None): def dns_lookup(self, dns_name, dns_partition=None):
'''Do a DNS lookup in the database, returns the NDR database structures''' '''Do a DNS lookup in the database, returns the NDR database structures'''