Skip to content
Snippets Groups Projects
Verified Commit 1ddc5332 authored by nd's avatar nd
Browse files

fix some ldap crap

parent d5e6a9e4
Branches
Tags
No related merge requests found
...@@ -19,7 +19,7 @@ class User(): ...@@ -19,7 +19,7 @@ class User():
# if you are in no groups, the "memberOf" attribute does not exist # 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 # 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 # 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): if isinstance(sanitized_groups, str):
sanitized_groups = [sanitized_groups] sanitized_groups = [sanitized_groups]
return User( return User(
...@@ -121,10 +121,7 @@ class Group(): ...@@ -121,10 +121,7 @@ class Group():
@classmethod @classmethod
def from_ldap(cls, ldapobject): def from_ldap(cls, ldapobject):
if 'description' in ldapobject: description = ldapobject['description'].value if hasattr(ldapobject, 'description') else ''
description = ldapobject['description'].value
else:
description = ''
# if a group has no members, "uniqueMember" attribute does not exist # 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 # 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 # we sanitize this to always be an array
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment