mirror of
https://github.com/samba-team/samba.git
synced 2025-07-29 15:42:04 +03:00
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>
This commit is contained in:
committed by
Andrew Bartlett
parent
cb15e32f85
commit
bc7c6c15da
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import ldb
|
import ldb
|
||||||
import dsdb
|
from samba import dsdb
|
||||||
from samba.ndr import ndr_pack
|
from samba.ndr import ndr_pack
|
||||||
from samba.dcerpc import misc
|
from samba.dcerpc import misc
|
||||||
import binascii
|
import binascii
|
||||||
|
@ -31,6 +31,7 @@ from samba import dsdb, dsdb_dns
|
|||||||
from samba.ndr import ndr_unpack, ndr_pack
|
from samba.ndr import ndr_unpack, ndr_pack
|
||||||
from samba.dcerpc import drsblobs, misc
|
from samba.dcerpc import drsblobs, misc
|
||||||
from samba.common import normalise_int32
|
from samba.common import normalise_int32
|
||||||
|
from samba.compat import text_type
|
||||||
|
|
||||||
__docformat__ = "restructuredText"
|
__docformat__ = "restructuredText"
|
||||||
|
|
||||||
@ -509,7 +510,7 @@ member: %s
|
|||||||
if len(res) > 1:
|
if len(res) > 1:
|
||||||
raise Exception('Matched %u multiple users with filter "%s"' % (len(res), search_filter))
|
raise Exception('Matched %u multiple users with filter "%s"' % (len(res), search_filter))
|
||||||
user_dn = res[0].dn
|
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 = """
|
setpw = """
|
||||||
dn: %s
|
dn: %s
|
||||||
changetype: modify
|
changetype: modify
|
||||||
@ -690,7 +691,7 @@ accountExpires: %u
|
|||||||
"""
|
"""
|
||||||
if len(self.hash_oid_name.keys()) == 0:
|
if len(self.hash_oid_name.keys()) == 0:
|
||||||
self._populate_oid_attid()
|
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)]
|
return self.hash_oid_name[self.get_oid_from_attid(attid)]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
@ -729,14 +730,14 @@ accountExpires: %u
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob,
|
repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob,
|
||||||
str(res[0]["replPropertyMetaData"]))
|
res[0]["replPropertyMetaData"][0])
|
||||||
ctr = repl.ctr
|
ctr = repl.ctr
|
||||||
if len(self.hash_oid_name.keys()) == 0:
|
if len(self.hash_oid_name.keys()) == 0:
|
||||||
self._populate_oid_attid()
|
self._populate_oid_attid()
|
||||||
for o in ctr.array:
|
for o in ctr.array:
|
||||||
# Search for Description
|
# Search for Description
|
||||||
att_oid = self.get_oid_from_attid(o.attid)
|
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():
|
att.lower() == self.hash_oid_name[att_oid].lower():
|
||||||
return o.version
|
return o.version
|
||||||
return None
|
return None
|
||||||
@ -751,7 +752,7 @@ accountExpires: %u
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob,
|
repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob,
|
||||||
str(res[0]["replPropertyMetaData"]))
|
res[0]["replPropertyMetaData"][0])
|
||||||
ctr = repl.ctr
|
ctr = repl.ctr
|
||||||
now = samba.unix2nttime(int(time.time()))
|
now = samba.unix2nttime(int(time.time()))
|
||||||
found = False
|
found = False
|
||||||
@ -760,7 +761,7 @@ accountExpires: %u
|
|||||||
for o in ctr.array:
|
for o in ctr.array:
|
||||||
# Search for Description
|
# Search for Description
|
||||||
att_oid = self.get_oid_from_attid(o.attid)
|
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():
|
att.lower() == self.hash_oid_name[att_oid].lower():
|
||||||
found = True
|
found = True
|
||||||
seq = self.sequence_number(ldb.SEQ_NEXT)
|
seq = self.sequence_number(ldb.SEQ_NEXT)
|
||||||
|
Reference in New Issue
Block a user