Browse Source

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 03531a5691)
changes/31/674031/2
Raildo Mascena 1 month ago
parent
commit
79ed42ee67
1 changed files with 2 additions and 3 deletions
  1. 2
    3
      keystone/identity/backends/ldap/common.py

+ 2
- 3
keystone/identity/backends/ldap/common.py View File

@@ -1284,9 +1284,8 @@ class BaseLdap(object):
1284 1284
     def _dn_to_id(self, dn):
1285 1285
         # Check if the naming attribute in the DN is the same as keystone's
1286 1286
         # configured 'id' attribute'.  If so, extract the ID value from the DN
1287
-        if self.id_attr == utf8_decode(
1288
-                ldap.dn.str2dn(utf8_encode(dn))[0][0][0].lower()):
1289
-            return utf8_decode(ldap.dn.str2dn(utf8_encode(dn))[0][0][1])
1287
+        if self.id_attr == ldap.dn.str2dn(dn)[0][0][0].lower():
1288
+            return ldap.dn.str2dn(dn)[0][0][1]
1290 1289
         else:
1291 1290
             # The 'ID' attribute is NOT in the DN, so we need to perform an
1292 1291
             # LDAP search to look it up from the user entry itself.

Loading…
Cancel
Save