diff options
author | Lumir Balhar <lbalhar@redhat.com> | 2018-01-30 18:52:11 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2018-02-15 00:18:29 +0100 |
commit | bc7c6c15da0ba42cd7f4b3551d2ab33f349bae1b (patch) | |
tree | 0de5fbbade3e7fa5c1e83f667e1aee6a5225a962 /python | |
parent | cb15e32f85f7a69dff0e461ec3536a84e95407ca (diff) | |
download | samba-bc7c6c15da0ba42cd7f4b3551d2ab33f349bae1b.tar.gz |
python: Port samdb module to Python 3 compatible form
Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/samba/common.py | 2 | ||||
-rw-r--r-- | python/samba/samdb.py | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/python/samba/common.py b/python/samba/common.py index a915934f184..1c410a4702d 100644 --- a/python/samba/common.py +++ b/python/samba/common.py @@ -18,7 +18,7 @@ import ldb -import dsdb +from samba import dsdb from samba.ndr import ndr_pack from samba.dcerpc import misc import binascii diff --git a/python/samba/samdb.py b/python/samba/samdb.py index abc7e188853..89014a53ed2 100644 --- a/python/samba/samdb.py +++ b/python/samba/samdb.py @@ -31,6 +31,7 @@ from samba import dsdb, dsdb_dns from samba.ndr import ndr_unpack, ndr_pack from samba.dcerpc import drsblobs, misc from samba.common import normalise_int32 +from samba.compat import text_type __docformat__ = "restructuredText" @@ -509,7 +510,7 @@ member: %s if len(res) > 1: raise Exception('Matched %u multiple users with filter "%s"' % (len(res), search_filter)) user_dn = res[0].dn - pw = unicode('"' + password.encode('utf-8') + '"', 'utf-8').encode('utf-16-le') + pw = text_type(b'"' + password.encode('utf-8') + b'"', 'utf-8').encode('utf-16-le') setpw = """ dn: %s changetype: modify @@ -690,7 +691,7 @@ accountExpires: %u """ if len(self.hash_oid_name.keys()) == 0: self._populate_oid_attid() - if self.hash_oid_name.has_key(self.get_oid_from_attid(attid)): + if self.get_oid_from_attid(attid) in self.hash_oid_name: return self.hash_oid_name[self.get_oid_from_attid(attid)] else: return None @@ -729,14 +730,14 @@ accountExpires: %u return None repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob, - str(res[0]["replPropertyMetaData"])) + res[0]["replPropertyMetaData"][0]) ctr = repl.ctr if len(self.hash_oid_name.keys()) == 0: self._populate_oid_attid() for o in ctr.array: # Search for Description att_oid = self.get_oid_from_attid(o.attid) - if self.hash_oid_name.has_key(att_oid) and\ + if att_oid in self.hash_oid_name and\ att.lower() == self.hash_oid_name[att_oid].lower(): return o.version return None @@ -751,7 +752,7 @@ accountExpires: %u return None repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob, - str(res[0]["replPropertyMetaData"])) + res[0]["replPropertyMetaData"][0]) ctr = repl.ctr now = samba.unix2nttime(int(time.time())) found = False @@ -760,7 +761,7 @@ accountExpires: %u for o in ctr.array: # Search for Description att_oid = self.get_oid_from_attid(o.attid) - if self.hash_oid_name.has_key(att_oid) and\ + if att_oid in self.hash_oid_name and\ att.lower() == self.hash_oid_name[att_oid].lower(): found = True seq = self.sequence_number(ldb.SEQ_NEXT) |