1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

python/samba: bulk conversion of caller to dsdb_Dn 2nd param.

Convert second param to dsdb_Dn to be unicode so py2 & py3 code
will work

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
This commit is contained in:
Noel Power 2018-04-25 18:28:30 +01:00 committed by Noel Power
parent cbd6786c04
commit 13280d3db9
4 changed files with 15 additions and 15 deletions

View File

@ -286,7 +286,7 @@ class dbcheck(object):
listwko = []
proposed_objectguid = None
for o in wko:
dsdb_dn = dsdb_Dn(self.samdb, o, dsdb.DSDB_SYNTAX_BINARY_DN)
dsdb_dn = dsdb_Dn(self.samdb, o.decode('utf8'), dsdb.DSDB_SYNTAX_BINARY_DN)
if self.is_deleted_objects_dn(dsdb_dn):
self.report("wellKnownObjects had duplicate Deleted Objects value %s" % o)
# We really want to put this back in the same spot
@ -917,7 +917,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
controls=["show_deleted:0", "extended_dn:0", "reveal_internals:0"])
syntax_oid = self.samdb_schema.get_syntax_oid_from_lDAPDisplayName(attrname)
for val in res[0][attrname]:
dsdb_dn = dsdb_Dn(self.samdb, val, syntax_oid)
dsdb_dn = dsdb_Dn(self.samdb, val.decode('utf8'), syntax_oid)
guid2 = dsdb_dn.dn.get_extended_component("GUID")
if guid == guid2:
return dsdb_dn
@ -943,7 +943,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
self.duplicate_link_cache[duplicate_cache_key] = False
for val in obj[forward_attr]:
dsdb_dn = dsdb_Dn(self.samdb, val, forward_syntax)
dsdb_dn = dsdb_Dn(self.samdb, val.decode('utf8'), forward_syntax)
# all DNs should have a GUID component
guid = dsdb_dn.dn.get_extended_component("GUID")
@ -1178,7 +1178,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
obj[attrname] = ldb.MessageElement(vals, 0, attrname)
for val in obj[attrname]:
dsdb_dn = dsdb_Dn(self.samdb, val, syntax_oid)
dsdb_dn = dsdb_Dn(self.samdb, val.decode('utf8'), syntax_oid)
# all DNs should have a GUID component
guid = dsdb_dn.dn.get_extended_component("GUID")
@ -1312,7 +1312,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
match_count = 0
if reverse_link_name in res[0]:
for v in res[0][reverse_link_name]:
v_dn = dsdb_Dn(self.samdb, v)
v_dn = dsdb_Dn(self.samdb, v.decode('utf8'))
v_guid = v_dn.dn.get_extended_component("GUID")
v_blob = v_dn.dn.get_extended_component("RMD_FLAGS")
v_rmd_flags = 0
@ -1329,7 +1329,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
# Forward binary multi-valued linked attribute
forward_count = 0
for w in obj[attrname]:
w_guid = dsdb_Dn(self.samdb, w).dn.get_extended_component("GUID")
w_guid = dsdb_Dn(self.samdb, w.decode('utf8')).dn.get_extended_component("GUID")
if w_guid == guid:
forward_count += 1
@ -1337,7 +1337,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
continue
expected_count = 0
for v in obj[attrname]:
v_dn = dsdb_Dn(self.samdb, v)
v_dn = dsdb_Dn(self.samdb, v.decode('utf8'))
v_guid = v_dn.dn.get_extended_component("GUID")
v_blob = v_dn.dn.get_extended_component("RMD_FLAGS")
v_rmd_flags = 0

View File

@ -739,7 +739,7 @@ class DirectoryServiceAgent(object):
for value in res[0][k]:
# Turn dn into a dsdb_Dn so we can use
# its methods to parse a binary DN
dsdn = dsdb_Dn(samdb, value)
dsdn = dsdb_Dn(samdb, value.decode('utf8'))
flags = dsdn.get_binary_integer()
dnstr = str(dsdn.dn)
@ -986,7 +986,7 @@ class NTDSConnection(object):
"for (%s)" % (self.dnstr))
if "transportType" in msg:
dsdn = dsdb_Dn(samdb, msg["transportType"][0])
dsdn = dsdb_Dn(samdb, msg["transportType"][0].decode('utf8'))
self.load_connection_transport(samdb, str(dsdn.dn))
if "schedule" in msg:
@ -996,7 +996,7 @@ class NTDSConnection(object):
self.whenCreated = ldb.string_to_time(msg["whenCreated"][0])
if "fromServer" in msg:
dsdn = dsdb_Dn(samdb, msg["fromServer"][0])
dsdn = dsdb_Dn(samdb, msg["fromServer"][0].decode('utf8'))
self.from_dnstr = str(dsdn.dn)
assert self.from_dnstr is not None
@ -1363,7 +1363,7 @@ class Partition(NamingContext):
continue
for value in msg[k]:
dsdn = dsdb_Dn(samdb, value)
dsdn = dsdb_Dn(samdb, value.decode('utf8'))
dnstr = str(dsdn.dn)
if k == "nCName":
@ -1926,7 +1926,7 @@ class Transport(object):
if "bridgeheadServerListBL" in msg:
for value in msg["bridgeheadServerListBL"]:
dsdn = dsdb_Dn(samdb, value)
dsdn = dsdb_Dn(samdb, value.decode('utf8'))
dnstr = str(dsdn.dn)
if dnstr not in self.bridgehead_list:
self.bridgehead_list.append(dnstr)
@ -2188,7 +2188,7 @@ class SiteLink(object):
if "siteList" in msg:
for value in msg["siteList"]:
dsdn = dsdb_Dn(samdb, value)
dsdn = dsdb_Dn(samdb, value.decode('utf8'))
guid = misc.GUID(dsdn.dn.get_extended_component('GUID'))
if guid not in self.site_list:
self.site_list.append(guid)

View File

@ -233,7 +233,7 @@ def samdb_to_ldif_file(samdb, dburl, lp, creds, ldif_file):
for value in msg[k]:
# Some of these have binary DNs so
# use dsdb_Dn to split out relevent parts
dsdn = dsdb_Dn(samdb, value)
dsdn = dsdb_Dn(samdb, value.decode('utf8'))
dnstr = str(dsdn.dn)
if dnstr not in nclist:
nclist.append(dnstr)

View File

@ -623,7 +623,7 @@ class DrsRodcTestCase(drs_base.DrsBaseTestCase):
packed_attrs = []
unpacked_attrs = []
for attribute in revealed_users:
dsdb_dn = dsdb_Dn(self.ldb_dc1, attribute)
dsdb_dn = dsdb_Dn(self.ldb_dc1, attribute.decode('utf8'))
metadata = ndr_unpack(drsblobs.replPropertyMetaData1, dsdb_dn.get_bytes())
if user_dn in attribute:
unpacked_attrs.append(metadata)