Do not assume users have names

This should be a safe assumption, but hughsaunders ran into a deployment
where a small subset of users (backed by AD) were configured with:

    [ldap]
    user_name_attribute = sAMAccountName

Where sAMAccountName happens to be an optional attribute in some LDAP
systems, resulting in those users not having "name" attributes available
via Keystone's API.

closes-bug: 1431942

Change-Id: Ic69e571c71fd462c65791800eaaa474917dec2ef
This commit is contained in:
Dolph Mathews 2015-03-13 10:13:20 -05:00 committed by Hugh Saunders
parent af64fa9f1f
commit 903e7b3d0d

View File

@ -461,7 +461,7 @@ class ManageKeystone(object):
:param name: ``str`` Name of the user. :param name: ``str`` Name of the user.
""" """
for entry in self.keystone.users.list(): for entry in self.keystone.users.list():
if entry.name == name: if getattr(entry, 'name', None) == name:
return entry return entry
else: else:
return None return None