diff --git a/uffd/user/models.py b/uffd/user/models.py index c666e14a3e644c686cb31a664d31f5d82a1dd583..bc4e038fab88d172ac6f359f03524b07e7342e11 100644 --- a/uffd/user/models.py +++ b/uffd/user/models.py @@ -19,7 +19,7 @@ class User(): # if you are in no groups, the "memberOf" attribute does not exist # if you are only in one group, ldap returns a string not an array with one element # we sanitize this to always be an array - sanitized_groups = ldapobject['memberOf'].value if 'memberOf' in ldapobject else [] + sanitized_groups = ldapobject['memberOf'].value if hasattr(ldapobject, 'memberOf') else [] if isinstance(sanitized_groups, str): sanitized_groups = [sanitized_groups] return User( @@ -121,10 +121,7 @@ class Group(): @classmethod def from_ldap(cls, ldapobject): - if 'description' in ldapobject: - description = ldapobject['description'].value - else: - description = '' + description = ldapobject['description'].value if hasattr(ldapobject, 'description') else '' # if a group has no members, "uniqueMember" attribute does not exist # if a group has exactly one member, ldap returns a string not an array with one element # we sanitize this to always be an array