diff options
author | Raildo Mascena <rmascena@redhat.com> | 2019-07-24 10:20:17 -0300 |
---|---|---|
committer | Raildo Mascena <rmascena@redhat.com> | 2019-08-05 09:02:53 -0300 |
commit | e0507d7ec57f5044727039e2ebc42b29365195c4 (patch) | |
tree | 3f95a34a2900be19234e0caf2439bf01393b13fa | |
parent | 7b84e9fcf1c259fe32def301f5e94a2ded845533 (diff) | |
download | keystone-e0507d7ec57f5044727039e2ebc42b29365195c4.tar.gz |
Fix python3 compatibility on LDAP search DN from id
In Python 3, python-ldap no longer allows bytes for some fields (DNs,
RDNs, attribute names, queries). Instead, text values are represented
as str, the Unicode text type.
[1] More details about byte/str usage in python-ldap can be found at:
http://www.python-ldap.org/en/latest/bytes_mode.html#bytes-mode
Change-Id: I63e3715032cd8edb11fbff7651f5ba1af506dc9d
Related-Bug: #1798184
(cherry picked from commit 03531a56910b12922afde32b40e270b7d68a334b)
-rw-r--r-- | keystone/identity/backends/ldap/common.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/keystone/identity/backends/ldap/common.py b/keystone/identity/backends/ldap/common.py index b873d6e0e..3967aa7ff 100644 --- a/keystone/identity/backends/ldap/common.py +++ b/keystone/identity/backends/ldap/common.py @@ -1296,9 +1296,8 @@ class BaseLdap(object): def _dn_to_id(self, dn): # Check if the naming attribute in the DN is the same as keystone's # configured 'id' attribute'. If so, extract the ID value from the DN - if self.id_attr == utf8_decode( - ldap.dn.str2dn(utf8_encode(dn))[0][0][0].lower()): - return utf8_decode(ldap.dn.str2dn(utf8_encode(dn))[0][0][1]) + if self.id_attr == ldap.dn.str2dn(dn)[0][0][0].lower(): + return ldap.dn.str2dn(dn)[0][0][1] else: # The 'ID' attribute is NOT in the DN, so we need to perform an # LDAP search to look it up from the user entry itself. |